Skip to content

refactor: standardize environment settings and generate their reference - #2967

Merged
EItanya merged 14 commits into
mainfrom
docs/env-reference
Sep 27, 2026
Merged

EItanya merged 14 commits into
mainfrom
docs/env-reference

Conversation

@EItanya

@EItanya EItanya commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Kagent-specific environment variables had inconsistent names, and the registry was missing settings used by the controller, CLI, runtimes, Python packages, and UI. This PR standardizes those names under KAGENT_ and generates docs/env.md from the existing ENV registry. The reference covers 138 user-configurable settings; controller-owned payloads, generated credentials, and private runtime wiring are excluded.

This is a direct pre-release rename. Custom deployment environments and local configuration need to use the new names, for example LOG_LEVEL → KAGENT_LOG_LEVEL, POSTGRES_DATABASE_URL → KAGENT_POSTGRES_DATABASE_URL, and the Go ADK's PORT → KAGENT_PORT. The old names are no longer read by kagent. Helm output, runtime injection, scripts, and examples use the new names. Upstream SDK and tool conventions such as OTEL_*, provider credentials, and KUBECONFIG stay unchanged.

  • make env-docs generates the reference through kagent env. make env-docs-check checks freshness without modifying it and runs in the existing manifests-check CI job. The workflow includes changes to docs/env.md while skipping other Markdown-only changes, with no additional job. Generation exports registered metadata, never values from the current process environment.

  • Registration functions accept multiple components so shared settings only need one registration. Filters match any listed component; JSON exports a components array instead of the previous component string.

  • Go controller, CLI, ADK, provider, logging, telemetry, E2E, and upgrade-test settings read through registered accessors. Telemetry rendering takes its environment names and protocol default from the same registry. Get() and Lookup() preserve component-specific defaults and precedence. Boolean/integer LookupWithError() preserves diagnostics for invalid migration and capture-limit settings. Go booleans accept true/t/1 and false/f/0 regardless of case or surrounding whitespace; upstream OTEL_SDK_DISABLED retains its true-only grammar. The Python ADK HTTP server uses shared KAGENT_LOG_LEVEL; the separate UVICORN_LOG_LEVEL override is removed.

  • The existing Go linter rejects direct os.Getenv/os.LookupEnv reads, including aliased imports and function references. E2E and upgrade tests are covered by the rule; unit tests may inspect process state directly. The registry itself and explained exceptions for generated payloads, credential placeholders, and the standalone BYO example remain allowed.

  • Both ADKs use KAGENT_PORT for A2A traffic. The controller supplies 80 once; Python's KAGENT_A2A_GRPC_ADDRESS is removed. Standalone defaults and explicit programmatic/CLI overrides are preserved, and Python's HTTP listener remains separately configured.

  • Chart-defined non-secret settings live in controller, UI, and bundled PostgreSQL ConfigMaps, loaded through envFrom. Pod-template checksums trigger rollouts when configuration changes. Credentials, downward-API values, values needing Kubernetes $(...) expansion, and explicit user env overrides stay in the Deployments.

  • Testing settings use KAGENT_TEST_* or KAGENT_E2E_*; UI settings use KAGENT_UI_*. UI containers and Vite consume the same names, including KAGENT_UI_ENABLE_MOCK. Browser configuration is limited to explicit UI settings, KAGENT_UI_EXTENSION_*, and build-time KAGENT_UI_VITE_* switches. Make targets, CI, Playwright, and local-development examples use the same prefixes. Upgrade tests also register their repository, version, registry, cluster, namespace, and context inputs under KAGENT_E2E_*; Make maps its existing build variables to those names. Existing empty-value fallbacks and true-only opt-in grammars are preserved.

  • Seven settings ignored by the controller are removed along with their Helm values and references. They covered authentication, gRPC TLS/message limits, and the default Substrate worker pool. The chart's MCP URL uses HTTP to match the controller listener. [BUG] Restore Helm-configured controller authentication end to end #2968 tracks restoring Helm-configured authentication end to end.

  • Image-digest lookups in CI and cluster setup consume the full Docker output. Exiting awk early can close the pipe while Docker is still writing and abort E2E setup under pipefail.

