Skip to content

fix(api-rs): deliver overlay.systemPrompt to sandboxes#532

Open
cjustice wants to merge 3 commits into
paradigmxyz:mainfrom
cjustice:fix/deliver-overlay-system-prompt
Open

fix(api-rs): deliver overlay.systemPrompt to sandboxes#532
cjustice wants to merge 3 commits into
paradigmxyz:mainfrom
cjustice:fix/deliver-overlay-system-prompt

Conversation

@cjustice

@cjustice cjustice commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Problem

overlay.systemPrompt is a no-op on the Rust control plane. The chart renders it into a ConfigMap (overlay-configmap.yaml) and sets CENTAUR_OVERLAY_DIR + a checksum/overlay annotation on api-rs — but the ConfigMap is mounted nowhere (api-rs's only volume is repo-cache) and api-rs never consumes it (no overlay reader anywhere in services/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.md is the base prompt only, CENTAUR_OVERLAY_DIR is unset, there is no ~/AGENTS_OVERLAY.md, and /app/overlay/org doesn't exist in the api-rs pod — though the …-overlay ConfigMap holds the prompt.

Fix

The legacy Python control plane delivered the prompt via a ConfigMap subPath mount (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.md contract (entrypoint.sh already appends that file to the effective AGENTS.md — no entrypoint change):

  • centaur-sandbox-core: add MountKind::ConfigMap { name } + optional Mount::sub_path (project a single ConfigMap key as one file).
  • centaur-sandbox-agent-k8s: render the configMap volume (optional: true) + 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 (apirs.yaml): pass the overlay ConfigMap name to api-rs when overlay.systemPrompt is set.

The volume is optional: true, so a missing/misnamed ConfigMap degrades gracefully (the entrypoint already guards ~/AGENTS_OVERLAY.md with [ -f ]) rather than wedging the pod.

Scope

Delivers the overlay system prompt only. The [Active deployment] block + persona injection that the Python prompt_assembly also 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 renders KUBERNETES_OVERLAY_CONFIGMAP.

cjustice added 2 commits June 12, 2026 21:49
`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.
@cjustice cjustice force-pushed the fix/deliver-overlay-system-prompt branch from 36e5a14 to b872b7e Compare June 13, 2026 01:49
@cjustice

Copy link
Copy Markdown
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 main. Thanks!

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant