fix(api-rs): deliver overlay.systemPrompt to sandboxes#532
Open
cjustice wants to merge 3 commits into
Open
Conversation
`overlay.systemPrompt` is rendered into a ConfigMap (templates/overlay-
configmap.yaml) and `CENTAUR_OVERLAY_DIR` is set on the api-rs container with a
`checksum/overlay` rollout annotation — but the ConfigMap is mounted nowhere
(api-rs has only the repo-cache volume) and api-rs never reads it. So the org
overlay never reaches the sandbox: the agent runs on the bare baked base prompt,
ignoring the operator's overlay (and any "read the repo's own AGENTS.md"
guidance it carries).
The legacy Python control plane injected the assembled prompt into the sandbox
via a ConfigMap `subPath` mount (services/api/api/sandbox/{prompt_assembly,
kubernetes}.py: `mountPath: /home/agent/AGENTS_BASE.md, subPath: ...`). The Rust
control plane never ported any overlay delivery.
Wire it through, minimally, reusing the sandbox entrypoint's existing
`~/AGENTS_OVERLAY.md` contract (entrypoint.sh already appends that file to the
effective AGENTS.md):
- centaur-sandbox-core: add `MountKind::ConfigMap { name }` and an optional
`Mount::sub_path` so a single ConfigMap key can be projected as one file.
- centaur-sandbox-agent-k8s: render the ConfigMap volume + `volumeMount.subPath`.
- centaur-api-server: add `--overlay-configmap` / `KUBERNETES_OVERLAY_CONFIGMAP`;
when set, the codex sandbox mounts that ConfigMap's `SYSTEM_PROMPT.md` at
`~/AGENTS_OVERLAY.md` (read-only).
- chart: pass the overlay ConfigMap name to api-rs when `overlay.systemPrompt`
is set.
No entrypoint change. Scope: this delivers the overlay *system prompt*; the
`[Active deployment]` block + persona prompt injection that the Python
`prompt_assembly` also produced are a related, separate gap left for follow-up.
Verification:
- cargo test -p centaur-sandbox-core -p centaur-sandbox-agent-k8s -p centaur-api-server
(incl. new: mount_json_renders_configmap_subpath,
codex_workload_mounts_overlay_configmap_as_agents_overlay,
codex_workload_has_no_overlay_mount_when_unset)
- helm lint contrib/chart -f values.dev.yaml
- helm template contrib/chart -f values.dev.yaml
…-trip Review follow-ups: - Render the overlay ConfigMap volume with `optional: true` so a missing or misnamed ConfigMap degrades gracefully (the sandbox entrypoint already treats ~/AGENTS_OVERLAY.md as optional via a `[ -f ]` guard) instead of wedging the pod in ContainerCreating. - Add agent_sandbox_crd_round_trips_configmap_overlay_mount: build the full Sandbox CRD and assert the configMap volume (optional) + the subPath volumeMount survive deserialization into the typed agents.x-k8s.io CRD — the isolated mount_json test wouldn't catch a future CRD regen dropping configMap support.
36e5a14 to
b872b7e
Compare
Contributor
Author
|
@Zygimantass — would you be able to review when you have a moment? It touches the api-rs overlay delivery you've worked on (#443), and it's rebased on latest |
Green up CI on this PR: apply rustfmt to the new MountKind::ConfigMap / overlay volume code, and bump contrib/chart to 0.1.56 (the "Validate chart version bump" check requires a version bump for any contrib/chart change). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
overlay.systemPromptis a no-op on the Rust control plane. The chart renders it into a ConfigMap (overlay-configmap.yaml) and setsCENTAUR_OVERLAY_DIR+ achecksum/overlayannotation on api-rs — but the ConfigMap is mounted nowhere (api-rs's only volume isrepo-cache) and api-rs never consumes it (no overlay reader anywhere inservices/api-rs). So the org overlay never reaches the sandbox: the agent runs on the bare baked base prompt and silently ignores the operator's overlay.Confirmed live: in the sandbox,
~/workspace/AGENTS.mdis the base prompt only,CENTAUR_OVERLAY_DIRis unset, there is no~/AGENTS_OVERLAY.md, and/app/overlay/orgdoesn't exist in the api-rs pod — though the…-overlayConfigMap holds the prompt.Fix
The legacy Python control plane delivered the prompt via a ConfigMap
subPathmount (services/api/api/sandbox/{prompt_assembly,kubernetes}.py); the Rust rewrite never ported it. This wires it through minimally, reusing the sandbox entrypoint's existing~/AGENTS_OVERLAY.mdcontract (entrypoint.shalready appends that file to the effectiveAGENTS.md— no entrypoint change):MountKind::ConfigMap { name }+ optionalMount::sub_path(project a single ConfigMap key as one file).configMapvolume (optional: true) +volumeMount.subPath.--overlay-configmap/KUBERNETES_OVERLAY_CONFIGMAP; when set, the codex sandbox mounts that ConfigMap'sSYSTEM_PROMPT.mdat~/AGENTS_OVERLAY.md, read-only.apirs.yaml): pass the overlay ConfigMap name to api-rs whenoverlay.systemPromptis set.The volume is
optional: true, so a missing/misnamed ConfigMap degrades gracefully (the entrypoint already guards~/AGENTS_OVERLAY.mdwith[ -f ]) rather than wedging the pod.Scope
Delivers the overlay system prompt only. The
[Active deployment]block + persona injection that the Pythonprompt_assemblyalso produced are a related, separate gap left for follow-up — happy to adjust shape if you'd prefer it unified.Verification
cargo test -p centaur-sandbox-core -p centaur-sandbox-agent-k8s -p centaur-api-server— green, incl. new tests:mount_json_renders_configmap_subpath,agent_sandbox_crd_round_trips_configmap_overlay_mount,codex_workload_mounts_overlay_configmap_as_agents_overlay,codex_workload_has_no_overlay_mount_when_unset.helm lint+helm template contrib/chart -f values.dev.yaml— pass; api-rs rendersKUBERNETES_OVERLAY_CONFIGMAP.