Repository navigation
feat: let agent hooks request another turn before accepting a final answer - #6124
markstuart-oai wants to merge 5 commits into
Conversation
…nswer Signed-off-by: markstuart-oai <[email protected]>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
Security findingsAdvisory 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. |
There was a problem hiding this comment.
Superseded by request changes: Python 3.10 cancellation assertion failures.
Approved after comprehensive static review and an independent second review. Reviewed text, structured and final-tool candidates; missing/empty content and refusal handling; approval/resume and handoff precedence; turn numbering and limits; provisional history; error-handler bypass; accepted-output guardrails and end hooks; and cancellation/error propagation. Completed tool effects are checkpointed before resumed policy evaluation and retained on policy failure, while parent cancellation joins the policy task without accepting a late finish. Existing behavior remains unchanged without a policy. No actionable findings.
Hosted check snapshot: {"SUCCESS": 14, "IN_PROGRESS": 9, "FAILURE": 1}. Pending checks require follow-up. Static review only; no candidate code or local tests executed.
There was a problem hiding this comment.
Request changes: supersedes my approval at this commit. I published that approval before inspecting the newly completed Python 3.10 failure. The hosted job reports six failures, all in new cancellation-message assertions: expected decision failed or local, actual empty string. Make these assertions compatible with supported Python 3.10 while retaining cancellation-type, checkpoint/session persistence and no-replay checks. No additional production correctness findings from the comprehensive static and independent reviews. Hosted CI is now terminal: 31 passed, 2 failed (the known Python 3.10 jobs), and 6 skipped. The request-changes decision remains in effect. 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 Python 3.10 cancellation-test finding is fixed: only cancellation-message matching is relaxed on Python versions below 3.11, while RuntimeError messages, cancellation types, suppressed final hooks, exactly-once tool effects, resumed output, and persisted session results remain checked. The incremental change is limited to these tests; no remaining actionable findings.
Hosted CI is complete: 33 passed and 2 skipped; no failures. Static review only; no candidate code or local tests executed.
Refresh follow-up (2026-11-22 21:45 UTC): rechecked current commit 28d818344a120756f0975bd605f4902e9336d813 against the prior reviewed patch and refreshed base. Added/deleted lines are unchanged; integration context remains sound. GitHub already associates this approval with the current commit. Reviewed the new guardrail comment: step_policy explicitly documents continued candidates as provisional and not subject to final-output guardrails; finish retains normal guardrail finalization. This is consistent with the existing final-output guardrail contract, so no actionable regression found. Earlier CI results describe the prior commit. Current hosted CI: {'SKIPPED': 2, 'SUCCESS': 19, 'IN_PROGRESS': 5}. Unfinished checks remain pending follow-up. Static review only; no candidate code or local tests executed.
Hosted CI follow-up (2026-11-22 22:10 UTC): current commit 28d818344a120756f0975bd605f4902e9336d813 completed with 33 successful checks and 4 skipped checks. No failures. Static review only; no local tests executed.
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
🛡️ Codex Security Review · Automatically triggeredSecurity 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: 28d818344a
ℹ️ 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.
There was a problem hiding this comment.
Re-reviewed 716221d2011da0649f3117c27019dc5f96f341ea. Continuation candidates now run both agent and run output guardrails before persistence or the next model turn. Checked fresh and approval-resumed runs in streamed and non-streamed modes, successful continuation without end hooks/final output/completion sentinel, blocked-candidate removal, preservation of sanitized completed-tool effects, validator errors, cancellation, and held session writes. The new matrix and documentation match this stronger continuation contract. Independent static review found no actionable regressions.
Hosted CI at review: 8 successful checks, 2 skipped, 16 in progress. CI remains pending follow-up. Static review only; no candidate code or local tests executed.
Hosted CI follow-up (2026-11-22 23:25 UTC): all 33 executed checks passed; 4 checks skipped. No checks remain pending for this commit. Static review only; no candidate code or local tests executed.
Summary
AgentHooks(step_policy=decide)lets an application request another turn when an agent proposes an answer too soon. For example, an application can require both a measurement and a calculation before accepting an answer.The optional callback receives the run context and a
SettledStep. Return"finish"for normal finalization or"continue"to try again with the same agent. The callback can be synchronous or asynchronous. Dynamic instructions can use updated context to guide the next turn. The existing turn limit still applies.The policy runs once per proposed answer after approvals resolve. A handoff takes precedence. Candidates include text, parsed structured output and final tool results selected by
tool_use_behavior. Agents without a policy keep their existing behavior.Both choices run agent and run output guardrails. On continuation, the Runner skips end hooks. If validation fails or is cancelled, the Runner stops before the next model request, keeps the unchecked candidate out of session history and omits run data from SDK exceptions. When it can safely retain a completed tool call, it saves a placeholder for its output. Validated candidates remain in history as provisional output. Earlier stream events and tool effects cannot be undone.
Test plan
Checks
.agents/skills/code-change-verification/scripts/run.sh