Repository navigation
fix: completion turns lose delegation tools after same-model retries - #163032
Conversation
|
🦞👀 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: needs maintainer review before merge. Reviewed October 1, 2026, 7:56 PM ET / 23:56 UTC (Revision 5). ClawSweeper reviewWhat this changesThe PR preserves authorized delegation tools after same-model retries while retaining completion-turn restrictions for genuine model fallback. Merge readiness✅ Ready for maintainer review This PR remains necessary and has no actionable correctness findings. The updated runtime evidence satisfies the prior proof request; current main still contains the reported defect. Priority: P1 Review scores
Verification
How this fits togetherThe embedded agent runner turns incoming agent requests and completion notifications into model attempts. Its retry and routing decisions determine which authorized tools the recovered attempt can discover and execute. flowchart TD
A[Agent request or completion notification] --> B[Embedded run loop]
B --> C[Same-model retry or actual fallback]
C --> D[Delegation capability]
D --> E[Authorized tool catalog]
E --> F[Session send or child launch]
F --> G[Execution and settlement]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +7, Tests +139. Total +146 across 3 files. View PR surface stats
Review metricsNone. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep retry diagnostics separate from actual routing facts so recovery preserves existing grants and genuine fallback completion turns remain report-only. Do we have a high-confidence way to reproduce the issue? Yes, from source: a same-model retry records a failure reason that current main converts into fallbackActive, removing delegation tools for completion provenance. This read-only review did not execute the runtime. Is this the best way to solve the issue? Yes. Repairing fallback classification at its producer preserves the shared restriction owner and existing authorization contracts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c3f2837f569e. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
|
Landed as c96350d. Thanks @stackingrockss, for both the report and the fix, and congrats on your first OpenClaw PR! |
…penclaw#163032) Fixes openclaw#163020. A same-model transient retry of a requester completion turn now keeps `sessions_send` and `sessions_spawn` in the tool set, so the requester can keep delegating after recovering. Proof: real isolated Gateways where a parent spawns a worker and receives its completion, with an injected 503 on the first completion request. main dropped both tools on the retry; this change keeps them. First-attempt tool lists and ordinary-turn retries are unchanged. Live check: after the injected 503, a real OpenAI request returned 200 with the full tool list and the completion turn finished. Regression tests fail on main and pass here. Co-authored-by: Ayaan Zaidi <[email protected]>
…penclaw#163032) Fixes openclaw#163020. A same-model transient retry of a requester completion turn now keeps `sessions_send` and `sessions_spawn` in the tool set, so the requester can keep delegating after recovering. Proof: real isolated Gateways where a parent spawns a worker and receives its completion, with an injected 503 on the first completion request. main dropped both tools on the retry; this change keeps them. First-attempt tool lists and ordinary-turn retries are unchanged. Live check: after the injected 503, a real OpenAI request returned 200 with the full tool list and the completion turn finished. Regression tests fail on main and pass here. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit c96350d)
Fixes #163020
What Problem This Solves
Fixes: requester completion and settle turns lose
sessions_send/sessions_spawnafter a transient timeout, overload, or HTTP 520 retry that stays on the same provider/model.User Impact
User impact: authorized coordinators can continue existing work after same-model recovery instead of requiring a fresh user message to restore delegation. No migration or permission expansion is required.
Why This Change Was Made
Separate retry diagnostics from actual fallback routing at the embedded run-loop owner. Retain retry reasons for exhaustion handling, but derive fallback state from actual fallback traces or the caller's routing provenance. An explicit fallback stage remains restricted even when its reason is absent or two providers use the same model identifier.
Security impact: genuine fallback-completion report-only gating remains enabled. Ordinary authorization, child-depth hard-denies, disabled tools, allowlists, and live admitted-run authority are unchanged. This is runtime-only: no UI, dependencies, installed-runtime changes, deployment, or Gateway restart.
Evidence
Real candidate behavior, not mocked attempts
Verified on clean head
1e88389059cb23bd42e1f8fd63bb70157ba2fa8dusing a disposable normally bootstrapped Gateway, preconfigured synthetic agents, a signed ephemeral operator identity, and a controlled HTTP/SSE model service. The publicagentrequest carried completion/settle provenance. Model requests, retry ownership, dynamic tool discovery, tool dispatch, subagent launch, peer execution, and settlement all used the candidate's real owners; none of those boundaries were mocked or bypassed.The synthetic service first returned HTTP 520. The Gateway logged
transient same-model retry 1/8 ... reason=server_error. On recovery, the model called actualtool_searchandtool_call: spawn was accepted and its child executed, then send executed a real peer run and returnedPEER_OK.A before comparison restored only the original retry-fallback expression in an isolated source build. The same real HTTP 520 recovery then lost spawn discovery and executed no peer. The reviewed expression was restored, the clean candidate rebuilt, and the after proof rerun with assertions:
The fallback control used a distinct configured provider/model and the real fallback owner; its trace selected the backup and completed successfully. The driver asserted both negative controls and the positive effects, then cleaned up its disposable Gateway/state. Temporary builds and proof files are not committed.
Regression, quality, review, and CI
report_only; candidate passes. Genuine fallback, absent fallback reason, disabled tools and restricted allowlists remain covered.git diff --checkpassed. Candidate build passed.Limits: the real transport proof uses a synthetic HTTP service, not an external paid model API. Codex/CLI physical attempts remain mocked regression coverage, not claimed live-provider proof. The installed Gateway was never modified or restarted. This evidence addresses ClawSweeper's requested recovered discovery and real session-tool execution; fresh bot review is pending.
Maintainer verification on the unchanged head
Independently verified
1e88389059cb23bd42e1f8fd63bb70157ba2fa8dagainst maine0d16ecdd58187a389bf7fb8722de6fb07e8c2a6in isolated Docker Gateways built from both revisions. The parent actually calledsessions_spawn, yielded, and received its child's successful completion. A recording provider returned one HTTP 503 on the resulting native requester-settle turn.sessions_send,sessions_spawn,sessions_yieldsessions_yieldonlysessions_send,sessions_spawn,sessions_yieldBoth Gateways logged
transient same-model retry 1/8 ... reason=server_error. The candidate completed the requester-settle turn successfully.Live provider gate: repeated the real parent/child lifecycle on the exact candidate. The recording proxy injected one 503, then forwarded the retry to OpenAI
gpt-4.1-mini. That request retained all three tools, returned HTTP 200, and the Gateway emittedP163020_COMPLETION_OKwithstopReason=stop. Exactly one real OpenAI request; utility model, heartbeat, cron, session observer, memory search and compaction memory-flush jobs were disabled. The parent/child setup responses were synthetic; the recovered completion response came from OpenAI.Regression: the existing completion regression group passed 13/13 on the candidate (31.16 s Vitest, 46.53 s wrapper wall). Applying those tests to the pinned main runtime produced 9 failures / 4 passes, including the same-model cases receiving
report_onlyinstead offull(29.38 s Vitest, 44.79 s wrapper wall). Both runtime builds passed. No product-code changes or CI reruns were needed.No overlap with Pash/Sarah changes: neither author has commits on these three changed files in the inspected main history. Thanks to @stackingrockss for reporting the defect, implementing the owner-level repair, and supplying the regression coverage.