Repository navigation
mods/interim: count a notice the engine folded into a tool result (7.171.1) - #230
Merged
Merged
Conversation
…171.1) A notification that arrives while a tool call runs is folded by the engine into that call's tool_result, in a system-reminder of its own under its system-notification frame. The conversation check read only user text, so the next repeat of a worktree or orphan notice passed once more (4 of 50 interim notices in MAWS 37052769). holds() now also counts a notice in a tool_result's content, string or text blocks, but only directly under the engine's exact frame, alone in its reminder, at the start of the text or after a blank line, as the API view renders it (confirmed live on 2.1.302). A tool output quoting a notification does not count; every other rule and every fail-open path is unchanged.
…tags Review: the body excluded only the closing tag, so an unfinished quoted frame and task id at the end of a tool's output could borrow the close of the engine's genuine fold after it and count as an earlier notice of the quoted task. The body now excludes openers too, and the genuine fold after such a quote counts as its own task's.
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.
Closes the interim filter's mid-turn gap (TECH-DEBT: "A first notice that entered mid-turn is not seen").
Problem. A notification that arrives while the main session is inside a tool call is folded by the engine into that call's
tool_result.holds()read only user-message text, so for a worktree or orphan agent the next repeat passed once more. In MAWS37052769(engine 2.1.302, filter live overnight) that let 4 of 50 interim notices through.Change.
holds()also counts a notice inside atool_result's content (a string or text blocks), but only where it sits exactly as the engine folds it: at the start of the text or after a blank line,<system-reminder>\n+ the engine's frame + one<task-notification>+\n</system-reminder>, then the end or a blank line. The frame is the engine'so8e(Iut), the same text from 2.1.283 to 2.1.302:A tool output that only quotes a notification (a file read, a transcript grep) does not count. Every other rule and every fail-open path is unchanged.
Where the shape comes from. The API view is
eA(ni(msgs), tools)with no model, so it builds no mid-conversation system messages. A mid-turn task notification renders asul(Iut(text))and is folded into the running call's result bygKn/hlt, which trims each part and joins them with a blank line. On the wire, 2.1.302 sends the same frame in arole: systemmessage, without the reminder, which is why the transcripts'api-request-blobrows hold no folded notice. A live diag run on 2.1.302 logged the API view'stool_resultaswaited\n\n<system-reminder>\n[SYSTEM NOTIFICATION …]…\n\n<task-notification>…</task-notification>\n</system-reminder>\n\n<system-reminder>….Verification.
tests/mods/run-mods-tests.sh, 436 pass. The new cases: a folded notice counts (string, its own text block, merged into a block, between other reminders, alone). It does not count without the frame, with the frame's first line alone, inside output with no blank line before it, numbered or fenced, with more than the notice in the reminder, with text right after it, or as the second of two notices in one reminder. A different task or worktree does not count either. Against main'sinterim.ts, the two "counts" tests fail and the rest pass.37052769with mid-turn notices folded into the running call's result: main's version reproduces all 50 live decisions (44 drops). This branch adds 4 drops: a319c7d5 at 22:00 and 22:08, and aba89ce3 at 01:04 and 02:11. It loses none. Each is a pure placeholder whose worktree an earlier notice of the same task, folded mid-turn, had already delivered. Both agents' hand-back reports later reached the session (a319c7d5 at 23:58, and it is still running; aba89ce3 at 04:09).Residual (README "gives up"): a tool output that forges the exact fold with a live agent's task id and worktree makes that agent's first worktree (or orphan) notice drop. That costs a placeholder, never a report. If a later engine rewrites the frame, folded notices go unseen again and repeats pass, as before this change.
Version 7.171.1. main is at 7.170.0, and #228 and the unmerged
to-human-pluginbranch both claim 7.171.0, so this sits above both.🤖 Generated with Claude Code