Repository navigation
refactor(agents): simplify failed-turn settlement and Codex fixtures - #135833
Conversation
Consolidate preflight, provider-facet, and fallback settlement without changing ordering, presentation, or post-compaction attribution. Remove unused synthetic lifecycle history and waiter state. Maintainer-requested follow-up to #135577; no policy-text or incognito-contract changes.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed September 1, 2026, 11:16 PM ET / September 2, 2026, 03:16 UTC. ClawSweeper reviewWhat this changesThe PR centralizes shared failed-turn settlement in one typed helper and removes unused bookkeeping from the Codex lifecycle test harness. Merge readinessKeep open for normal maintainer review: this fresh, maintainer-labelled cleanup has no introduced correctness or security defect in the reviewed diff, and current main has not changed either touched path since the PR’s merge base. Priority: P3 Review scores
Verification
How this fits togetherAgent-turn errors are classified and settled into a lifecycle terminal event, reply-operation outcome, and model-patch result. The Codex fixture simulates native thread lifecycle requests so integration tests can exercise OpenClaw’s real client-side protocol handling. flowchart LR
A[Agent turn error] --> B[Failure classification]
B --> C[Failure settlement]
C --> D[Lifecycle terminal event]
C --> E[Reply operation]
C --> F[Model patch]
G[Codex lifecycle fixture] --> H[Native thread protocol]
H --> I[Integration tests]
Decision needed
Why: Repository policy keeps maintainer-authored and protected-label PRs open for explicit maintainer handling even when the review finds no defect. Before merge
Agent review detailsSecurityNone. PR surfaceSource -4, Tests -6. Total -10 across 2 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Retain one local settlement path for the three equivalent final-failure branches while preserving the intentionally distinct abort, restart, compaction, and retry flows. Do we have a high-confidence way to reproduce the issue? Not applicable: this is a behavior-preserving refactor, not a report of a separately reproducible user defect. Is this the best way to solve the issue? Yes: the helper absorbs three byte-for-byte-equivalent settlement sequences at their owner boundary, while distinct failure paths remain explicit. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 77a24659740f. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Land-ready review for The final diff changes two files: production −4 lines, test support −6 lines. Settlement ordering, failure metadata, presentation, fixture wire/guards, policy text, and incognito behavior are preserved. Both files remained byte-identical through rebase. Fresh final-diff Codex autoreview found no P0/P1 issues; the latest ClawSweeper review found no correctness/security defects or separate Rank-up moves. Its remaining CI step is now complete. Exact-head CI 33585118125 passed. The ordered baseline/candidate comparison passed 1,258 tests in 47 files on each side; the final retained files match that tested candidate, and the discarded Exact local static command: node scripts/check-changed.mjs --base c4b8d42bd42cdf4ef447bd48dc96abc1fa33c27f -- extensions/codex/src/app-server/thread-lifecycle.test-fixtures.ts src/auto-reply/reply/agent-runner-error-handler.tsExact refreshed-head smoke command: node scripts/run-vitest.mjs extensions/codex/src/app-server/run-attempt.auth-context.test.ts extensions/codex/src/app-server/event-projector.verbose-hooks.test.ts extensions/codex/src/app-server/run-attempt.test.tsThe PR's live qualification remains explicit: stock Codex plus actual OpenAI inference passed all native handoff/ownership assertions in 12 scenarios/28 requests, but one warm-empty model-output canary retained the old marker. That successful native attempt did not invoke the changed failure handler, and the real probe did not use the synthetic fixture. This behavior-neutral cleanup neither introduces nor claims to repair that separate limitation. No policy-format change, forced compaction, unsafe replay, or history rewrite is included. Proceeding through the required native review/prepare/merge gates; no bypass or release action. |
|
Merged via squash.
|
openclaw#135833) Consolidate preflight, provider-facet, and fallback settlement without changing ordering, presentation, or post-compaction attribution. Remove unused synthetic lifecycle history and waiter state. Maintainer-requested follow-up to openclaw#135577; no policy-text or incognito-contract changes.
Related: the stale Codex instruction repair.
What Problem This Solves
Maintainer-requested cleanup following the Codex instruction repair. Failed-turn maintenance required keeping three equivalent settlement paths aligned, while the native lifecycle fixture retained history state and an accessor that no test consumed.
Why This Change Was Made
One local, typed helper now owns the shared final-settlement sequence. The fixture drops only unused bookkeeping; its real-client wire, request recording, loaded/subscribed validation, and lifecycle transitions remain intact.
Production +25/−29 (net −4); test support +1/−7 (net −6). No regression tests were removed. A proposed direct throw inside
finallywas discarded rather than suppressing or circumventingno-unsafe-finally.User Impact
No intended user-visible behavior change. Preflight refusals remain ahead of provider-text classification, visible delivery settles before terminal failure, model-patch failure remains awaited, post-compaction attribution is preserved, and only the existing final fallback branch emits fallback-exhaustion metadata. Policy text, ownership checks, incognito refusal/recovery, persistence, and native protocols are unchanged.
This is not a fix for the separate empty-policy model-adherence limitation described below.
Evidence
main(c4b8d42bd42cdf4ef447bd48dc96abc1fa33c27f) and the cleanup candidate in Blacksmith Testbox run 33580471050. The two retained files are byte-identical to that tested candidate; the discardedfinallychange was restored exactly toHEAD. The separately gated native-MCP live suite was explicitly excluded from the hermetic run. Counts overlap and must not be summed.82bcef85ffef1010e53cac09b4ea0bcea7b68f72; both changed files remained byte-identical. Exact-head PR CI 33585118125 completed successfully at2b817962e6c75356ea32d1124f6b15b47427f3af.The final local static command was:
The refreshed-head smoke command was:
The first broad Mac test attempt hit CLI-test timeouts and subsequent preflight call-count failures after multi-minute imports. The clean Linux baseline/candidate comparison retained ordering, assertions, and timeouts; no assertions were weakened and no timeout was increased. No unsupported OS or package-manager root-cause claim is made.
Live verification qualification
Real OpenClaw hook/admitted-host/lifecycle composition, stock Codex 0.151.0, and actual
gpt-5.6-lunainference exercised 12 scenarios and 28 HTTP requests. The corrected recording relay retained native OpenAI provider semantics and protocol headers, and asserted generic-policy provenance metadata. All native handoff/ownership assertions passed, and all 15 clients and both servers closed.The live model-output result was 11/12, not fully green: one warm empty-policy turn returned the old policy marker even though the request contained empty native configuration and the later explicit withdrawal notice. Replacement, cold withdrawal, incognito refusal/recovery, contention recovery, and compaction checks passed. Earlier custom-provider captures are not treated as default OpenAI proof: stock Codex strips internal metadata for non-OpenAI provider identities.
That finding is recorded for a separate behavioral investigation; this cleanup neither changes the policy producer/carrier nor claims to fix model adherence. The failing canary completed as a successful native attempt, so it did not exercise the changed error-settlement path; the changed fixture bookkeeping is not used by the real native probe. No policy-format change, forced compaction, replay, or history rewrite is introduced here. The task credential stayed in the recording relay and was never passed to the native environment or persisted; the credential window and Testbox lease were closed.
Pinned dependency source personally checked at
78c290807ce710180111df227df3b7a4fe845452: generic context versus later-turn differences, history injection, loaded-resume ownership, and provider-specific metadata stripping.