From d74e3701cbd6cbf79d7cc7bfd73603bc27977713 Mon Sep 17 00:00:00 2001 From: Timo Derstappen Date: Thu, 22 Oct 2026 12:03:15 +0200 Subject: [PATCH 1/2] feat: agent.egressPolicyRefs picks the namespace's EgressPolicies --- CHANGELOG.md | 2 ++ README.md | 26 ++++++++++++++ helm/agent/README.md | 3 +- helm/agent/templates/agent.yaml | 6 ++++ helm/agent/tests/agent_test.yaml | 61 ++++++++++++++++++++++++++++++++ helm/agent/values.schema.json | 10 ++++++ helm/agent/values.yaml | 9 +++++ 7 files changed, 116 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c17fe1e..89a366a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- `agent.egressPolicyRefs` (empty by default): names of EgressPolicies in the agent's namespace, rendered into the Agent's `spec.egressPolicyRefs` as `{name}` entries beside `spec.egress`. The chart copies none of a policy's rules. At most 16 unique resource names; the schema refuses anything else, naming the entry. Needs a kagent line that serves `egresspolicies.api.kagent.dev` (giantswarm/kagent-upstream#620). + - `agent.egress` accepts `tls://:` entries: TLS that the egress gateway forwards without decrypting it, matched on the SNI server name, for a database or message broker that speaks TLS from its first byte. Same host rules as an HTTP(S) origin, and a port is required. The schema and the render refuse an entry without a port, with a path or on an IP address, naming it. Needs the kagent line from 1.21.0, whose Agent accepts `tls://` in `spec.egress` (giantswarm/kagent-upstream#740); an older kagent refuses the Agent (giantswarm/agent#58). - `agent.egress` (empty by default): HTTP(S) origins the agent may reach besides what its revision compiles, such as `https://github.com:443` or `https://*.githubusercontent.com` (one wildcard label, over at least two labels), rendered into the Agent's `spec.egress` (kagent-dev/kagent#3019, which the kagent line must carry; a kagent without the field prunes it). At most 64 unique origins; the chart refuses anything that is not an origin, naming the entry. diff --git a/README.md b/README.md index 6c6f3fb..5267c40 100644 --- a/README.md +++ b/README.md @@ -261,6 +261,32 @@ agent: from the platform's per-Harness list, which agent-manager writes into `agent.egress`; another origin is refused there. +**Picking an EgressPolicy.** A tenant's admins can bundle origins, and the +credential header the gateway adds to them, into an `EgressPolicy` in the +namespace (`kubectl -n get egresspolicies.api.kagent.dev`). An +agent picks one by name in `agent.egressPolicyRefs`, beside its own +`agent.egress`; the chart renders the names into the Agent's +`spec.egressPolicyRefs` and copies none of the policy's rules: + +```yaml +agent: + egressPolicyRefs: + - github + - go-modules + egress: + - https://orders.example.com # typed origins still work next to them +``` + +- At most 16 names, each a resource name, none twice; the schema refuses + anything else, naming the entry. +- The policy is read where it lives: an origin added to it reaches every agent + that picks it from that agent's next Session, with no upgrade of the agent's + release. +- A name with no EgressPolicy in the namespace leaves the Agent reporting it in + its status (`EgressPolicyNotFound`); its typed origins keep working. +- An agent on a coding Harness reaches only its Harness's platform list: + agent-manager refuses a ref there. + **What a denial looks like.** The platform answers a refused request, so it reads like an outage, not a policy: diff --git a/helm/agent/README.md b/helm/agent/README.md index e3f021f..ac4ae54 100644 --- a/helm/agent/README.md +++ b/helm/agent/README.md @@ -14,7 +14,7 @@ What an agent can reach and how to add a host (`agent.egress`): [What an agent c | Key | Type | Default | Description | |-----|------|---------|-------------| -| agent | object | `{"description":"","displayName":"","egress":[],"harness":"kagent","iconUrl":"","name":"","systemMessage":"You are a helpful agent.\n"}` | Identity and prompt of the agent. | +| agent | object | `{"description":"","displayName":"","egress":[],"egressPolicyRefs":[],"harness":"kagent","iconUrl":"","name":"","systemMessage":"You are a helpful agent.\n"}` | Identity and prompt of the agent. | | agent.name | string | `""` | Technical resource name (DNS-1123) of the Agent and of its RemoteMCPServer. Defaults to the Helm release name. | | agent.displayName | string | `""` | Human-friendly name, Unicode allowed. Rendered as the ui.giantswarm.io/display-name annotation on the Agent. Size-limited so it cannot become a description. | | agent.description | string | `""` | Rendered into the Agent's spec.template.description. It shares the compiled agent config's size budget with the system prompt (see systemMessage), so keep it to a few sentences. | @@ -22,6 +22,7 @@ What an agent can reach and how to add a host (`agent.egress`): [What an agent c | agent.systemMessage | string | `"You are a helpful agent.\n"` | The agent's system prompt. Rendered into the Agent's spec.template.systemPrompt. At most 20000 characters; move long reference material into a skill. A prompt heavy in `<`, `>` or `&` can still exceed the runtime limit under this cap, and the Agent then reports why. | | agent.harness | string | `"kagent"` | Name of the platform Harness that runs the agent, in the agent's namespace. Rendered into the Agent's spec.harnessRef.name; the Agent selects its Harness, no label and no Harness-side selector is involved. The platform ships the `kagent` Harness (the Go ADK runtime); an Agent whose Harness does not exist reports `ResolvedRefs=False` and never becomes Ready. | | agent.egress | list | `[]` | Origins the agent may reach besides the destinations its revision compiles (the model, its MCP servers, its skill and plugin sources, telemetry), such as `https://github.com:443`, `https://proxy.golang.org` or `tls://db.example.com:5432`. Rendered into the Agent's spec.egress. An origin is `http(s)://[:port]` with no path, or `tls://:` with a required port: TLS that the egress gateway forwards without decrypting it, matched on the SNI server name (a database or message broker that speaks TLS from the first byte, not STARTTLS). The host may have `*` as its leftmost label (`https://*.githubusercontent.com` matches one label, such as raw.githubusercontent.com) and a wildcard needs two labels under it, so nothing opens a whole top-level domain or every host. At most 64 origins. The chart refuses anything else, naming the entry. | +| 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 leaves the Agent reporting it in its status. | | 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. | | 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. | diff --git a/helm/agent/templates/agent.yaml b/helm/agent/templates/agent.yaml index 5413698..4ba7098 100644 --- a/helm/agent/templates/agent.yaml +++ b/helm/agent/templates/agent.yaml @@ -23,5 +23,11 @@ spec: egress: {{- toYaml . | nindent 4 }} {{- end }} + {{- with .Values.agent.egressPolicyRefs }} + egressPolicyRefs: + {{- range . }} + - name: {{ . | quote }} + {{- end }} + {{- end }} template: {{- include "agent.spec" . | nindent 4 }} diff --git a/helm/agent/tests/agent_test.yaml b/helm/agent/tests/agent_test.yaml index 9a6dfba..84baccb 100644 --- a/helm/agent/tests/agent_test.yaml +++ b/helm/agent/tests/agent_test.yaml @@ -1174,3 +1174,64 @@ tests: asserts: - failedTemplate: errorPattern: 'agent[./]egress' + + # egressPolicyRefs: Agent.spec.egressPolicyRefs, the namespace's EgressPolicies by name + - it: renders no spec.egressPolicyRefs by default + asserts: + - notExists: + path: spec.egressPolicyRefs + + - it: renders agent.egressPolicyRefs as spec.egressPolicyRefs names next to spec.egress + set: + agent: + egress: + - https://example.com + egressPolicyRefs: + - github + - go-modules + asserts: + - equal: + path: spec.egressPolicyRefs + value: + - name: github + - name: go-modules + - equal: + path: spec.egress + value: + - https://example.com + + - it: refuses an empty EgressPolicy name through the values schema + set: + agent: + egressPolicyRefs: + - "" + asserts: + - failedTemplate: + errorPattern: 'agent[./]egressPolicyRefs' + + - it: refuses an EgressPolicy name that is not a resource name through the values schema + set: + agent: + egressPolicyRefs: + - GitHub + asserts: + - failedTemplate: + errorPattern: 'agent[./]egressPolicyRefs' + + - it: refuses a repeated EgressPolicy name through the values schema + set: + agent: + egressPolicyRefs: + - github + - github + asserts: + - failedTemplate: + errorPattern: 'agent[./]egressPolicyRefs' + + - it: refuses more than 16 EgressPolicy names through the values schema + set: + agent: + egressPolicyRefs: [p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17] + asserts: + - failedTemplate: + errorPattern: 'agent[./]egressPolicyRefs' diff --git a/helm/agent/values.schema.json b/helm/agent/values.schema.json index 5c31e7e..29277d8 100644 --- a/helm/agent/values.schema.json +++ b/helm/agent/values.schema.json @@ -171,6 +171,16 @@ "maxItems": 64, "uniqueItems": true }, + "egressPolicyRefs": { + "type": "array", + "description": "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 leaves the Agent reporting it in its status.", + "items": { + "type": "string", + "pattern": "^[a-z0-9]([-a-z0-9.]*[a-z0-9])?$" + }, + "maxItems": 16, + "uniqueItems": true + }, "harness": { "type": "string", "description": "Name of the platform Harness that runs the agent, in the agent's namespace. Rendered into the Agent's spec.harnessRef.name; the Agent selects its Harness, no label and no Harness-side selector is involved. The platform ships the `kagent` Harness (the Go ADK runtime); an Agent whose Harness does not exist reports `ResolvedRefs=False` and never becomes Ready.", diff --git a/helm/agent/values.yaml b/helm/agent/values.yaml index 457d3a4..ef209c6 100644 --- a/helm/agent/values.yaml +++ b/helm/agent/values.yaml @@ -68,6 +68,15 @@ agent: # host. At most 64 origins. The chart refuses anything else, naming the # entry. egress: [] + # @schema type:array;item:string;itemPattern:^[a-z0-9]([-a-z0-9.]*[a-z0-9])?$;maxItems:16;uniqueItems:true + # -- (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 leaves the Agent reporting it in its status. + egressPolicyRefs: [] # -- Which platform-provisioned ModelConfig the agent uses, referenced by name. # kagent resolves it in the agent's own namespace. The chart never creates or From ba32f8ae534b746193dc0438f0ed4ef9550a3fc1 Mon Sep 17 00:00:00 2001 From: Timo Derstappen Date: Thu, 22 Oct 2026 14:00:17 +0200 Subject: [PATCH 2/2] docs: a missing EgressPolicy blocks the Agent, as the agentlab shows --- README.md | 8 +++++--- helm/agent/README.md | 2 +- helm/agent/values.schema.json | 2 +- helm/agent/values.yaml | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5267c40..76dcb44 100644 --- a/README.md +++ b/README.md @@ -281,9 +281,11 @@ agent: anything else, naming the entry. - The policy is read where it lives: an origin added to it reaches every agent that picks it from that agent's next Session, with no upgrade of the agent's - release. -- A name with no EgressPolicy in the namespace leaves the Agent reporting it in - its status (`EgressPolicyNotFound`); its typed origins keep working. + release. The Agent recompiles on the change and reports `Ready=False` until + its new revision is ready. +- A name with no EgressPolicy in the namespace blocks the whole Agent: + `ResolvedRefs=False` with `resolve EgressPolicy "/": not + found`, and it is not Ready until the policy exists or the ref is removed. - An agent on a coding Harness reaches only its Harness's platform list: agent-manager refuses a ref there. diff --git a/helm/agent/README.md b/helm/agent/README.md index ac4ae54..a08e917 100644 --- a/helm/agent/README.md +++ b/helm/agent/README.md @@ -22,7 +22,7 @@ What an agent can reach and how to add a host (`agent.egress`): [What an agent c | agent.systemMessage | string | `"You are a helpful agent.\n"` | The agent's system prompt. Rendered into the Agent's spec.template.systemPrompt. At most 20000 characters; move long reference material into a skill. A prompt heavy in `<`, `>` or `&` can still exceed the runtime limit under this cap, and the Agent then reports why. | | agent.harness | string | `"kagent"` | Name of the platform Harness that runs the agent, in the agent's namespace. Rendered into the Agent's spec.harnessRef.name; the Agent selects its Harness, no label and no Harness-side selector is involved. The platform ships the `kagent` Harness (the Go ADK runtime); an Agent whose Harness does not exist reports `ResolvedRefs=False` and never becomes Ready. | | agent.egress | list | `[]` | Origins the agent may reach besides the destinations its revision compiles (the model, its MCP servers, its skill and plugin sources, telemetry), such as `https://github.com:443`, `https://proxy.golang.org` or `tls://db.example.com:5432`. Rendered into the Agent's spec.egress. An origin is `http(s)://[:port]` with no path, or `tls://:` with a required port: TLS that the egress gateway forwards without decrypting it, matched on the SNI server name (a database or message broker that speaks TLS from the first byte, not STARTTLS). The host may have `*` as its leftmost label (`https://*.githubusercontent.com` matches one label, such as raw.githubusercontent.com) and a wildcard needs two labels under it, so nothing opens a whole top-level domain or every host. At most 64 origins. The chart refuses anything else, naming the entry. | -| 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 leaves the Agent reporting it in its status. | +| 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). | | 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. | | 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. | diff --git a/helm/agent/values.schema.json b/helm/agent/values.schema.json index 29277d8..512cad2 100644 --- a/helm/agent/values.schema.json +++ b/helm/agent/values.schema.json @@ -173,7 +173,7 @@ }, "egressPolicyRefs": { "type": "array", - "description": "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 leaves the Agent reporting it in its status.", + "description": "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).", "items": { "type": "string", "pattern": "^[a-z0-9]([-a-z0-9.]*[a-z0-9])?$" diff --git a/helm/agent/values.yaml b/helm/agent/values.yaml index ef209c6..813bdc3 100644 --- a/helm/agent/values.yaml +++ b/helm/agent/values.yaml @@ -75,7 +75,7 @@ agent: # `{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 leaves the Agent reporting it in its status. + # the namespace keeps the Agent from becoming Ready (ResolvedRefs=False). egressPolicyRefs: [] # -- Which platform-provisioned ModelConfig the agent uses, referenced by name.