Skip to content

fix(agents): describe settled recovery by behavior - #185351

Merged
steipete merged 2 commits into
mainfrom
dbasync/finalizer
Oct 27, 2026
Merged

steipete merged 2 commits into
mainfrom
dbasync/finalizer

Conversation

@steipete

@steipete steipete commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A turn can finish its side effects and still fail before producing a final answer. Keep the passive recovery that delivers that answer and its artifact, but stop telling the model that tools are unavailable: stock native Codex can advertise apply_patch even in the restricted, no-environment recovery turn. Advertisement is not execution.

User Impact

Completed work still gets a recovered answer and artifact without repeating effects. Recovery remains passive, with all existing execution and result guards. No configuration or migration is needed.

Why This Change Was Made

This replaces the two misleading sentences with “Do not call tools in this step. Summarize the recorded results in plain text.” The remaining instructions and every execution/result guard stay intact. The Telegram production-path fixture now identifies recovery by request order and the completed tool call ID, and asserts exactly-once effects and delivery instead of a tool catalog or prompt phrase. The native live branch retains its action, summary, binding, and transcript assertions. Existing mock fixtures and the nine QA scenario markers follow the new wording; their effect, cutoff, failure, and delivery assertions remain intact.

#141705 added the old sentence to prevent denied tool calls from discarding an otherwise valid answer. That remains the reason for a clear no-tools behavioral instruction and strict result validation. #185173 demonstrated that native Codex still advertises apply_patch; its forced-patch rejection regression is preserved unchanged. No upstream Codex change, new capability, schema change, or guard relaxation.

Preregistered acceptance (before measurements)

Flow: existing synthetic Telegram write → provider overload → passive recovery → authored final and uploaded artifact through an isolated Gateway, native Codex transport, and synthetic provider/Telegram endpoints. Require exactly one original write, one injected overload, one recovery request carrying the same call ID, one marker answer, one exact-byte file delivery, no new/repeated tool effects, preserved inter-session provenance, and no duplicates after Gateway shutdown. Embedded cutoff/result/transport/delivery tests and prefix-stability must remain green. Normal completed warm turns must not gain a recovery attempt.

Workload: frozen sqlharness v3.1.5, verified against its frozen hashes, one baseline invocation followed by one candidate invocation on this Mac, one repetition each, using the ten warm turns per invocation. Cold/boot/restart phases are reported separately from warm. Report statements, requests and Gateway MAIN median [min–max] and p95; compare per-operation counts. Any new Gateway MAIN work or attributable extra operation is a regression; a 20% adverse cell movement stops acceptance pending attribution. No latency or CPU claim; this is a wording/test-contract correction with expected unchanged work, not a SQL optimization. Counts are the evidence; wall-clock sample size is intentionally insufficient for timing claims.

Evidence

Validation: 287 focused tests passed (including 13 prefix-stability cases, the native forced-patch rejection, and embedded cutoff/result/transport/delivery coverage). The optional credentialed native live case is not counted as proof. The synthetic Telegram production path passed on the final head in CI job 121983439469; its exactly-once and delivery assertions all passed. The corrected subagent recovery scenario passed in job 121983438347. The frozen count pair passed; detailed counts and phase attribution are below. No timing claim is made. Exact-head CI run 40441545305 passed, including the synthetic Telegram E2E, QA smoke, types and lint. Locally, check:changed completed: 36 checks passed; its type/extension-lint checks refused the mandated external dependency store at the declaration-custody boundary, and Knip reported one untouched browser export, reproduced identically by both baseline scans: extensions/browser/src/browser/client.types.ts: BrowserGraphicsDevice (production 1→1, full-tree 1→1, scripts 0→0). No guard bypass. Runtime import cycles: 0; full Madge check: 0 cycles. T1 168→168, compatibility 15→15, dialect 0→0. Two isolated Codex P0–P2 reviews completed with no actionable findings; each assessed the supplied patch, with unchanged routing implementation outside its context. A third, delta-only review covers the CI-driven test corrections. CI identified a stale QA scenario marker and an overly strict global request-adjacency assertion. Recovery is now required exactly once for the same completed call after the overload, allowing unrelated model requests to interleave. Production is still only two sentence replacements. Final diff: 17 files, +34/-53 (net -19 lines). No SDK surface or PostgreSQL-reachable SQL changes.

Open-main-PR overlap: shared PR-index refresh plus base-only versus candidate git merge-tree comparisons found no added conflict paths or blocks. Peer PRs and conflict-path counts (base→candidate): #185310 0→0, #184434 0→0, #170846 1→1, #165379 39→39, #156181 14→14, #153758 2→2, #147611 8→8, #139929 4→4. Every peer head matched the refreshed index; marker counts also did not rise.

