Fix two tool-retry bugs in the agent execute loop#6
Merged
Conversation
- structured retry leaked stale content: `structuredBlocks` was declared once outside the retry loop and only set on a successful executeStructured, never reset per attempt. If attempt 0 returned structured blocks + a transient error and a later attempt threw (timeout/reset), the call returned the new attempt's error text paired with the PREVIOUS attempt's structured blocks. Reset structuredBlocks at the top of each attempt. - retry backoff leaked an abort listener: the abortable backoff registered an `abort` listener on the long-lived run signal but only removed it on the abort path, so every normally-completing backoff leaked one listener (accumulating across retries/tool-calls in a run → MaxListenersExceededWarning). Remove the listener on the normal-completion path too. Found by a parallel bug-hunt over the tool-execution subsystem; both ship with red-before-green specs. Verified: agent suite 168 files green, boundaries + hygiene + lint clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Two real bugs in
core/tools/execute-tool-call.ts, found by a parallel bug-hunt over the tool-execution subsystem, each with a red-before-green spec.structuredBlockswas set only on a successfulexecuteStructuredand never reset per attempt, so a retry that threw returned the new attempt's error text paired with a previous attempt's structured blocks. Reset per attempt.abortlistener on the long-lived run signal but removed it only on the abort path; every normal completion leaked one listener (→ MaxListenersExceededWarning across a run). Remove it on the normal path too.Verified: agent suite 168 files green, boundaries + hygiene + lint clean.
🤖 Generated with Claude Code