fix(agent-runner): bound hasIdenticalSend to the turn in flight#3014
Open
vishnujayvel wants to merge 1 commit into
Open
fix(agent-runner): bound hasIdenticalSend to the turn in flight#3014vishnujayvel wants to merge 1 commit into
vishnujayvel wants to merge 1 commit into
Conversation
hasIdenticalSend had no seq/time bound, so it scanned all of messages_out history. A recurring task's fixed-text reminder delivers on its first fire, then every later fire's turn-final <message> block matches yesterday's identical row and gets silently dropped as a stale-history "already sent" echo — zero delivery from the second fire onward. Add a seq floor (getMaxSeq(), captured once at the top of each processQuery turn) so the lookup only considers rows written during the current turn. The original nanocoai#2981 guard (dropping the echo of an MCP send_message made earlier in the same turn) still works, since that row lands above the floor. Closes nanocoai#2997
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.
Type of Change
.claude/skills/<name>/, no source changes)Description
What:
hasIdenticalSend(container/agent-runner/src/db/messages-out.ts) had no seq/time bound, so it scanned all ofmessages_outhistory. A recurring task with fixed reminder text delivers on its first fire, then every later fire's turn-final<message>block matches the previous fire's identical row and gets silently dropped as a stale-history "already sent" echo — zero delivery from the second fire onward.Why: Task-fire sends are written with
in_reply_tonull by design, so yesterday's fire writes exactly the row that today's lookup matches. On a hit,sendToDestinationreturns before writing — no error, no log surfacing to the host (the only trace is aDropping turn-final echoline in the container log, gone once the container exits with--rm).How it works: Adds
getMaxSeq()(extracted from the existingwriteMessageOutlogic) and threads asinceSeqfloor — captured once at the top of eachprocessQueryturn — throughdispatchResultText→sendToDestination→hasIdenticalSend. The lookup now only matches rows written during the current turn, so a recurring reminder never collides with its own previous fire. The original #2981 guard (dropping the echo of an MCPsend_messagemade earlier in the same turn) still works, since that row lands above the floor.Note: the issue's suggested fix pointed at reusing
getToolSentTextsSince(floorSeq)/toolSentFloorSeqas an existing primitive for this — that function does not actually exist in the codebase (verified viagrep -rn "getToolSentTextsSince\|toolSentFloorSeq"). The floor here (getMaxSeq()+sinceSeq) is built fresh, following the same shape.How it was tested: See Test plan below — full suite, typecheck, and a revert-confirms-fail check on the new regression test.
Fixes #2997
Credit to @glifocat for the report, root-cause analysis, and a ready-to-run regression test in the issue body.
For Skills
Test plan
Repo:
container/agent-runner(bun workspace).Revert-confirms-fail check (checked out
src/db/messages-out.tsandsrc/poll-loop.tsfrom the parent commit, keeping the new tests inpoll-loop.test.ts):Both new tests fail without the fix (the first reproduces the exact bug: 1 delivered row instead of 2, the reminder silently dropped) and pass with it. Restored the fix afterward and reran the full suite to confirm a clean tree (119 pass, 0 fail).