Frozen counts

Frozen v3.1.5 verified: 37 files, zero hash mismatches. One sequential baseline/candidate pair on the same Mac; ten warm turns each. Baseline 8e70778f2021ff4f87af712834af665f8d0932cb, candidate 4996f75f8274de860ad7706b5f934eea4418af03. Both workloads passed; causal coverage available with no missing warm-turn coverage. Counts only: no latency, CPU, or throughput claim.

Warm metric Baseline median [min–max]; p95 Candidate median [min–max]; p95
Turn-caused: turn_statements 45 [45–48]; 48 45 [45–48]; 48
Turn-caused: turn_requests 12 [12–13]; 13 12 [12–13]; 13
Turn-caused: turn_main 0 [0–0]; 0 0 [0–0]; 0
Execution window: sql 45 [45–63]; 63 45.5 [45–49]; 49
Execution window: requests 12 [12–17]; 17 12 [12–15]; 15
Execution window: main 0 [0–0]; 0 0 [0–0]; 0

All ten paired turn-caused samples match: first turn 48 SQL/13 requests, remaining nine 45/12, Gateway MAIN zero throughout. Worker-thread SQL is also identical. No relocation or SQL saving is claimed.

Warm execution-window operation totals (SQL/requests; MAIN is zero for every operation):

Operation Baseline Candidate Δ SQL / requests
AsyncLocalStorage.enterAsyncStore 0/10 0/10 +0/+0
NO_REQUEST / AsyncLocalStorage.enterAsyncStore 3/0 4/0 +1/+0
UNKNOWN 5/2 0/0 -5/-2
appendSqliteTrajectoryRuntimeEventsWithWriter 13/10 13/10 +0/+0
applyPreparedSessionActorAdoption 10/10 10/10 +0/+0
batch 110/10 110/10 +0/+0
commitSessionEntryPatch 40/10 40/10 +0/+0
pluginState.loadNamespace 0/0 2/2 +2/+2
plugins.catalogSnapshot.write 1/1 1/1 +0/+0
plugins.metadata.index.refresh 9/0 0/0 -9/+0
prepareMessageRewrite 110/10 110/10 +0/+0
prepareTranscriptPayload 100/10 100/10 +0/+0
prewarm 0/1 0/0 +0/-1
project 0/1 0/1 +0/+0
record-run 10/10 10/10 +0/+0
recordProviderPrompt 0/10 0/10 +0/+0
scan 0/1 0/0 +0/-1
session-pending-input-source 10/10 10/10 +0/+0
sessionUpstream.listWatched 1/1 1/1 +0/+0
statement 10/10 10/10 +0/+0
trackSessionEntryCacheWrite 40/10 40/10 +0/+0

Other phases remain separate from warm (SQL/requests/Gateway MAIN):

Phase Baseline Candidate
01.boot 303/97/52 555/130/52
01.connect 33/8/0 52/13/0
02.first-turn 456/95/0 206/62/0
04.second-session 462/112/0 464/112/0
05.control-plane 7/1/0 7/1/0
06.cron 231/64/0 223/61/0
07.compaction 100/19/0 100/19/0
07.idle-settle 46/7/0 143/19/0
07.idle-connected 195/47/0 94/35/0
08.shutdown 21/7/5 21/7/5
09.restart-boot 330/118/38 324/115/38
09.restart-connect 33/15/0 62/16/0
10.restart-first-turn 170/48/0 136/45/0
11.restart-shutdown 26/9/5 21/7/5

The >20% adverse raw phase moves stopped acceptance for attribution. agent.worker.open moves 183 SQL from first-turn to boot but totals exactly 183 SQL/2 requests on both heads. installStatusTracking moves 30 SQL/1 request from restart-first-turn to restart-connect, unchanged in total. Memory-index work moves from idle-connected to idle-settle: database.publish 42/1, source.replace.group 25/1, vector.ensure 8/1, cache count 4/1, cache prune 3/1 and metadata write 2/1 are identical overall; session-entries is 15/2 on both. Combined cold boot/connect/first-turn is 792/200/52 → 813/205/52, combined idle phases 241/54/0 → 237/54/0, restart boot/connect/first-turn 533/181/38 → 522/176/38. Remaining window deltas are existing background/plugin operations; every warm turn-caused sample and all recurring warm owner-operation counts match. Acceptance uses this attribution, not a “within spread” claim.

