Repository navigation
fix(agents): retain operator authority for recovery-spawned children - #178186
Conversation
Native child admission now retains the existing independent continuation authority, so children survive completion of a restart-recovered requester. The original scope and model ceilings, live source-policy checks, and parent Stop cancellation still apply. Add production-boundary regressions for child completion and parent Stop, and clarify the restart-recovery documentation. The completion regression fails on the base with inactive admitted operator authority. Focused recovery, authority, registry, and cancellation tests pass. One collector-origin failure in the full spawn file did not reproduce in the focused replay.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ 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. |
|
Codex review: needs real behavior proof before merge. What this changesNative children spawned by a recovered parent retain independent operator policy authority after the parent finishes. Example: A restart-recovered parent spawns eight native children and finishes before them.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 4 items remain This PR addresses a concrete recovery lifetime defect with a focused change to the existing authority owner; no introduced code defect was found. Priority: P1 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherGateway admission transfers the authenticated requester's authority into an accepted agent run; native spawning uses that admission path to establish each child's execution lifetime. flowchart TD
A[Interrupted parent] --> B[Recovery authority owner]
B --> C[Recovered parent turn]
C --> D[Native child admission]
B --> E[Current operator policy]
E --> D
D --> F[Child execution and effects]
Technical reviewBest possible solution: Keep the focused admission change and verify its retained authority through a native child's final effect. Do we have a high-confidence way to reproduce the issue? Current main selects inherited claim-bound authority at native child admission, and the PR reports a matching base failure and live restart reproduction; no target code was executed during this review. Is this the best way to solve the issue? Selecting the existing independent continuation authority at child admission is the smallest complete production fix and preserves the shared scope, model-policy, revocation, and cancellation owners. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 23af78ff67ae. Merge-risk optionsMaintainer options:
Provenance checked
TestingProof path: in-process harness. SecurityNeeds attention: No concrete authorization bypass was found, but the extended native-child lifetime needs final-effect revocation evidence. EvidenceWhat I checked:
PR surfaceSource +4, Tests +236, Docs +2. Total +242 across 4 files. Added test files: 1. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 20, 2026, 3:15 AM ET / 07:15 UTC. |
Let top-level recovery scenarios opt out of the default grouping parent. Otherwise their human-message event queues a delayed notice to a missing main session and fails later boundary tests. Assert that the recovery cases leave no such notices. Preserve grouped fixture defaults and production authority behavior. Verified three full spawn-boundary runs, focused recovery and admitted-context tests, owning typechecks, lint, format, and independent review.
|
Merged via squash.
|
…penclaw#178186) * fix(agents): retain operator authority for recovery-spawned children Native child admission now retains the existing independent continuation authority, so children survive completion of a restart-recovered requester. The original scope and model ceilings, live source-policy checks, and parent Stop cancellation still apply. Add production-boundary regressions for child completion and parent Stop, and clarify the restart-recovery documentation. The completion regression fails on the base with inactive admitted operator authority. Focused recovery, authority, registry, and cancellation tests pass. One collector-origin failure in the full spawn file did not reproduce in the focused replay. * test(agents): isolate recovery spawn fixture notices Let top-level recovery scenarios opt out of the default grouping parent. Otherwise their human-message event queues a delayed notice to a missing main session and fails later boundary tests. Assert that the recovery cases leave no such notices. Preserve grouped fixture defaults and production authority behavior. Verified three full spawn-boundary runs, focused recovery and admitted-context tests, owning typechecks, lint, format, and independent review.
What Problem This Solves
If the Gateway crashes while a parent is still in its first turn (spawning children, not yet yielded), main-session restart recovery resumes that turn as a restart-recovery operator run. Any child the resumed parent spawns inherits the recovery run's run-scoped authority. When the parent's recovered turn ends, the recovery assertion revokes that authority, and every child dies about 10 s into its work:
Live, a crash before the parent's yield wiped out the whole fleet:
openai/gpt-6-astra, killed mid-first-turn: 16 authority-lost failures and nothing merged.User Impact
Recovery-spawned children can finish their accepted work after the recovered parent finishes. Explicitly stopping the parent still cancels its children. No migration or operator action is required.
Why This Change Was Made
Native child admission (
agent-run-admission-phase.ts) now asksretainGatewayOperatorRunforindependentContinuationwhen the caller is a native subagent. The child then retains the existing independent continuation authority, the same mechanismdocs/gateway/restart-recovery.mdalready promises for accepted child continuations, instead of the parent's run-scoped recovery claim.Original authority validation, scope intersection, the model-policy ceiling and live source-policy checks still apply. Revoking the operator, replacing the source session or stopping the Gateway still invalidates the child. Explicitly stopping the parent still cancels it. No new token, store or grant path is added. The docs now name
sessions_spawnchildren explicitly.Evidence
subagent-spawn.production-boundary.test.ts: "recovered requester finish before its spawned child: complete" is red on base (admitted run operator authority is no longer activeatadmitted-run-context.ts:355) and green with the fix. A Stop regression confirms parent Stop still persists the child as killed. Theadmitted-run-context,operator-run-recovery(.requester),server-instance-runtime.operator-recovery,server.startup-recovery-boundary/-webchat,subagent-registry-restart-recoveryandoperator-run-cancellationsuites pass.kill -9while both parents were still in their first turn (neither yielded):The first head's CI failed a nested-plugin case with "Session event origin is missing". The cause was the new recovery fixture: it assigned a nonexistent
agent:main:mainparent whose delayed notice could fail during a later test (session-event-handoff.ts:499, reproduced with a controlled timer probe). The second commit makes those cases explicitly parentless and asserts that no notice leaks. The full spawn file then passed 3/3 consecutive runs (63/63), with production code unchanged.