Validation passed:

  • Focused Go tests for the registry, controller app, CLI/database commands, ADK app/A2A/agent/providers/embedding/tools, logging, telemetry, harness configuration, and translators; make -C go lint (zero issues). Coverage checks unset values, invalid input, capture limits, and boolean grammars. Negative lint probes verify that aliased direct reads and function references are rejected, including in E2E test files. Focused configuration tests cover E2E URL precedence, mock-host overrides, and upgrade defaults/context selection; Make dry runs verify that both upgrade targets pass the registered names.

  • go build -mod=readonly passes for the Go ADK, both harnesses, and sandbox guest.

  • Sandbox guest Docker builder passes for linux/amd64 and linux/arm64 with -mod=readonly. Its minimal source context includes the ENV package required by logging.

  • make env-docs-check, including checks that stale or missing docs fail and a failed generator preserves existing documentation.

  • Helm unit tests (369 tests) and chart lint. Before/after renders preserve effective container environments across default, custom, external-database, and database-file configurations; setting changes update rollout checksums.

  • Python CLI, A2A configuration, and gRPC tests, plus Ruff on changed Python files. A real gRPC connection verifies the shared port is consumed and explicit addresses take precedence.

  • UI typecheck, focused unit tests (42 tests), and lint (no errors). Vite and container-startup smoke checks verify prefixed settings reach the browser and unrelated environment values stay private. Playwright configuration checks verify the renamed ports and mock/live switches; Upgrade packages compile without running cluster tests.

  • Full E2E suite passed on a clean local Kind cluster using images built from this branch: 52 top-level tests, zero failures, and 10 existing subtest skips in 7m01s, with four concurrent scenarios and tracing required. This covers all four harnesses, CLI invocation, checkpoints, controller restarts, scheduled runs, runtime revision lifecycle, and sandbox workflows. The BYO fixture uses KAGENT_PORT=80; the old PORT=80 left the runtime listening on 8080 while the gateway connected to 80. The interaction test reproduced that timeout before the fixture change and passed afterward.

@EItanya
EItanya requested review from a team and Charlesthebird as code owners September 27, 2026 12:29
@github-actions github-actions Bot added documentation Improvements or additions to documentation and removed documentation Improvements or additions to documentation labels Sep 27, 2026
@github-actions github-actions Bot added documentation Improvements or additions to documentation and removed documentation Improvements or additions to documentation labels Sep 27, 2026
@EItanya EItanya changed the title docs: generate and verify environment variable reference refactor: standardize environment settings and generate their reference Sep 27, 2026
Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
@blacksmith-sh