Whole-workload totals: 2885 SQL/774 requests/100 Gateway MAIN → 2869/767/100 (includes boot and shutdown). Unnamed-operation attribution remains 9 SQL and 11→10 requests; these are included in totals, and no complete named attribution is claimed. The two runtime sentence replacements do not add SQL, requests, or execution paths.

@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 27, 2026 02:43
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T03:00:33.432944Z 4996f75 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 27, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 27, 2026
@clawsweeper

clawsweeper Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR describes settled recovery as a plain-text summarization step and updates fixtures to check recovery behavior rather than advertised tools.

Example: Recovery follows the completed write of qa-empty-response-side-effect.txt while native Codex advertises apply_patch.

  • Before: The recovery instruction says tools are unavailable despite the advertised tool.
  • After: The instruction says not to call tools and to summarize recorded results in plain text.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and source-supported; supplied validation supports the contracts but does not yet establish the declared runtime acceptance result.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its complete body explicitly leaves the Gateway recovery acceptance run pending, and prior-PR results do not establish this head's runtime outcome.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Recovery can receive instructions that contradict the tools advertised by its native runtime while trying to deliver an answer after completed work.
Reason: The maintainer-authored direction accurately describes the existing restriction and preserves the reason for the earlier no-tools instruction.

Merge readiness

✅ Ready for maintainer review

This PR makes a useful, narrowly scoped correction to recovery instructions without weakening execution guards; no introduced correctness or security defect was found.

Priority: P3
Reviewed head: 4996f75f8274de860ad7706b5f934eea4418af03

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The declared post-change Gateway overload-to-recovery artifact run remains pending, and no behavioral red/green result for the wording change is supplied.
Agent review details

How this fits together

The agent runner selects recovery after completed tool work lacks a final answer, passes recorded results to an isolated harness, and validates the resulting answer before delivery.

flowchart TD
  A[Completed tool work] --> B[Missing final answer]
  B --> C[Recovery instruction]
  C --> D[Isolated finalizer]
  D --> E[Result validation]
  E --> F[Answer and artifact delivery]
Loading

Technical review

Best possible solution:

Keep the behavioral instruction at the existing recovery owner while preserving isolation, strict result validation, and effect-based delivery coverage.

Do we have a high-confidence way to reproduce the issue?

The mismatch is source-reproducible: current main claims tools are unavailable while pinned native Codex can advertise apply_patch without an execution environment; this review ran no target code.

Is this the best way to solve the issue?

The two sentence replacements are the smallest complete correction, and the fixture changes retain independent execution, provenance, and delivery assertions without adding machinery.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 30210d90e39f.

Provenance checked

  • Settled recovery instructions changes intended behavior with a stated reason (160bd6a: Explicitly discourage tool calls so denied capability activity cannot discard an otherwise valid summary.)
  • Required-result and silence instructions keeps the original intent (bd5f760: Distinguish deliberate silence from missing required output without fabricating completion.)
  • Recovered artifact and provenance coverage keeps the original intent (f6f939a: Preserve accepted recovered answers and outstanding artifacts independently of transcript completion.)
  • Native catalog assertions changes intended behavior with a stated reason (d731fbb: Accept advertised native apply_patch while proving execution is rejected before changing sentinel bytes.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 4601114 adds src/agents/embedded-agent-runner/run/incomplete-turn-recovery.ts:391 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4601114c7fbd; files: src/agents/embedded-agent-runner/run/incomplete-turn-recovery.ts)

PR surface

Source 0, Tests -19, Other 0. Total -19 across 17 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 3 3 0
Tests 6 22 41 -19
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 9 9 9 0
Total 17 34 53 -19

Labels

Label changes:

  • add P3: This is a bounded instruction and fixture correction with unchanged execution and delivery policy.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: This is a bounded instruction and fixture correction with unchanged execution and delivery policy.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 26, 2026, 11:15 PM ET / October 27, 2026, 03:15 UTC.

@steipete
steipete merged commit 9b69228 into main Oct 27, 2026
175 of 178 checks passed
@steipete
steipete deleted the dbasync/finalizer branch October 27, 2026 03:55
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 27, 2026
Keep passive recovery for completed tool work that ends without a final reply. Replace the two inaccurate tool-availability sentences with an instruction to summarize recorded results without calling tools.

Verify recovery through exactly-once effects, the recovered answer and artifact delivery instead of tool catalogs or prompt text. Preserve existing execution/result guards and the forced-patch rejection regression.

Refs openclaw#141705, openclaw#185173.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling extensions: codex extensions: qa-lab P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant