-
Notifications
You must be signed in to change notification settings - Fork 12
Sequence tools after same-message patches; report tool failures to the room #5767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jurgenwerk
wants to merge
7
commits into
main
Choose a base branch
from
cs-12515-tool-requests-that-race-their-own-messages-code-patches-hang
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6b68048
Sequence tools after same-message patches; report tool failures to th…
jurgenwerk 1354baa
Type the store.patch spy against the bound original
jurgenwerk 9b389e7
Catch per-tool drain failures and report them to the room
jurgenwerk 6172636
Wait for patched files' index invalidations before running same-messa…
jurgenwerk c82e465
Merge remote-tracking branch 'origin/main' into cs-12515-tool-request…
jurgenwerk 4a9c795
Harden failed-tool handling around retries, reloads, and index waits
jurgenwerk 5186389
Keep the tool drain unblocked and the failed status truthful
jurgenwerk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Claude Code 🤖] Confirmation — the ordering this scan depends on holds under both states the array can be in, which is not obvious from here.
Room.addEvent(packages/host/app/lib/matrix-classes/room.ts) appends to_eventsin arrival order and replaces edits in place, so within a room afailedresult precedes itsappliedretry positionally. Separately,RoomResource.sortedEventscalls.sort((a, b) => a.origin_server_ts - b.origin_server_ts)on that same array —Array.prototype.sortmutates in place, so once anything has readsortedEventsthe array is also timestamp-ascending. Both orders put the newest matching result last, so walking backwards picks the right one either way. Also good that the loop now usese.content?.[...]— the old.finddereferencede.contentunguarded on every event in the room.Two notes for whoever edits this next:
This is the rebuild path, not the live one. When a result event arrives live,
updateMessageCommandResulttakes thebuilderContext.toolResultEventfast path above and assignstoolCallStatusunconditionally, so the last event to arrive wins there. That agrees with this scan only because both now mean "latest wins" — if either side ever flips back to first-wins, the live view and the post-reload view of a retried tool diverge with nothing failing.Which makes the pair worth pinning. The new
packages/ai-bot/tests/prompt-construction-test.tscase covers the ai-bot half of latest-wins; the host half has no equivalent. A rendering or unit test that builds a message from a history containingfailedthenappliedfor one request and assertsmessageTool.status === 'applied'(and no stalefailureReason) would cover the reload path this scan owns.Scope. Confirmation + suggested test. Non-blocking.
Generated by Claude Code