Skip to content

fix: reconcile resumed tool name collisions - #4145

Merged
seratch merged 2 commits into
mainfrom
fix/resume-tool-name-collision-policy
Aug 4, 2026
Merged

fix: reconcile resumed tool name collisions#4145
seratch merged 2 commits into
mainfrom
fix/resume-tool-name-collision-policy

Conversation

@seratch

@seratch seratch commented Aug 3, 2026

Copy link
Copy Markdown
Member

This pull request fixes stale tool and handoff routing when a run resumes after a human-in-the-loop approval.

Before this change, queued function-tool and handoff runs retained the tool objects selected before the pause. If the enabled tools, handoffs, or their ordering changed while the run was interrupted, resuming could execute a stale or disabled tool even when RunConfig.tool_name_collision_policy selected a different current winner.

The resume path now rebuilds the current tool inventory using a consistent enabled-handoff snapshot, applies the canonical collision resolver, and reconciles queued calls with the resulting winners before allowing side effects. Under the default warn policy, queued calls are rebound to the current winning function tool or handoff. Under the error policy, current collisions fail before tool execution or handoff transfer.

The implementation also:

  • reconciles function-to-function, function-to-handoff, handoff-to-function, and handoff-to-handoff winner changes;
  • respects tool_not_found_behavior when a queued tool is no longer available;
  • preserves model call order when combining executed, rejected, and missing-tool results;
  • validates persisted approval identity before dynamic tool inventory callbacks run;
  • snapshots approval and invocation metadata so mutable callbacks cannot change routing or authorization decisions during resume;
  • preserves interrupted Agent.as_tool() state when a strict missing-tool error or formatter cancellation aborts a resume;
  • transfers nested run state only after reconciliation succeeds, preventing failed or ambiguous replacements from corrupting retryable state;
  • propagates the same handoff snapshot through custom get_mcp_tools() and get_all_tools() overrides that delegate to the base implementation.

This does not add a new public API or change the serialized RunState schema. It uses the existing tool_name_collision_policy configuration.

Queued calls with duplicate call IDs intentionally retain the existing ordered owner-binding behavior because they cannot be reconciled unambiguously. Applications that need tool replacement across an interruption should use unique provider call IDs. Replacing an interrupted Agent.as_tool() with a different owner before deserializing the state also remains unsupported because the current persisted state does not contain a durable owner identity.

Documentation is intentionally excluded from this pull request and will be handled separately.

This pull request resolves #4116.

@seratch seratch added this to the 0.19.x milestone Aug 3, 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: 4517f74a93

ℹ️ 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_internal/turn_resolution.py
@seratch
seratch force-pushed the fix/resume-tool-name-collision-policy branch from 4517f74 to e0f0b50 Compare August 3, 2026 07:34
@seratch seratch changed the title fix: enforce tool name collision policy when resuming runs fix: reconcile queued tool calls with current collision winners Aug 3, 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: e0f0b501ad

ℹ️ 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_internal/turn_resolution.py Outdated
Comment thread src/agents/run_internal/turn_resolution.py Outdated
@seratch
seratch force-pushed the fix/resume-tool-name-collision-policy branch from e0f0b50 to 69dddfc Compare August 3, 2026 12:58

@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: 69dddfc2d3

ℹ️ 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_internal/turn_resolution.py Outdated
Comment thread src/agents/agent.py Outdated

@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: 521b12dedc

ℹ️ 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_internal/turn_resolution.py Outdated
Comment thread src/agents/run_internal/turn_resolution.py Outdated
@seratch
seratch force-pushed the fix/resume-tool-name-collision-policy branch from 521b12d to 96e096e Compare August 4, 2026 01:28

@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: 96e096ef20

ℹ️ 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_internal/turn_resolution.py
@seratch
seratch enabled auto-merge (squash) August 4, 2026 02:02
@seratch seratch changed the title fix: reconcile queued tool calls with current collision winners fix: reconcile resumed tool name collisions Aug 4, 2026
@seratch
seratch disabled auto-merge August 4, 2026 02:07
@seratch
seratch enabled auto-merge (squash) August 4, 2026 02:07
@seratch
seratch merged commit 648c252 into main Aug 4, 2026
9 checks passed
@seratch
seratch deleted the fix/resume-tool-name-collision-policy branch August 4, 2026 02:16
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.

Reject duplicate function tool names

1 participant