Skip to content

Fix two tool-retry bugs in the agent execute loop#6

Merged
QiaolongLi1201 merged 1 commit into
mainfrom
codex/agent-capability-gap-fixes
Jun 13, 2026
Merged

Fix two tool-retry bugs in the agent execute loop#6
QiaolongLi1201 merged 1 commit into
mainfrom
codex/agent-capability-gap-fixes

Conversation

@QiaolongLi1201

Copy link
Copy Markdown
Collaborator

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.

  1. Stale structured content on retrystructuredBlocks was set only on a successful executeStructured and 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.
  2. Abort-listener leak in retry backoff — the abortable backoff added an abort listener 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

- 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>
@QiaolongLi1201 QiaolongLi1201 merged commit 3b33f18 into main Jun 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant