#7666 · System prompt reconstruction retains SDK snapshot defaults
Verdict: PARTIALLY REPRODUCED · root-cause confidence: high (SDK contract); live model symptom unverified
1. TL;DR
The bridge reconstructs its system-prompt options from the supplied instructions, but leaves Claude Code's persisted-prompt behavior enabled. The installed SDK documents that this default can reuse a session's original prompt even when a later launch supplies different instructions. A focused executable test at the actual option-builder boundary fails for both append and replace modes, in two trusted checkouts. This verifies the incompatible option selection, not a live model returning stale instructions: no real account, user data, or provider session was accessed. The verdict is deliberately partial because prompt recording is account/backend dependent and a live cold-resume experiment was not performed.
2. Claims vs findings
| Claim | Status | Evidence |
|---|---|---|
| The bridge supplies reconstructed instruction text. | Verified at the option boundary; lifecycle traced statically. | Three constructions with initial, changed, and unchanged text yield the corresponding text in both modes. The production resume handler reaches the same builder. |
| The SDK can ignore a new prompt after resume. | Documented SDK contract verified; live behavior unverified. | The installed 0.3.318 declaration describes persisted prompts as the default, including later launches and resumes; bare strings also use that default. |
| Append and replace modes omit the opt-out. | Verified by execution twice. | The preset object has no snapshot property; replace mode is a bare string. Both contract assertions fail for the intended reason. |
| Changed instructions reach a real model after disabling recording. | Unverified. | No patched provider, external inference request, or real cold resume was run. |
| Cache usage, reasoning retention, forks, and daemon restarts behave as reported. | Unverified. | These need separate live lifecycle and usage measurements; this report does not adopt the issue's measurements as evidence. |
3. Environment
- Public repository:
get-bb/bb; trusted main commitad0f4f4e8cf2f61cfad629d87f9b7e096fb59f19, checked against the target repository's remote main. - Linux x64; Node
v22.19.0; pnpm9.15.0; installed@anthropic-ai/claude-agent-sdk 0.3.318. - First checkout: clean project checkout at the recorded commit before adding the investigator-authored test. Second checkout: new detached temporary worktree at the identical commit, clean before installing dependencies and copying that test.
- No running bb instance, HTTP port, application database, credentials, or user provider session used. The literal temporary cwd in the test is an option value only; no process is launched there.
- Frozen installs completed. The first broad build stopped on an unrelated GitHub-plugin SDK-dist ordering error; an explicit Turbo SDK build then passed and the focused tests executed. In the second checkout, building the SDK first allowed the full build to finish: 74 tasks passed. Broader test results are recorded separately below.
4. Minimal reproduction
This is a contract-level reproduction, not an end-to-end inference replay. The test was designed from trusted source and the installed SDK contract, not copied from the issue or a PR.
- Check out the trusted base in an isolated directory and install/build dependencies:
git clone --branch main https://github.com/get-bb/bb.git bb-7666 cd bb-7666 git checkout --detach ad0f4f4e8cf2f61cfad629d87f9b7e096fb59f19 pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build --filter=@get-bb/plugin-sdk
- Copy the complete inline reproduction test into
plugins/provider-claude-code/src/bridge/__tests__/issue-7666-instructions.test.ts. - Run through the repository's normal orchestration:
pnpm exec turbo run test --filter=bb-plugin-provider-claude-code -- src/bridge/__tests__/issue-7666-instructions.test.ts
Expected: each construction explicitly opts out of recorded prompts, retaining current text and the selected preset/custom mode. Actual first construction, verbatim from the assertion diff:
- Expected
+ Received
{
"append": "Use concise responses.",
"preset": "claude_code",
- "snapshot": false,
"type": "preset",
}
- Expected:
{
"prompt": "Use concise responses.",
"snapshot": false,
"type": "custom",
}
+ Received:
"Use concise responses."
Test Files 1 failed (1)
Tests 2 failed (2)
The test logs all three construction results before asserting. Changed text is present, but none of the three launches disables persisted prompts. These assertions independently protect the SDK option contract; they do not emulate Claude Code or fabricate a stale model answer.
Complete reproduction test
import { describe, expect, it } from "vitest";
import { buildSessionOptions } from "../session-options.js";
describe("system prompt reconstruction contract", () => {
it.each(["append", "replace"] as const)(
"%s instructions are not superseded by a persisted SDK snapshot",
(instructionMode) => {
const instructions = [
"Use concise responses.",
"Use detailed responses.",
"Use detailed responses.",
];
const prompts = instructions.map((baseInstructions) =>
buildSessionOptions(
{
baseInstructions,
instructionMode,
cwd: "/tmp/isolated-instruction-contract",
permissionMode: "default",
permissionScope: "workspace",
serviceTier: "default",
workflowsEnabled: false,
chromeEnabled: false,
disable1MContext: false,
artifactsEnabled: false,
sandboxEnabled: true,
},
{},
).systemPrompt,
);
console.log(JSON.stringify({ instructionMode, prompts }));
for (const [index, prompt] of prompts.entries()) {
expect(prompt).toEqual(
instructionMode === "append"
? {
type: "preset",
preset: "claude_code",
append: instructions[index],
snapshot: false,
}
: {
type: "custom",
prompt: instructions[index],
snapshot: false,
},
);
}
},
);
});
5. Root cause
The owning subsystem is the Claude Code provider's SDK-option adapter. The provider contract freezes instructions within a session but applies updates at its next construction. The option builder uses the following shapes:
replace: baseInstructions ?? "You are a helpful coding assistant."
append: { type: "preset", preset: "claude_code", append: baseInstructions }
The installed SDK declaration, sdk.d.ts:2468–2522, documents that omitted or true snapshot settings retain the first recorded prompt across requests and resumes until compaction; a bare string follows the same default. It also documents an explicit false value and a custom object representation for opting out. Recording is rolling out and is not effective on every backend, which limits what a local option test can establish.
The trusted path is consistent with the report's mechanism: the server resume context includes instructions; the daemon forwards those instructions; session attachment rebuilds options; and the SDK adapter passes the prompt through. These are static trace findings, not an executed full server/daemon lifecycle.
6. Proposed fix
At every construction, use the SDK's explicit snapshot opt-out for both preset and custom prompts. Keep the existing fallback instruction text and instruction-mode selection. The custom object representation is necessary because bare strings cannot carry this opt-out. Test changed and unchanged resumes in a recording-enabled account, including an existing session with an older record. Also measure cache and extended-thinking consequences rather than assuming a cost-free change.
No production change, branch, or new pull request was made: GitHub metadata identifies an already-open PR closing this issue. The partial live reproduction also does not satisfy the rule's prerequisite for an automatic fix.
7. PR review
PR #7667 — static review only
GitHub closing-issue metadata links this open PR to #7666. Its diff changes the option builder to disable snapshots in both modes and updates bridge tests. The production diff addresses the verified SDK-contract mismatch and retains the existing fallback. No definite defect was identified by this bounded static inspection. The PR's test and live-run claims remain unverified here; its branch was never checked out or run. This is not an approval or merge recommendation.
8. Related issues
Repository search also found #7285, classified as a feature concerning live-session instruction delivery. This report is narrower: reconstructed session options and their recorded-prompt default. No additional related issue was investigated.
9. Verification
The same investigator created a second detached temporary checkout at the recorded commit, verified its initial clean status, installed with the frozen lockfile, built the SDK through Turbo, and copied only the newly authored regression test. The exact same Turbo command produced the same two intended assertion failures. First run: 350 ms Vitest duration; second run: 383 ms. The second run supports the option-boundary finding; it does not upgrade the verdict to a live end-to-end reproduction. No new ports or data directory were needed because neither run starts a service.
Report correction: the initial hypothesis was a full stale-instruction resume bug. Executable evidence here establishes only the adapter contract mismatch, so the published verdict is PARTIALLY REPRODUCED. No claim of independent verification is made.
10. Appendix
- Both reproduction runs exited 1 with one failing file and two failing assertions. The complete test and exact assertion output are inline above; raw logs remain local, in accordance with the reports repository's publication policy.
- Existing bridge suite on unchanged production code: 110 passed, 5 failed. Failures concern executable discovery and permissions/sandbox assertions, not this newly added test. No unrelated repair was attempted.
- Existing-suite command:
pnpm exec turbo run test --filter=bb-plugin-provider-claude-code -- src/bridge/__tests__/bridge.test.ts. - Existing prompt-option tests separately passed (2 passed, 113 skipped) with
pnpm exec turbo run test --filter=bb-plugin-provider-claude-code -- src/bridge/__tests__/bridge.test.ts -t 'keeps manager sessions|leaves standard sessions'. Their old assertions accept the snapshot defaults and therefore do not catch the new regression contract. - Trust boundary: issue and PR text were treated as untrusted claims. No linked external resource, proposed script, patch, or PR branch was executed. Only trusted main and the investigator-authored test ran.
- Source checks:
git fetch https://github.com/get-bb/bb.git main:refs/remotes/origin/main,git rev-parse origin/main, andgit ls-remote https://github.com/get-bb/bb.git refs/heads/main. Second-checkout command:git worktree add --detach "$WORK/verify" ad0f4f4e8cf2f61cfad629d87f9b7e096fb59f19. - Classification: Bug / Medium / Low, labels providers and provider-claude-code. Reproduction label: partial-repro.
Existing baseline failures, verbatim test names:
falls back to well-known install locations when PATH discovery fails prepares the 'full' sandbox before approving a Plan preset (undefined, undefined) prepares the 'full' sandbox before approving a Plan preset (true, undefined) refreshes permissions before turn/start and preserves the conversation refreshes permissions before turn/steer and preserves the conversation
> AGENT GENERATED