Skip to content

fix: resume recursive agent tool approvals - #4414

Merged
seratch merged 1 commit into
mainfrom
fix/recursive-agent-tool-approval-resume
Aug 14, 2026
Merged

seratch merged 1 commit into
mainfrom
fix/recursive-agent-tool-approval-resume

Conversation

@seratch

@seratch seratch commented Aug 14, 2026

Copy link
Copy Markdown
Member

This pull request fixes approval resume through recursively nested Agent.as_tool calls.

When a protected tool was nested behind two or more agent-tool edges, approving the flattened interruption from RunResult.to_state() could leave the same interruption pending or allow the outer run to continue without executing the protected tool. The resume path now resolves the deepest nested RunState that owns the approval and checks that owner’s decision ledger before deciding whether to rerun the pending agent tool.

The change preserves existing checkpoint isolation and serialized RunState behavior. Regression coverage verifies two- and three-edge nesting for both Runner.run and Runner.run_streamed, including exactly-once protected-tool execution.

ref: #4413 (comment)

@seratch seratch added this to the 0.21.x milestone Aug 14, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9dc7da9f2b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agents/run_state.py Resolved
@seratch
seratch force-pushed the fix/recursive-agent-tool-approval-resume branch from 9dc7da9 to 1725a89 Compare August 14, 2026 12:49

Copy link
Copy Markdown
Contributor

I independently validated the exact head 1725a8989adcba536641cea1ef56a02d310c534e with AgentRunProof plus the upstream test suite.

The pre-fix head 9dc7da9 reproducibly failed the serialized recursive-approval scenario: after a RunState.to_json() / RunState.from_json() boundary, both approval and rejection remained interrupted. On this head, all of the following pass in both Runner.run and Runner.run_streamed:

  • sibling RunState approval isolation;
  • recursive live approval routing;
  • recursive approval routing after JSON restoration;
  • approve and reject decisions, with 2 and 3 nested Agent.as_tool() edges;
  • decisions applied before serialization and after restoration.

The focused upstream suites are also green locally (546 passed), and the full GitHub Actions matrix is green. I found no remaining issue in this contract.

@seratch
seratch merged commit 50d65f6 into main Aug 14, 2026
14 checks passed
@seratch
seratch deleted the fix/recursive-agent-tool-approval-resume branch August 14, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants