fix(agent): the pre-API-call /steer drain also stops smearing the persisted tool row
Second site of the same bug class #104444 fixes in apply_pending_steer_to_tool_results: _inject_steer_into_newest_tool_result (the drain that runs when a /steer lands during an API call) mutated the newest role:tool row in place. That row was already flushed append-only, so the replayed history diverged from the live request bytes at the injection point and broke the prompt cache exactly like the post-batch path. Deliver it the same way: a standalone user row inserted right after the newest tool result (not yet persisted, so the next flush writes it to the transcript). Restash when there is no tool row yet, unchanged. Stale comments claiming steer lands "in the newest tool result" and agent/AGENTS.md's alternation rule now describe the real shape.
This commit is contained in:
+4
-1
@@ -59,7 +59,10 @@ Adding one: register in that table (no `if name == ...` chain); `tools/todo_tool
|
||||
commands (`agent/skill_commands.py`) inject as a user message; subdirectory `AGENTS.md` hints
|
||||
(`agent/subdirectory_hints.py`) append to the tool result (head+tail truncated past `_MAX_HINT_CHARS = 32_000`, with a warning).
|
||||
- **Strict role alternation.** Never two same-role messages in a row; never a synthetic user
|
||||
message injected mid-loop. Cron deliveries live in their own session for this reason.
|
||||
message injected mid-loop. The one exception is `/steer`, delivered as a standalone user row
|
||||
after a tool result (`assistant(tool_calls) → tool → user` is legal on every provider path) —
|
||||
never smeared onto the already-persisted tool row, which append-only persistence would leave
|
||||
divergent from the live request. Cron deliveries live in their own session for this reason.
|
||||
- **Context files** (`agent/prompt_builder.py`) load from the CWD only at startup and are capped
|
||||
(`CONTEXT_FILE_MAX_CHARS` / dynamic cap from the context window / `context_file_max_chars`).
|
||||
Never load an install-tree `AGENTS.md` as project context (PR #64611); subdirectory hints reject
|
||||
|
||||
Reference in New Issue
Block a user