Skip to content

feat: #1097 support overrideArguments for approved tool calls#1098

Open
seratch wants to merge 9 commits intomainfrom
feat/approval-override-arguments
Open

feat: #1097 support overrideArguments for approved tool calls#1098
seratch wants to merge 9 commits intomainfrom
feat/approval-override-arguments

Conversation

@seratch
Copy link
Copy Markdown
Member

@seratch seratch commented Mar 14, 2026

This pull request resolves #1097.

It adds overrideArguments support to RunState.approve(...) so human approval flows can correct a pending function_call before execution and resume with the corrected arguments. The runner and RunState now propagate those overrides through resumed execution, replay input, tracing, and serialized state so the approved tool call behaves consistently across interruption and resume boundaries.

To support durable local replay, this change also adds session-history rewrite support for local sessions, including a new OpenAIResponsesHistoryRewriteSession and shared rewrite-aware session interfaces/exports. That allows corrected function-call arguments to become the canonical persisted history for local memory/file-backed flows, while saveOverrideArguments remains an opt-out for execution-only overrides in server-managed conversation paths where persisted history cannot be rewritten. Examples and tests were updated to cover local persistence, compaction ordering, public exports, and the conversation/previous-response edge cases around override handling.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 14, 2026

🦋 Changeset detected

Latest commit: 3b487df

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@openai/agents Patch
@openai/agents-core Patch
@openai/agents-openai Patch
@openai/agents-extensions Patch
@openai/agents-realtime Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@seratch seratch changed the title feat: #1097 support overrideArguments for approved tool calls feat: #1097 support overrideArguments for approved tool calls Mar 14, 2026
@github-actions github-actions Bot added this to the 0.7.x milestone Mar 14, 2026
@seratch
Copy link
Copy Markdown
Member Author

seratch commented Mar 14, 2026

@codex review

Copy link
Copy Markdown

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

Choose a reason for hiding this comment

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

💡 Codex Review

const serverManagesConversation =
Boolean(effectiveOptions.conversationId ?? resumedConversationId) ||
Boolean(effectiveOptions.previousResponseId ?? resumedPreviousResponseId);

P2 Badge Detect server-managed sessions before blocking exec-only overrides

serverManagesConversation is computed only from conversationId/previousResponseId. Resumes using OpenAIConversationsSession usually have neither, so execution-only overrides (saveOverrideArguments: false) are rejected even though the transcript is server-managed and non-rewriteable. This blocks the intended fallback path for conversations-backed runs.

ℹ️ 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 packages/agents-openai/src/memory/openaiResponsesCompactionSession.ts Outdated
@seratch seratch force-pushed the feat/approval-override-arguments branch from b987d9c to cea8656 Compare March 15, 2026 00:17
Copy link
Copy Markdown

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

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: cea8656ac9

ℹ️ 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 packages/agents-openai/src/memory/openaiResponsesCompactionSession.ts Outdated
@seratch seratch force-pushed the feat/approval-override-arguments branch from cea8656 to d0cb8cf Compare March 15, 2026 11:18
@seratch seratch marked this pull request as ready for review March 15, 2026 11:18
@seratch seratch modified the milestones: 0.7.x, 0.9.x Mar 20, 2026
@github-actions
Copy link
Copy Markdown
Contributor

This PR is stale because it has been open for 10 days with no activity.

@github-actions github-actions Bot modified the milestones: 0.9.x, 0.8.x Apr 13, 2026
Copy link
Copy Markdown

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

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: f307f0f4d7

ℹ️ 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 packages/agents-core/src/run.ts Outdated
Copy link
Copy Markdown

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

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: 4d6aa770df

ℹ️ 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 packages/agents-core/src/run.ts Outdated
Copy link
Copy Markdown

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

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: f68f7140bf

ℹ️ 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 packages/agents-core/src/runState.ts Outdated
Copy link
Copy Markdown

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

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: f58a7af315

ℹ️ 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 packages/agents-core/src/run.ts Outdated
Copy link
Copy Markdown

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

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: 3b487df52f

ℹ️ 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 on lines 1014 to 1015
const serverManagesConversation =
Boolean(resolvedConversationId) || Boolean(resolvedPreviousResponseId);
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 Align streamed persistence gate with chain-availability logic

Use the same chain-availability predicate as Runner.run(). Here any non-empty previousResponseId marks the stream as server-managed, so resumed runs with a tagged server-managed session (no explicit chain) skip saveStreamResultToSession. That silently drops streamed tool outputs from local session history, breaking later fresh turns that rely on session replay.

Useful? React with 👍 / 👎.

@seratch seratch modified the milestones: 0.8.x, 0.9.x Apr 17, 2026
Copy link
Copy Markdown
Contributor

@wsk-builds wsk-builds left a comment

Choose a reason for hiding this comment

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

I reviewed the approval override path, local session history rewrite, conversationId/previousResponseId handling, serialized RunState resume, and the updated examples. The targeted tests I ran passed: pnpm -F @openai/agents-core test runState.test.ts, pnpm -F @openai/agents-core test runner/sessionPersistence.test.ts, and pnpm -F @openai/agents-openai test hitlOpenAIConversationsSession.test.ts.

One docs/example issue to fix or clarify:

  • examples/agent-patterns/human-in-the-loop.ts:93-99: the sample says the serialized state could be resumed on a different thread/process, but after RunState.fromString(...) it still iterates result.interruptions from the original in-memory result. In the actual cross-process case that object is not available, and users should approve/reject the interruptions from the restored state, e.g. for (const interruption of state.getInterruptions()). This matters more now that the example demonstrates overrideArguments, because the approval is supposed to be applied to the rehydrated RunState and the sample should show the recoverable source of pending approvals.

I did not find a blocker in the core override execution, local rewrite application, server-managed conversation restrictions, or serialized resume behavior in the covered paths.

@seratch seratch modified the milestones: 0.9.x, 0.10.x, 1.1.x Apr 28, 2026
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.

Feature: approve() with modified arguments

2 participants