Skip to content

fix(server): keep subagent prompt hints for each own server and steady own_restart_note - #314

Merged
opficdev merged 3 commits into
mainfrom
fix/restart-note-subagent-prompt
Dec 6, 2026
Merged

opficdev merged 3 commits into
mainfrom
fix/restart-note-subagent-prompt

Conversation

@opficdev

@opficdev opficdev commented Dec 6, 2026

Copy link
Copy Markdown
Member

own_restart_note::differential failed once on #313's CI (harness shard 8, continuation on): on t-awaited, a subagent turn item stored its prompt in full in upstream but by reference (prompt: "" plus promptSequence) in own mode. Looping the case under load turned up a second flake in the same harness. Both are fixed here.

Prompt hints were process-wide in own mode

Upstream keeps promptHints (the sequence of the last event that stored each subagent's prompt in full) in its event store, so a server starts with an empty map. Own mode kept one static map for the process. own_restart_note runs two own servers in one test process, one per case. The second server took the first one's sequences as its own, and when one of them happened to land on a row with the same prompt in its own database, it stored the prompt by reference where upstream, a fresh process, stored it in full.

The hints are now kept for each database file and start empty when own mode opens its database (turns::write::forget_prompt_hints), as upstream's event store does. A unit test covers a copied database and a reopened one.

Two replies a turn made the fake ACP agent's turns depend on the server's speed

With two assistant replies, the ACP adapter closes the first when the second starts, and the turn's end writes it again as an answer (markClosingAssistantSegments), stamped with the time it is read. When a busy server read the second reply and the turn's end in one millisecond, that write changed nothing and its node.updated was skipped. Under load, upstream skipped it while own mode's bridge did not, and every later event of the thread shifted by one (111 differences). Both servers run the same adapter, so this was the harness's race: fake-claude-agent-acp.mjs now sends one reply a turn.

docs/ci.md notes both rules under Harnesses.

Verification

  • own_restart_note::differential passed 30 times in a row locally, three at a time (Node 26.13.1, scratch HOME, TERN_KEYCHAIN=off). Before the agent change, it failed 1 run in 15 under load. own_subagents and own_composer_context, which use the same agent, pass.
  • cargo fmt --all, cargo clippy --workspace --all-targets --locked -- -D warnings, cargo test --workspace --locked.

🤖 Generated with Claude Code

opficdev and others added 3 commits December 6, 2026 10:16
Own mode kept upstream's promptHints in one map for the process, so a
server opened after another in the same process took the first one's
event sequences as its own. own_restart_note runs two own servers in one
test process, and the second stored a subagent's prompt by reference
whenever a sequence from the first database landed on a row with the same
prompt, where upstream, a fresh process, stored it in full.

Keep the hints for each database file and start them empty when own mode
opens its database, as upstream's event store does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With two replies, the ACP adapter closes the first when the second
starts and writes it again as an answer at the turn's end. When a busy
server read the second reply and the turn's end in one millisecond, the
second write changed nothing and its node.updated was skipped, so the
turn's events depended on the server's speed. Under load, upstream
skipped it in own_restart_note while own mode's bridge did not.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@opficdev
opficdev enabled auto-merge (squash) December 6, 2026 01:41
@opficdev
opficdev merged commit cca77cd into main Dec 6, 2026
20 checks passed
@opficdev
opficdev deleted the fix/restart-note-subagent-prompt branch December 6, 2026 01:44
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