feat(backends): honor replace-vs-append prompt intent, or refuse it loudly - #120
Merged
Conversation
…e it renderLocalHarnessProfilePreamble folded agent_profile.prompt.systemPrompt into a preamble that claude sent through --append-system-prompt and every other local backend flattened into the user turn. systemPrompt means DELETE the harness's own prompt; both paths kept it running. The caller saw a successful turn either way, so a profile written to replace claude-code's 27,673-byte built-in prompt silently ran on top of it instead. Bind each intent to the control that performs it. claude passes plan.systemPrompt to --system-prompt and merges plan.appendSystemPrompt into the single --append-system-prompt block; pi writes each intent to its own file under the request-scoped profile directory and passes --system-prompt / --append-system-prompt, with the profile's addition ordered ahead of the AGENTS.md loader that shares the flag. codex, opencode and gemini receive their intents through the materializer's files and flags. The preamble now carries no prompt text at all — only the skills/MCP/resources/permission summary that was always informational. One --append-system-prompt, never two: claude-code takes the LAST occurrence and discards earlier ones (verified on the wire — two values arrive as only the second), so a second occurrence would silently drop whichever source lost. Everything additive composes into one block, and composeStdinInput mirrors it exactly, since it exists to predict whether that same block fits argv; the profile is provisioned before it runs so both see the same bytes. assertProfilePromptIntentsSupported is the shared refusal. acp, factory and nanoclaw never materialize a plan, so the materializer's fail-closed record never reaches them and an intent would vanish without a word. Unknown backend names refuse both intents, so a backend added later cannot inherit a capability by omission. The per-backend controls are measured, not documented: claude-code 2.1.222 --system-prompt drops the built-in prompt from the request while --append-system-prompt leaves it in place; pi 0.83.0 matches, and its flags inline a file's bytes without sending the path; codex 0.146.0 has a replacement config key and no additive control at all.
…lly passes it assertProfilePromptIntentsSupported was tested only by calling it directly. Deleting its one call site in resolvePromptMessages left all 26 prompt-intent tests green: acp, factory, nanoclaw, hermes and kimi-code each accepted a profile carrying an intent they cannot execute, spawned, and ran the turn with the intent gone — the exact silent downgrade the assertion exists to stop, and the suite could not see it. Drive each backend's own chat path with a profile it must refuse, and assert the BackendError code together with a spawn count of zero, measured by a spawner that throws if it is ever reached. nanoclaw launches nothing of its own, so its equivalent is a listening socket that must receive no connection. codex and opencode carry the two cells their materializer would also catch a layer later; asserting this seam's wording proves the refusal lands before any workspace is touched, which the empty-cwd assertion checks directly. One case runs the other way: codex with a replacement and opencode with an addition pass the seam untouched, so a blanket refusal fails too.
This was referenced Aug 6, 2026
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.
Every backend now either honors the caller's system-prompt intent with a real control, or throws
BackendError[not_configured]before spawning anything. No intent is silently turned into the other one.Measured on the real wire against the installed CLIs (claude 2.1.222 · codex 0.146.0 · gemini 0.26.0 · opencode 1.17.18 · pi 0.83.0):
.gemini/system.mdreplaces wholesaleZero silent downgrades in ten cells.
Also fixed: the guard that does this work had no test coverage — deleting it left 26/26 prompt-intent tests passing. Ten new tests drive each backend's own
chat()with an intent it cannot execute and assert the error kind, the message, and zero spawns (a spawner that throws if reached; a real unix socket for the backend that spawns nothing). Deleting the guard now fails 9 of 10. One negative control ensures a blanket refusal fails too.Suite 668 → 678 passing, typecheck clean.