This comment has been minimized.

Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
@EItanya
EItanya merged commit d570870 into main Sep 27, 2026
31 checks passed
@EItanya
EItanya deleted the docs/env-reference branch September 27, 2026 15:06
alexdarbyshire pushed a commit to alexdarbyshire/kagent that referenced this pull request Oct 5, 2026
…ce (kagent-dev#2967)

Kagent-specific environment variables had inconsistent names, and the
registry was missing settings used by the controller, CLI, runtimes,
Python packages, and UI. This PR standardizes those names under
`KAGENT_` and generates `docs/env.md` from the existing ENV registry.
The reference covers 138 user-configurable settings; controller-owned
payloads, generated credentials, and private runtime wiring are
excluded.

This is a direct pre-release rename. Custom deployment environments and
local configuration need to use the new names, for example `LOG_LEVEL` →
`KAGENT_LOG_LEVEL`, `POSTGRES_DATABASE_URL` →
`KAGENT_POSTGRES_DATABASE_URL`, and the Go ADK's `PORT` → `KAGENT_PORT`.
The old names are no longer read by kagent. Helm output, runtime
injection, scripts, and examples use the new names. Upstream SDK and
tool conventions such as `OTEL_*`, provider credentials, and
`KUBECONFIG` stay unchanged.

- `make env-docs` generates the reference through `kagent env`. `make
env-docs-check` checks freshness without modifying it and runs in the
existing `manifests-check` CI job. The workflow includes changes to
`docs/env.md` while skipping other Markdown-only changes, with no
additional job. Generation exports registered metadata, never values
from the current process environment.
- Registration functions accept multiple components so shared settings
only need one registration. Filters match any listed component; JSON
exports a `components` array instead of the previous `component` string.
- Go controller, CLI, ADK, provider, logging, telemetry, E2E, and
upgrade-test settings read through registered accessors. Telemetry
rendering takes its environment names and protocol default from the same
registry. `Get()` and `Lookup()` preserve component-specific defaults
and precedence. Boolean/integer `LookupWithError()` preserves
diagnostics for invalid migration and capture-limit settings. Go
booleans accept `true`/`t`/`1` and `false`/`f`/`0` regardless of case or
surrounding whitespace; upstream `OTEL_SDK_DISABLED` retains its
true-only grammar. The Python ADK HTTP server uses shared
`KAGENT_LOG_LEVEL`; the separate `UVICORN_LOG_LEVEL` override is
removed.
- The existing Go linter rejects direct `os.Getenv`/`os.LookupEnv`
reads, including aliased imports and function references. E2E and
upgrade tests are covered by the rule; unit tests may inspect process
state directly. The registry itself and explained exceptions for
generated payloads, credential placeholders, and the standalone BYO
example remain allowed.
- Both ADKs use `KAGENT_PORT` for A2A traffic. The controller supplies
`80` once; Python's `KAGENT_A2A_GRPC_ADDRESS` is removed. Standalone
defaults and explicit programmatic/CLI overrides are preserved, and
Python's HTTP listener remains separately configured.
- Chart-defined non-secret settings live in controller, UI, and bundled
PostgreSQL ConfigMaps, loaded through `envFrom`. Pod-template checksums
trigger rollouts when configuration changes. Credentials, downward-API
values, values needing Kubernetes `$(...)` expansion, and explicit user
env overrides stay in the Deployments.
- Testing settings use `KAGENT_TEST_*` or `KAGENT_E2E_*`; UI settings
use `KAGENT_UI_*`. UI containers and Vite consume the same names,
including `KAGENT_UI_ENABLE_MOCK`. Browser configuration is limited to
explicit UI settings, `KAGENT_UI_EXTENSION_*`, and build-time
`KAGENT_UI_VITE_*` switches. Make targets, CI, Playwright, and
local-development examples use the same prefixes. Upgrade tests also
register their repository, version, registry, cluster, namespace, and
context inputs under `KAGENT_E2E_*`; Make maps its existing build
variables to those names. Existing empty-value fallbacks and true-only
opt-in grammars are preserved.
- Seven settings ignored by the controller are removed along with their
Helm values and references. They covered authentication, gRPC
TLS/message limits, and the default Substrate worker pool. The chart's
MCP URL uses HTTP to match the controller listener. kagent-dev#2968 tracks
restoring Helm-configured authentication end to end.

- Image-digest lookups in CI and cluster setup consume the full Docker
output. Exiting `awk` early can close the pipe while Docker is still
writing and abort E2E setup under `pipefail`.

Validation passed:

- Focused Go tests for the registry, controller app, CLI/database
commands, ADK app/A2A/agent/providers/embedding/tools, logging,
telemetry, harness configuration, and translators; `make -C go lint`
(zero issues). Coverage checks unset values, invalid input, capture
limits, and boolean grammars. Negative lint probes verify that aliased
direct reads and function references are rejected, including in E2E test
files. Focused configuration tests cover E2E URL precedence, mock-host
overrides, and upgrade defaults/context selection; Make dry runs verify
that both upgrade targets pass the registered names.
- `go build -mod=readonly` passes for the Go ADK, both harnesses, and
sandbox guest.
- Sandbox guest Docker builder passes for `linux/amd64` and
`linux/arm64` with `-mod=readonly`. Its minimal source context includes
the ENV package required by logging.
- `make env-docs-check`, including checks that stale or missing docs
fail and a failed generator preserves existing documentation.
- Helm unit tests (369 tests) and chart lint. Before/after renders
preserve effective container environments across default, custom,
external-database, and database-file configurations; setting changes
update rollout checksums.
- Python CLI, A2A configuration, and gRPC tests, plus Ruff on changed
Python files. A real gRPC connection verifies the shared port is
consumed and explicit addresses take precedence.
- UI typecheck, focused unit tests (42 tests), and lint (no errors).
Vite and container-startup smoke checks verify prefixed settings reach
the browser and unrelated environment values stay private. Playwright
configuration checks verify the renamed ports and mock/live switches;
Upgrade packages compile without running cluster tests.


- Full E2E suite passed on a clean local Kind cluster using images built
from this branch: 52 top-level tests, zero failures, and 10 existing
subtest skips in 7m01s, with four concurrent scenarios and tracing
required. This covers all four harnesses, CLI invocation, checkpoints,
controller restarts, scheduled runs, runtime revision lifecycle, and
sandbox workflows. The BYO fixture uses `KAGENT_PORT=80`; the old
`PORT=80` left the runtime listening on 8080 while the gateway connected
to 80. The interaction test reproduced that timeout before the fixture
change and passed afterward.

---------

Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant