Skip to content

fix: detach RunState interruption snapshots - #4409

Open
seratch wants to merge 1 commit into
mainfrom
fix/detach-runstate-interruptions
Open

fix: detach RunState interruption snapshots#4409
seratch wants to merge 1 commit into
mainfrom
fix/detach-runstate-interruptions

Conversation

@seratch

@seratch seratch commented Aug 14, 2026

Copy link
Copy Markdown
Member

This pull request fixes RunState.get_interruptions() so it returns detached ToolApprovalItem snapshots instead of exposing mutable approval content owned by RunState.

  • Detach typed Pydantic and mapping-based approval payloads without copying the owning Agent.
  • Preserve direct and nested approve() and reject() routing through canonical invocation identity.
  • Fail before returning partial results when a payload cannot be cloned safely, using a payload-safe SDK UserError.
  • Update corruption-path tests to mutate authoritative pending state explicitly rather than relying on public snapshot aliasing.

@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: 768ba9ad63

ℹ️ 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 Outdated
@seratch
seratch force-pushed the fix/detach-runstate-interruptions branch from 768ba9a to 46b5c92 Compare August 14, 2026 08:57

@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: 46b5c92e45

ℹ️ 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
Comment on lines +249 to +253
_TOOL_APPROVAL_MODEL_ADAPTERS: tuple[tuple[type[Any], TypeAdapter[Any]], ...] = (
(ResponseFunctionToolCall, TypeAdapter(ResponseFunctionToolCall)),
(McpCall, TypeAdapter(McpCall)),
(McpApprovalRequest, TypeAdapter(McpApprovalRequest)),
(LocalShellCall, _LOCAL_SHELL_CALL_ADAPTER),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Support every approval-bearing response model

When a CustomTool with needs_approval receives the normal ResponseCustomToolCall that turn_resolution.py queues verbatim, get_interruptions() now passes that model to _copy_tool_approval_raw_item(), but no adapter matches and the method raises UserError instead of returning the pending approval. ResponseFunctionShellToolCall is omitted for the same reason. Derive this set from the approval-processing pipeline or add adapters and regression coverage for these production models.

AGENTS.md reference: AGENTS.md:L93-L93

Useful? React with 👍 / 👎.

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.

1 participant