Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

Let switch-core send a key to a decision service run elsewhere

agent-runner3530a34ca65c534
diff --git a/deploy/remote/helm/switch/README.md b/deploy/remote/helm/switch/README.md
index c00ea38c2..d771c2c2b 100644
--- a/deploy/remote/helm/switch/README.md
+++ b/deploy/remote/helm/switch/README.md
@@ -377,7 +377,11 @@ no further setup.
To use a decision service run elsewhere instead, leave `decision.enabled` off
and set `switchCore.decision.endpointUrl` (and `bedrockEnabled` if that service
-allows Bedrock). Setting both is refused at render time. With neither,
+allows Bedrock). If that service requires a token, put it in a Secret and
+name it in `switchCore.decision.apiKey.existingSecret` (key
+`existingSecretKey`, default `token`); switch-core sends it as
+`DECISION_API_KEY`. Setting both `decision.enabled` and an endpoint is refused
+at render time. With neither,
auto-route is unavailable until a workspace admin sets up a backend in Switch
Console. `switchCore.decision.timeoutSeconds` sets `DECISION_TIMEOUT_SECONDS`.
diff --git a/deploy/remote/helm/switch/templates/_helpers.tpl b/deploy/remote/helm/switch/templates/_helpers.tpl
index 05fafb21d..6e5dcd80e 100644
--- a/deploy/remote/helm/switch/templates/_helpers.tpl
+++ b/deploy/remote/helm/switch/templates/_helpers.tpl
@@ -922,7 +922,19 @@ this one. Drop it once the oldest supported image reads ID_SERVER_NAME. */}}
value: {{ . | quote }}
{{- end }}
{{- if .Values.decision.enabled }}
+{{- if .Values.switchCore.decision.apiKey.existingSecret }}
+{{- fail "switchCore.decision.apiKey.existingSecret is the key for a decision service run elsewhere (switchCore.decision.endpointUrl); with decision.enabled the chart sends its own token. Clear it, or use decision.token.existingSecret." }}
+{{- end }}
{{ include "switch.decisionTokenEnv" (dict "root" . "name" "DECISION_API_KEY") }}
+{{- else if .Values.switchCore.decision.apiKey.existingSecret }}
+{{- if not .Values.switchCore.decision.endpointUrl }}
+{{- fail "switchCore.decision.apiKey.existingSecret is set but switchCore.decision.endpointUrl is not: there is no endpoint to send the key to." }}
+{{- end }}
+- name: DECISION_API_KEY
+ valueFrom:
+ secretKeyRef:
+ name: {{ .Values.switchCore.decision.apiKey.existingSecret }}
+ key: {{ .Values.switchCore.decision.apiKey.existingSecretKey }}
{{- end }}
{{- if include "switch.decisionBedrockEnabled" . }}
- name: DECISION_BEDROCK_ENABLED
diff --git a/deploy/remote/helm/switch/values.yaml b/deploy/remote/helm/switch/values.yaml
index 08ad5867e..359589b05 100644
--- a/deploy/remote/helm/switch/values.yaml
+++ b/deploy/remote/helm/switch/values.yaml
@@ -432,6 +432,13 @@ switchCore:
decision:
# DECISION_ENDPOINT_URL, e.g. http://switch-decision.decision.svc:8230.
endpointUrl: ""
+ # DECISION_API_KEY for that endpoint: the bearer token a decision service
+ # run elsewhere requires (its DECISION_SERVICE_TOKEN), read from an
+ # existing Secret. Only with endpointUrl; with decision.enabled the chart
+ # wires its own token.
+ apiKey:
+ existingSecret: ""
+ existingSecretKey: token
# DECISION_BEDROCK_ENABLED: workspaces may choose Claude Haiku on Amazon
# Bedrock, which runs inside the decision service on its own AWS
# credentials. With decision.enabled, decision.bedrock.enabled sets this.
diff --git a/scripts/check_chart_decision.py b/scripts/check_chart_decision.py
index 7cbf4993f..e70a409c2 100755
--- a/scripts/check_chart_decision.py
+++ b/scripts/check_chart_decision.py
@@ -353,6 +353,32 @@ def test_an_endpoint_elsewhere() -> None:
assert "DECISION_API_KEY" not in env
+def test_an_endpoint_elsewhere_with_a_key() -> None:
+ docs = render(
+ "--set",
+ "switchCore.decision.endpointUrl=http://decider.example:8230",
+ "--set",
+ "switchCore.decision.apiKey.existingSecret=decider-token",
+ )
+ assert decision_objects(docs) == {}
+ env = core_env(docs)
+ assert env["DECISION_ENDPOINT_URL"] == "http://decider.example:8230"
+ assert env["DECISION_API_KEY"] == {
+ "secretKeyRef": {"name": "decider-token", "key": "token"}
+ }
+ error = render_error(
+ "--set", "switchCore.decision.apiKey.existingSecret=decider-token"
+ )
+ assert "no endpoint to send the key to" in error
+ error = render_error(
+ "--set",
+ "decision.enabled=true",
+ "--set",
+ "switchCore.decision.apiKey.existingSecret=decider-token",
+ )
+ assert "decision.token.existingSecret" in error
+
+
def test_the_service_requires_a_token_that_switch_core_sends() -> None:
docs = render("--set", "decision.enabled=true", *FLAGS)
objects = decision_objects(docs)
@@ -584,6 +610,7 @@ TESTS: list[Callable[[], None]] = [
test_without_a_model_server_there_is_no_gpu_or_volume,
test_network_policy_can_be_left_out,
test_an_endpoint_elsewhere,
+ test_an_endpoint_elsewhere_with_a_key,
test_the_service_requires_a_token_that_switch_core_sends,
test_an_existing_token_secret_replaces_the_generated_one,
test_the_model_server_requires_the_token_too,