Skip to content

Preserve originating context for yielded code-mode tool calls - #44866

Merged
copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/4533379aae6e4ecb4aabe5a25e4aca5d65385d76
Sep 11, 2026
Merged

copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/4533379aae6e4ecb4aabe5a25e4aca5d65385d76

Conversation

@copyberry

@copyberry copyberry Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Preserve originating context for yielded code-mode tool calls

Why

A code-mode cell can outlive its turn. Nested tool calls dispatched during a later turn need the original step's tools and context, while approval handling must still work across that turn boundary.

What changed

  • Retain each cell's originating StepContext for nested tool dispatch and cancel queued calls whose context has been released.
  • Keep MCP approval metadata available for the lifetime of the running invocation, keyed by server and call ID.
  • Apply Guardian denial accounting and interruption to the active turn, including reviews from an earlier cell.
  • Carry turn_id in legacy MCP begin/end events so history reconstruction and rollout migration assign late completions to their original turn. Preserve the current-turn fallback for older records without it.

Testing

Add regression coverage for originating tool selection across turns, callback and metadata cleanup, delayed MCP elicitation review, Guardian interruption of the active turn, and late MCP completion attribution with legacy compatibility.

## Why

A code-mode cell can outlive its turn. Nested tool calls dispatched during a later turn need the original step's tools and context, while approval handling must still work across that turn boundary.

## What changed

- Retain each cell's originating `StepContext` for nested tool dispatch and cancel queued calls whose context has been released.
- Keep MCP approval metadata available for the lifetime of the running invocation, keyed by server and call ID.
- Apply Guardian denial accounting and interruption to the active turn, including reviews from an earlier cell.
- Carry `turn_id` in legacy MCP begin/end events so history reconstruction and rollout migration assign late completions to their original turn. Preserve the current-turn fallback for older records without it.

## Testing

Add regression coverage for originating tool selection across turns, callback and metadata cleanup, delayed MCP elicitation review, Guardian interruption of the active turn, and late MCP completion attribution with legacy compatibility.

GitOrigin-RevId: 4533379aae6e4ecb4aabe5a25e4aca5d65385d76
@copyberry
copyberry Bot force-pushed the copyberry/codex-internal-to-codex-oss/4533379aae6e4ecb4aabe5a25e4aca5d65385d76 branch from df7f96c to 2fc4bda Compare September 11, 2026 17:01
@copyberry
copyberry Bot merged commit 2fc4bda into main Sep 11, 2026
1 check passed
@copyberry
copyberry Bot deleted the copyberry/codex-internal-to-codex-oss/4533379aae6e4ecb4aabe5a25e4aca5d65385d76 branch September 11, 2026 17:01
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant