Repository navigation
Steer an active run and queue follow-up messages - #6208
markstuart-oai wants to merge 8 commits into
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
Security findingsBlocking findings (1)
Advisory findings (1)
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
jbeckwith-oai
left a comment
There was a problem hiding this comment.
Approved the incremental changes over #6207 after comprehensive static review and an independent second review. Checked handle ownership and nested/concurrent isolation; redaction and guardrails before staging; tool completion and next-request ordering; conservative occurrence-based receipts through filters; retry cutoff, cancellation, approval pauses, and local/server-managed history retention. No additional actionable findings in this PR's changes.
The stack still needs the ModelSelector release-policy fix requested in #6207 (review). This PR's prospective-release-contract job fails for that same inherited missing policy entry; this approval does not indicate green CI. Hosted CI: 4 passed, 3 skipped, 11 running and 1 failed. Pending checks remain tracked. Static review only; no candidate code or local tests executed.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ee09aa5a41
ℹ️ 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".
There was a problem hiding this comment.
This supersedes my earlier approval: I missed a stream-cleanup compatibility regression, now independently confirmed by static inspection. The existing finding #6208 (comment) is actionable; no duplicate inline comment is needed.
With RunControl enabled, controlled_stream wraps the adapter iterator but its finally block forwards only aclose(). The retry driver's existing _close_async_iterator supports both aclose() and close() (including awaitable close results). Since it now sees the wrapper, an underlying close-only iterator loses cleanup on completion, errors, or cancellation. Preserve the existing cleanup helper's behavior through this wrapper and add coverage with a close-only adapter iterator and RunControl.
The inherited ModelSelector release-contract failure from #6207 also remains. Static review only; no candidate code or tests executed.
Hosted CI follow-up: all currently reported checks have finished: 15 successful, 9 skipped, and the same inherited prospective-release-contract failure. The stream-cleanup request above remains unresolved.
There was a problem hiding this comment.
Re-reviewed the refresh with an independent second static review. The requested cleanup fix is addressed: controlled streams now use the existing closer, preserving both aclose() and close() support (including awaitable close results) and retaining the original provider failure if cleanup itself fails. Approval preview retirement occurs before provider cleanup awaits; existing idempotent retirement/retry behavior is preserved. Regression coverage exercises completion, error, timeout, cancellation and approval expiration. The updated base also carries the reviewed model-selector fixes. No additional actionable findings.
Latest inspected hosted CI snapshot: 11 passed, 8 running. Pending checks remain tracked. Static review only; no candidate code or local tests executed.
Hosted CI update (2026-11-24 07:37 UTC): 19 passed, 2 skipped; no checks remain pending in the current rollup. Approval is unchanged. No local tests were run.
|
@codex security review |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
There was a problem hiding this comment.
🛡️ Codex Security Review · Automatically triggered
Here are some automated security review suggestions for this pull request.
Reviewed commit: 994b36141b
ℹ️ 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
left a comment
There was a problem hiding this comment.
Request changes for the existing checkpoint identity finding: #6208 (comment). No duplicate inline comment added.
Static inspection confirms that serialization omits the follow-up task identities, restoration leaves _task_input_ids as None, and resumed task context falls back to the original input. This matters when task-sensitive tool policy is evaluated after approval: it can receive the original task while executing the follow-up. I considered the RunInbox documentation requiring in-memory resume for this case; the remaining concern is that unsupported serialized restoration silently continues with a different policy context instead of rejecting it. Persist and validate the task identities, or reject these serialized follow-up resumes before policy evaluation/tool execution. Add round-trip coverage with a task-sensitive tool guardrail.
The broader review covered queue/steer admission, guardrails, cancellation, nested isolation, receipts through input filtering, previous-output snapshots, accepted-response recovery and iterator cleanup, with independent static reviews. No additional actionable findings. Latest hosted CI snapshot: 17 passed, 2 skipped, 7 running; unfinished checks remain tracked. Static review only; no candidate code or local tests executed.
There was a problem hiding this comment.
Approved after static re-review and an independent second review. The serialized follow-up authorization-context finding is addressed: schema 1.27 preserves validated task references and restores them before specialist and nested authorization checks. Invalid or ambiguous references fail restoration; required nested task state cannot be silently discarded. Explicitly withdrawn input and handoff replacement retain their intended meaning. The intermediate 1.26 format is rejected.
Regression coverage now includes post-approval tool guardrails, pending/server-withheld input, failed session writes and replacement, repeated/replaced handoff input, and nested restoration failures. The added cancellation checks preserve accepted-response accounting while preventing tool execution after a provider suppresses cancellation. No additional actionable findings.
Latest reported hosted check runs: 17 passed, 7 running. Pending CI remains tracked. Static review only; no candidate code or local tests executed.
Hosted CI follow-up (2026-11-24 21:43 UTC): tests-windows (3.10) failed in test_parallel_guardrail_trip_cancels_model_task at tests/test_guardrails.py:586 (model_cancelled event was unset): https://github.com/openai/openai-agents-python/actions/runs/45492688013/job/138794870071. The expected tripwire exception and model-finished assertion passed. The test body is unchanged from the base and relies on a 20 ms sleep; static inspection is consistent with the model finishing before cancellation, but the root cause is not proven. No introduced defect is established by this failure, so code approval is unchanged; this does not indicate green CI. Other checks remain pending. No local tests were run.
Hosted CI final snapshot (2026-11-24 21:58 UTC): 30 passed, 5 skipped, 2 failed; no checks remain running. In addition to the previously recorded Windows guardrail test failure, verify (3.10, win_amd64) failed in tests/models/test_operation_tracing_parity.py:377: https://github.com/openai/openai-agents-python/actions/runs/45492688008/job/138806475603. Its timestamp comparison differs by 56 ns (1795557441549997056 versus 1795557441549997000); the helper converts datetime through floating-point timestamp() to nanoseconds. The entire test file is identical to the base (blob 077c60086a81776331165362fba8d7b435cb72df), and the observed values are consistent with conversion rounding. These hosted failures remain unresolved; no introduced code defect has been established. Approval remains unchanged and does not indicate green CI. Static inspection only; no local tests executed.
There was a problem hiding this comment.
🛡️ Codex Security Review · Automatically triggered
Here are some automated security review suggestions for this pull request.
Reviewed commit: 36fa6e13bd
ℹ️ 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
left a comment
There was a problem hiding this comment.
Approved after coordinator review and two independent static reviews of the update from e002fc7. No actionable findings.
The active task now remains identifiable when a handoff splits messages between history and generated input, when sandbox context hooks rewrite history, and after serialized resume. Ordered history references are validated against user-message content; conflicting copies and ambiguous rewrites fail before subsequent execution, and missing task messages do not revive earlier permissions. Copy observers preserve identity through supported conversions and are disabled on scope exit. Failed edits preserve the previous checkpoint. Policy continuations retain tool guardrail results, and owner cancellation is checked before preparing a follow-up after saving an answer.
Reviewed the new handoff, sandbox, serialization, recovery and cancellation regression coverage. The Windows guardrail test now uses an event instead of a timing-dependent sleep. The steering example and API documentation correctly describe synchronous submission and avoiding receipt waits in the stream consumer.
Latest hosted CI snapshot: 8 passed, 2 skipped, 16 running, with no failures observed on this commit. The previous commit had two Windows failures; this approval does not claim those checks have passed on the new commit. Pending CI remains tracked. Static review only; no candidate code or local tests executed.
jbeckwith-oai
left a comment
There was a problem hiding this comment.
Request changes for the existing mid-task steering authorization-context finding: #6208 (comment). No duplicate inline comment added. This supersedes my earlier approval at this commit; that review missed the unchanged _stage branch.
Coordinator and independent static inspection confirm that RunInbox._stage appends steering to pending model input but updates task identities only after a completed answer. During an unfinished task, _task_input_ids remains None or retains only the earlier follow-up IDs. Admission does not repair either case, so _get_turn_input omits the new steering while the next model request includes it. Dynamic tool policy and tool guardrails reading context.turn_input can therefore evaluate an earlier permission instead of a newly supplied restriction. This occurs in both awaited and streamed runs, without serialization or a handoff.
Preserve the current task's original input and append admitted mid-task steering to its policy context, while keeping post-answer follow-ups distinct. Add regression coverage where a mid-task steer changes a task-sensitive tool policy or guardrail, for both the original task and an active follow-up, including approval/resume.
The handoff and serialization improvements remain sound, but do not address this separate path. Hosted CI is still pending; no candidate code or local tests executed.
Why
A traveler asks for flights from Seattle to Boston. While the agent searches, the traveler adds "Only show nonstop flights." Use
steer()to include that request in the answer. Usequeue()when the traveler wants to ask another question after the first answer.Summary
Call
steer()andqueue()directly withoutawait. Both are synchronous. Each validates the message and immediately adds it to this run's in-memory inbox on the run's event loop. Neither waits for a model or tool.This example assumes an existing agent and an async function.
The receipt is optional. For the detailed submission outcome, use
await follow_up.wait()while another task drains the stream or after the loop. It reports whether the SDK passed the message to the model adapter. It does not wait for the answer or guarantee provider receipt. Do not block a tool or stream callback that must finish before submission can happen.previous_outputsholds earlier answers.final_outputholds the last answer.For
Runner.run, pass a freshRunInbox. The app suppliesregister_ui_callbacksand keeps its handlers active during the run, on the same event loop.Runner includes pending steering messages in order in its next model request, after any active tool or Codex request finishes. It takes one queued message after each successful answer.
Saved approvals retain which follow-up requested a tool, so tool guardrails check the correct follow-up after loading. Conversation state is saved normally. Pending inbox messages are not saved. If a handoff filter or sandbox hook rewrites messages so the SDK cannot tell which task authorized a tool, the run stops before running tools.
The SDK writes checkpoints in format 1.27 and reads formats 1.0 through 1.25. It cannot load checkpoints written in the unreleased format 1.26.
Standard Python mode and opt-in Codex mode support both calls. Try the runnable example with Python by default or with
--codex.Test plan
Issue number
None.
Checks
.agents/skills/code-change-verification/scripts/run.sh/reviewbefore submitting this PR