Skip to content

Allow request preparation in native TypeScript sessions - #2160

Merged
markstuart-oai merged 59 commits into
feat/codex-harnessfrom
codex/native-request-preparation-v1-6b753b17
Nov 5, 2026
Merged

markstuart-oai merged 59 commits into
feat/codex-harnessfrom
codex/native-request-preparation-v1-6b753b17

Conversation

@markstuart-oai

@markstuart-oai markstuart-oai commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Builds on merged #2162. Current head: 8edad04d.

Summary

Add prepareRequest to native TypeScript sessions so callers can edit instructions, input, tool descriptions and JSON schemas before sampling. The callback receives a detached request. Execution keeps the original tool declarations and admission rules.

This supports direct root Responses HTTP requests with selected eager function and MCP tools. Each new sampling request invokes the editor; HTTP retries reuse its captured edit. Unsupported selections fail before editor or provider dispatch. Pre-turn and mid-turn automatic compaction fail before hidden requests. Post-turn compaction skips the hidden request and preserves the completed answer.

Managed tools expose their original JSON schemas, so partial edits preserve raw keywords. No-op and description-only edits restore Core's captured declaration projection before validation. The public types are available through @openai/agents-codex and the existing @openai/agents facade.

Test plan

The new post-turn native regression reproduces the old failure with an editor; its normal-compaction control passes. Current-head hosted code/security reviews and Justin's source review are clean.

A normal development build verifies Core 1c65094c, all 135 native inputs and six independent physical products. All 50 editor/context/default native cases and two callback/parent-policy controls pass, including both post-turn cases and all raw-schema regressions. Both required independent source reviews are clean. The complete SDK verification passes: format, lint, build, types and 9,567 tests, with 116 skipped. Reviewed source and all native product hashes remain unchanged before and after verification. Platform CI status is tracked in the checks below.

Before the post-turn correction, the raw-schema fix passed 48 native editor/context/default cases, four Rust schema tests and two trace controls. Earlier qualification also covered 18 source cases and installed Linux release runtime/declarations. Those results support the unchanged components; earlier products do not qualify the changed Core.

Issue number

REQ106

Checks

  • Added regression coverage and a changeset.
  • Updated the request-preparation example and phase-boundary documentation.
  • Completed current-head hosted source review.
  • Qualify the rebuilt native products and complete final local verification.
  • Complete hosted CI on all platforms.

@changeset-bot

changeset-bot Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8edad04

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

This PR includes changesets to release 6 packages
Name Type
@openai/agents-codex Minor
@openai/agents Minor
@openai/agents-core Minor
@openai/agents-extensions Minor
@openai/agents-openai Minor
@openai/agents-realtime Minor

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

@markstuart-oai
markstuart-oai marked this pull request as ready for review November 5, 2026 05:13
@markstuart-oai
markstuart-oai requested a review from a team as a code owner November 5, 2026 05:14
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-05T19:18:54.799335Z 8edad04 New commits
🔒 Security Review ✅ Completed 2026-11-05T19:19:48.682693Z 8edad04 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: 23304ddecd

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes requested after coordinator and independent static review. Existing finding #2160 (comment) is blocking: Agent.run(null, {state, prepareRequest}) accepts and stores the callback, but the resumed path calls session.wait() and bypasses its only reader in _run. Reject this unsupported combination before opening the session. Also avoid cloning the entire prompt for ordinary operations without an editor (existing #2160 (comment)), and document the automatic-compaction failure restriction in the public callback API (#2160 (comment)). No duplicate inline comments added.

The exact-store/generation admission, one-shot replies, canceled callback joining, detached schema presentation and original executable authority otherwise look sound. Node tests/coverage passed; native packaging remains pending. No candidate code or local tests ran.

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved after coordinator and independent static re-review. All three findings are addressed: null-input resume rejects a new editor before restoring resources, ordinary sampling borrows the original prompt, and public docs describe pre/mid/post-turn compaction restrictions. The new regression verifies rejection leaves the checkpoint usable. The author reports a separate checkpoint/executor timeout under investigation; retain that follow-up.

Hosted CI remains pending. Static review only; no candidate code or local tests ran.

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved after coordinator and independent static re-review of the base integration. Direct tree comparison shows 25 of 31 changed files equal the current base. Reviewed the six overlapping files, including TraceContext propagation through startTurn, manual continuation and native argument ordering. Prepared-request behavior and all prior fixes remain intact.

Hosted CI remains pending. Static review only; no candidate code or local tests ran.

@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: 3e572447fe

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes requested after validating two existing findings; no duplicate inline comments added.

  1. #2160 (comment) : one-shot admission still permits unhandled manual tools because canCheckpointManual ignores prepareRequest. If the model calls the tool, sealManualTurn rejects the editor-bearing operation and maybeSealManual returns InteractionRequired without resumable state. Reject this combination before model activity unless an interaction handler is supplied.
  2. #2160 (comment) : the early owned-run profile omits declarations.checklist, so an inevitably unsupported run can open provider/MCP resources before the later Session check rejects it. Add the checklist preflight.

The new deferred-roster changes themselves look sound: native validation checks the selected sampling roster before invoking the editor, and beforeStep cannot exceed the operation ceiling. No hosted checks were reported for this new head at inspection; CI follow-up remains open.

Static review only; no candidate code or local tests ran.

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The reviewed findings are addressed: edited one-shot runs with unhandled manual tools reject before model/editor activity, checklist incompatibility rejects during early preflight, and managed parameter edits retain raw schema constraints through the sampling receipt while preserving immutable identity and original execution validation. Ordinary MCP edits still require lossless projection. Reviewed base integration; no new findings. Hosted native CI is pending. Coordinator and independent static review; no candidate code or local tests executed.

@markstuart-oai
markstuart-oai changed the base branch from feat/codex-harness to codex/terminal-authentication-retry-v1-6b753b17 November 5, 2026 16:07

Copy link
Copy Markdown
Contributor Author

@codex review
@codex security review

Please review current head 4f7b49f16e69dc8439b88feb5e1a4c88b5f9901a against its updated dependency branch. The body distinguishes source integration checks from native qualification and hosted CI.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 4f7b49f16e

ℹ️ 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".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 4f7b49f16e

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved at 4f7b49f. Request preparation and fatal propagation remain intact when composed with authentication recovery and the reviewed A2A changes. Shared tracing/child-admission changes match reviewed 1875314, and patch hashes match the manifests.

Current reported hosted checks: 7 SUCCESS, 1 IN_PROGRESS. Coordinator and independent static review found no actionable integration regressions. No candidate code or local tests executed; no CI reruns requested.

Base automatically changed from codex/terminal-authentication-retry-v1-6b753b17 to feat/codex-harness November 5, 2026 18:20

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved at f563352. Coordinator and independent static review found no actionable integration issues. All 51 files changed since 4f7b49f match the merged parent and current base exactly; all 21 feature files remain byte-identical to the prior approval. The imported changes cover documentation, example import/output adjustments, and suite-owned telemetry setup/teardown without removing test assertions. Previously withdrawn findings remain withdrawn.

Fresh hosted CI remains pending. No candidate code, local tests, builds, generators or CI reruns executed.

@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: f56335279f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved at ea8a96e. The two-file fix addresses the existing raw-schema finding: managed request editors receive original JSON Schema keywords, unchanged declarations return to Core’s original projection, and partial edits retain raw keywords through serialization receipts. Tool identity checks, executable validators and ownership remain intact. Rust and native TypeScript regressions cover unchanged, description-only and partial-schema edits. Coordinator and independent static review found no actionable issues.

Fresh hosted CI remains pending. No candidate code, local tests, builds, generators or CI reruns executed.

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved at 8edad04. The post-turn guard preserves a completed answer by skipping automatic compaction when request preparation is active. Pre-turn and mid-turn rejection remain intact; pinned upstream and the composed Fatal propagation were inspected. Edited and ordinary regressions assert one versus two provider requests and preserve the final answer. Patch checksum matches the manifest, and the previously reviewed raw-schema fix is unchanged.

Coordinator and independent static review found no actionable issues. Hosted CI remains pending. No candidate code, local tests, builds or CI reruns executed.

@markstuart-oai
markstuart-oai merged commit b947095 into feat/codex-harness Nov 5, 2026
8 checks passed
@markstuart-oai
markstuart-oai deleted the codex/native-request-preparation-v1-6b753b17 branch November 5, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants