diff --git a/.abs/main.yaml b/.abs/main.yaml index 9bb5245..8d15b29 100644 --- a/.abs/main.yaml +++ b/.abs/main.yaml @@ -2,3 +2,4 @@ replace-chart-version-with-git: true generate-metadata: true chart-dir: ./helm/agent destination: ./build +helm-template-extra-values: [./helm/agent/ci/ci-values.yaml] diff --git a/.ats/main.yaml b/.ats/main.yaml index aef17b6..bf78176 100644 --- a/.ats/main.yaml +++ b/.ats/main.yaml @@ -16,8 +16,8 @@ # smoke test_smoke.py: a release with tests/ats/values-smoke.yaml (every # field the chart maps, a public git skill pinned to a commit) # reaches Ready and its RemoteMCPServer is accepted; a release -# with the chart's default values reaches Ready with its -# RemoteMCPServer. +# with the chart's default values and the required +# modelConfig.name reaches Ready with its RemoteMCPServer. # functional test_chat_only.py: toolset ["preset:none"] reaches Ready with no # RemoteMCPServer. test_fail_fast.py: the readiness wait answers # in seconds, with the reason, for an Agent whose Harness does diff --git a/CHANGELOG.md b/CHANGELOG.md index 206c6c3..c70faa7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- **BREAKING** Chart 3.0: `modelConfig.name` is required and has no default (it was `default-model-config`). The values schema refuses a release without a name, or with one that is not a valid Kubernetes object name. The chart looks nothing up: set `modelConfig.name` before upgrading, to the namespace's default model (the ModelConfig annotated `agent-platform.giantswarm.io/is-default-model-config: "true"`) or another ModelConfig in the agent's namespace. A release that already sets it upgrades unchanged (giantswarm/agent#124). + ### Removed - Chart 2.0: the `kagent.dev/v1alpha3 AgentTemplate` and the admission label `agent-platform.giantswarm.io/harness`. The chart renders one `api.kagent.dev/v1alpha3 Agent` instead (see Changed); `Harness.spec.allowedAgentTemplates` no longer exists in the API, so no label selects a Harness. An upgrade of a 1.x release replaces the `AgentTemplate` with an `Agent` of the same name. The chart installs only on a platform that serves `api.kagent.dev` (kagent-dev/kagent#2952). diff --git a/Makefile.custom.mk b/Makefile.custom.mk index 2714d12..4a98a19 100644 --- a/Makefile.custom.mk +++ b/Makefile.custom.mk @@ -13,11 +13,11 @@ APPLICATION := agent .PHONY: helm-lint helm-lint: ## Lint the chart. - helm lint helm/agent + helm lint helm/agent --values helm/agent/ci/ci-values.yaml .PHONY: helm-template -helm-template: ## Render the chart with defaults. - helm template agent helm/agent +helm-template: ## Render the chart with defaults and the required modelConfig.name. + helm template agent helm/agent --values helm/agent/ci/ci-values.yaml # Prerequisite-only, no recipe: make merges it into the generated helm-test # rule, which keeps its recipe (the helm-unittest run) and gains the lint. diff --git a/README.md b/README.md index 3c6fd0b..09998f1 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,10 @@ It never touches: becomes Ready; - **`ModelConfig`** CRs and the `Secret`s they reference (LLM credentials) — platform-owned, provisioned per tenant namespace. The chart wires the agent - to one **by name** (`modelConfig.name`, default `default-model-config`). + to one **by name** (`modelConfig.name`, required, no default). The + namespace's default model is the ModelConfig annotated + `agent-platform.giantswarm.io/is-default-model-config: "true"`; the chart + looks nothing up, so name it (or another ModelConfig) explicitly. ## Usage @@ -51,6 +54,9 @@ Install with whatever you already use for Helm charts (Argo CD, Flux `HelmRelease`, `helm install`). A minimal values file yields a working agent: ```yaml +modelConfig: + name: claude-sonnet # a ModelConfig in the agent's namespace; required + agent: displayName: "SRE Assistant" # Unicode, becomes the ui.giantswarm.io/display-name annotation description: Helps the SRE team triage incidents. @@ -379,6 +385,17 @@ fail with a legible error before anything hits the cluster. Upgrades are values changes plus a re-apply; uninstalling the release removes the agent. Pin the chart version for reproducibility. +## Migrating from 2.x + +Chart 3.0 drops the default of `modelConfig.name` (it was +`default-model-config`, a ModelConfig installations no longer ship). The value +is required: the values schema refuses a release without it. Set it to the +namespace's default model, the ModelConfig annotated +`agent-platform.giantswarm.io/is-default-model-config: "true"` +(`kubectl get modelconfigs -n -o jsonpath='{.items[?(@.metadata.annotations.agent-platform\.giantswarm\.io/is-default-model-config=="true")].metadata.name}'`), +or to any other ModelConfig in the namespace. A release that already sets +`modelConfig.name` upgrades unchanged. + ## Migrating from 1.x Chart 2.0 renders the kagent API that ships the `Agent` kind diff --git a/helm/agent/README.md b/helm/agent/README.md index ae0f2d7..626bb8b 100644 --- a/helm/agent/README.md +++ b/helm/agent/README.md @@ -26,8 +26,8 @@ What an agent can reach and how to add a host (`agent.egress`): [What an agent c | agent.egressPolicyRefs | list | `[]` | Names of EgressPolicies in the agent's namespace whose origins (and credential headers) the agent may also reach, such as `github` or `go-modules`. Rendered into the Agent's spec.egressPolicyRefs as `{name}` entries; the chart copies none of a policy's rules, so a change to the policy reaches the agent from its next Session without an upgrade of this release. At most 16 unique names. A name with no EgressPolicy in the namespace keeps the Agent from becoming Ready (ResolvedRefs=False). | | agent.platformPrompt | object | `{"egressNote":false}` | Sections the platform appends to the system prompt, after `systemMessage`. The platform (agent-manager) sets them, not the agent's author: the chart owns their wording, so a chart release updates them on every agent, and an edit of `systemMessage` neither shows nor removes them. | | agent.platformPrompt.egressNote | bool | `false` | Append the network access note: a `## Network access (set by the platform)` section that names the origins of `egress` and the registries of the toolchains mounted under /opt/kagent/tools, and tells the agent that a request to any other host is refused by policy, not an outage to retry. agent-manager sets it on every agent on a coding Harness (any runtime but kagent's). | -| modelConfig | object | `{"name":"default-model-config"}` | Which platform-provisioned ModelConfig the agent uses, referenced by name. kagent resolves it in the agent's own namespace. The chart never creates or mutates a ModelConfig, and tenants never handle LLM credentials. | -| modelConfig.name | string | `"default-model-config"` | Name of the platform-provisioned ModelConfig in the agent's namespace. Rendered into the Agent's spec.template.modelConfig.name. | +| modelConfig | object | `{"name":""}` | Which platform-provisioned ModelConfig the agent uses, referenced by name. kagent resolves it in the agent's own namespace. The chart never creates or mutates a ModelConfig, and tenants never handle LLM credentials. | +| modelConfig.name | string | `""` | Required. Name of the platform-provisioned ModelConfig in the agent's namespace, rendered into the Agent's spec.template.modelConfig.name. The chart has no default and looks nothing up: name the namespace's default model, the ModelConfig annotated `agent-platform.giantswarm.io/is-default-model-config: "true"`, or another ModelConfig in the namespace. | | context | object | `{"compaction":{"compactionInterval":null,"enabled":true,"eventRetentionSize":4,"overlapSize":null,"summarizer":{"modelConfig":"","promptTemplate":""},"tokenThreshold":24000}}` | Kept for the values of existing releases; rendered into nothing. Context compaction moved from the agent's template to the platform Harness (kagent-dev/kagent#2790; Harness.spec.kagent.compaction, set by the platform as kagent.harness.compaction), where it applies to every agent the Harness admits. The kagent line from 1.1.0 has no spec.context on the AgentTemplate, and a template that carries it is refused at admission. Everything under this key is ignored. | | context.compaction | object | `{"compactionInterval":null,"enabled":true,"eventRetentionSize":4,"overlapSize":null,"summarizer":{"modelConfig":"","promptTemplate":""},"tokenThreshold":24000}` | Compaction keeps the prompt bounded as a turn grows. Without it every tool result stays in the history verbatim and every later model call of the turn re-reads all of it: a status question that lists pods and events grows from 6 k to 60 k input tokens in ten calls, waits 9-19 s for the first token of every call after a large listing, and pays for the whole history on every call. The default is tail retention, the strategy that bounds a long tool loop: before a model call whose prompt has passed `tokenThreshold`, the runtime replaces everything but the last `eventRetentionSize` events and the turn's own question with one rolling summary (the previous summary is folded into the next, so the history is one summary plus a raw tail). A summary is a model call too — on the agent's own model unless `summarizer` names another — and it reads the events it replaces once, so a turn under the threshold pays nothing and a turn over it pays one summary per crossing instead of re-reading the whole history on every call; what leaves the raw tail survives only as the summary describes it (values and the registered tool names verbatim, per the runtime's default prompt). | | context.compaction.enabled | bool | `true` | Render spec.context.compaction. `false` renders no spec.context at all: the agent keeps every word of a long turn verbatim and pays for re-reading it. | diff --git a/helm/agent/ci/ci-values.yaml b/helm/agent/ci/ci-values.yaml new file mode 100644 index 0000000..20a2f20 --- /dev/null +++ b/helm/agent/ci/ci-values.yaml @@ -0,0 +1,8 @@ +# ct lint case: the default values plus the required modelConfig.name, +# toolset unset (implicit full access). +# ct lints each ci/*-values.yaml in place of the bare defaults, so the +# default shape needs its own case. The check-values-schema workflow merges +# this file (by its name) over values.yaml before validating against the +# schema, and app-build-suite renders the chart with it (.abs/main.yaml). +modelConfig: + name: demo-model diff --git a/helm/agent/ci/default-values.yaml b/helm/agent/ci/default-values.yaml deleted file mode 100644 index 9053563..0000000 --- a/helm/agent/ci/default-values.yaml +++ /dev/null @@ -1,3 +0,0 @@ -# ct lint case: the default values, toolset unset (implicit full access). -# ct lints each ci/*-values.yaml in place of the bare defaults, so the -# default shape needs its own case. diff --git a/helm/agent/ci/toolset-none-values.yaml b/helm/agent/ci/toolset-none-values.yaml index d3152cc..8c45e81 100644 --- a/helm/agent/ci/toolset-none-values.yaml +++ b/helm/agent/ci/toolset-none-values.yaml @@ -1,3 +1,5 @@ # ct lint case: an agent without tools, toolset exactly ["preset:none"]. toolset: - preset:none +modelConfig: + name: demo-model diff --git a/helm/agent/ci/toolset-selectors-values.yaml b/helm/agent/ci/toolset-selectors-values.yaml index 503fc26..3e4c4be 100644 --- a/helm/agent/ci/toolset-selectors-values.yaml +++ b/helm/agent/ci/toolset-selectors-values.yaml @@ -2,3 +2,5 @@ toolset: - preset:read-only - workflow:incident-triage +modelConfig: + name: demo-model diff --git a/helm/agent/tests/__snapshot__/agent_test.yaml.snap b/helm/agent/tests/__snapshot__/agent_test.yaml.snap index b97550b..ca9737b 100644 --- a/helm/agent/tests/__snapshot__/agent_test.yaml.snap +++ b/helm/agent/tests/__snapshot__/agent_test.yaml.snap @@ -18,7 +18,7 @@ renders the default values (golden): name: kagent template: modelConfig: - name: default-model-config + name: demo-model systemPrompt: You are a helpful agent. tools: - mcp: diff --git a/helm/agent/tests/agent_test.yaml b/helm/agent/tests/agent_test.yaml index 8c35eb4..0ea8c44 100644 --- a/helm/agent/tests/agent_test.yaml +++ b/helm/agent/tests/agent_test.yaml @@ -14,6 +14,10 @@ templates: release: name: demo namespace: demo-ns +# modelConfig.name has no default; every test names a model unless it tests +# the refusal. +set: + modelConfig.name: demo-model tests: - it: renders the default values (golden) asserts: @@ -49,7 +53,7 @@ tests: path: spec.template.plugins - equal: path: spec.template.modelConfig.name - value: default-model-config + value: demo-model - equal: path: spec.template.systemPrompt value: You are a helpful agent. @@ -284,6 +288,30 @@ tests: - failedTemplate: errorPattern: 'agent[./]platformPrompt' + - it: refuses a release without modelConfig.name + set: + modelConfig: + name: null + asserts: + - failedTemplate: + errorPattern: "/modelConfig': missing property 'name'" + + - it: refuses an empty modelConfig.name + set: + modelConfig: + name: "" + asserts: + - failedTemplate: + errorPattern: "/modelConfig/name': minLength" + + - it: refuses a modelConfig.name that is not a Kubernetes object name + set: + modelConfig: + name: Claude Sonnet + asserts: + - failedTemplate: + errorPattern: "/modelConfig/name': .*does not match pattern" + - it: references the ModelConfig by name set: modelConfig: diff --git a/helm/agent/tests/remotemcpserver_test.yaml b/helm/agent/tests/remotemcpserver_test.yaml index 919240c..6de7367 100644 --- a/helm/agent/tests/remotemcpserver_test.yaml +++ b/helm/agent/tests/remotemcpserver_test.yaml @@ -10,6 +10,10 @@ templates: release: name: demo namespace: demo-ns +# modelConfig.name has no default and the values schema refuses a release +# without it, whatever template is rendered. +set: + modelConfig.name: demo-model tests: - it: renders the default values (golden) asserts: diff --git a/helm/agent/values.schema.json b/helm/agent/values.schema.json index 173b11b..fa9e601 100644 --- a/helm/agent/values.schema.json +++ b/helm/agent/values.schema.json @@ -384,12 +384,17 @@ "modelConfig": { "type": "object", "description": "Which platform-provisioned ModelConfig the agent uses, referenced by name. kagent resolves it in the agent's own namespace. The chart never creates or mutates a ModelConfig, and tenants never handle LLM credentials.", + "required": [ + "name" + ], "additionalProperties": false, "properties": { "name": { "type": "string", - "description": "Name of the platform-provisioned ModelConfig in the agent's namespace. Rendered into the Agent's spec.template.modelConfig.name.", - "minLength": 1 + "description": "Required. Name of the platform-provisioned ModelConfig in the agent's namespace, rendered into the Agent's spec.template.modelConfig.name. The chart has no default and looks nothing up: name the namespace's default model, the ModelConfig annotated `agent-platform.giantswarm.io/is-default-model-config: \"true\"`, or another ModelConfig in the namespace.", + "maxLength": 253, + "minLength": 1, + "pattern": "^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$" } } }, diff --git a/helm/agent/values.yaml b/helm/agent/values.yaml index 535449b..c57daf8 100644 --- a/helm/agent/values.yaml +++ b/helm/agent/values.yaml @@ -105,10 +105,14 @@ agent: # kagent resolves it in the agent's own namespace. The chart never creates or # mutates a ModelConfig, and tenants never handle LLM credentials. modelConfig: - # @schema type:string;minLength:1 - # -- Name of the platform-provisioned ModelConfig in the agent's namespace. - # Rendered into the Agent's spec.template.modelConfig.name. - name: default-model-config + # @schema type:string;minLength:1;maxLength:253;pattern:^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$;required:true + # -- Required. Name of the platform-provisioned ModelConfig in the agent's + # namespace, rendered into the Agent's spec.template.modelConfig.name. The + # chart has no default and looks nothing up: name the namespace's default + # model, the ModelConfig annotated + # `agent-platform.giantswarm.io/is-default-model-config: "true"`, or another + # ModelConfig in the namespace. + name: "" # -- Kept for the values of existing releases; rendered into nothing. Context # compaction moved from the agent's template to the platform Harness diff --git a/tests/ats/conftest.py b/tests/ats/conftest.py index d1dcda9..4a39156 100644 --- a/tests/ats/conftest.py +++ b/tests/ats/conftest.py @@ -558,8 +558,11 @@ def assert_all_conditions_true(entry: Dict[str, Any], generation: int) -> None: def install_release(helm: Helm, chart_archive: Path, release: str, values: Optional[Path] = None, sets: Optional[List[str]] = None) -> None: """`helm install` of a release of the chart under test into the Harness's - namespace. No --wait: the chart renders custom resources only, and the - readiness that matters is asserted by wait_agent_ready.""" + namespace, bound to the ModelConfig the kagent release renders + (modelConfig.name has no default). No --wait: the chart renders custom + resources only, and the readiness that matters is asserted by + wait_agent_ready.""" + sets = [f"modelConfig.name={MODEL_CONFIG}", *(sets or [])] helm.install(release, str(chart_archive), KAGENT_NAMESPACE, values=[values] if values else None, sets=sets, wait=False, timeout="2m") diff --git a/tests/ats/test_smoke.py b/tests/ats/test_smoke.py index dfa4c8b..81fbea4 100644 --- a/tests/ats/test_smoke.py +++ b/tests/ats/test_smoke.py @@ -10,9 +10,9 @@ resolves the Harness, is compiled and booted into a golden snapshot (the skill is materialised on the way), and the agent's RemoteMCPServer is accepted with no failed condition. - * `ats-defaults` with the chart's default values — the smallest release an - operator can install. Ready too, with its RemoteMCPServer (the default - toolset binds muster). + * `ats-defaults` with the chart's default values and the required + modelConfig.name: the smallest release an operator can install. Ready + too, with its RemoteMCPServer (the default toolset binds muster). Ready means compiled and bootable on the platform's runtime; no model is called (the provider key is a placeholder). @@ -31,6 +31,7 @@ FIRST_BOOT_TIMEOUT_S, HARNESS, KAGENT_NAMESPACE, + MODEL_CONFIG, TOOLSET_HEADER, Kube, agent_generation, @@ -67,7 +68,7 @@ def test_smoke_release_reaches_ready_with_a_git_skill(kube: Kube, release: Calla assert annotations["ui.giantswarm.io/display-name"] == "ATS Smoke Agent" assert annotations["ui.giantswarm.io/icon-url"] == "https://avatars.example.com/ats-smoke.svg" assert annotations["giantswarm.io/scenario"] == "smoke" - assert spec["modelConfig"] == {"name": "default-model-config"} + assert spec["modelConfig"] == {"name": MODEL_CONFIG} assert spec["description"] == "Exercises the chart's field mapping on the platform's runtime." assert spec["systemPrompt"] == "You are the chart's smoke test. Be brief." # context.compaction in the values renders nothing: compaction lives on the @@ -104,7 +105,7 @@ def test_default_values_reach_ready_with_a_remotemcpserver(kube: Kube, release: agent = kube.get(AGENTS, DEFAULTS_RELEASE, namespace=KAGENT_NAMESPACE) assert agent assert agent["spec"]["harnessRef"] == {"name": HARNESS} - assert agent["spec"]["template"]["modelConfig"] == {"name": "default-model-config"} + assert agent["spec"]["template"]["modelConfig"] == {"name": MODEL_CONFIG} assert "context" not in agent["spec"]["template"] assert agent["spec"]["template"]["tools"] == [{"mcp": {"server": {"kind": "RemoteMCPServer", "name": DEFAULTS_RELEASE}}}]