Skip to content

fix(agent): finalize settled turns when harness callback is absent - #137887

Closed
ajmtrz wants to merge 2 commits into
openclaw:mainfrom
ajmtrz:fix/settled-post-tool-finalization-unavailable
Closed

ajmtrz wants to merge 2 commits into
openclaw:mainfrom
ajmtrz:fix/settled-post-tool-finalization-unavailable

Conversation

@ajmtrz

@ajmtrz ajmtrz commented Sep 4, 2026 •

Copy link
Copy Markdown

Summary

What Problem This Solves

Codex can complete a turn after tool side effects without emitting a final assistant message. Current main recovers this when a tool-free finalizer is available, including truncated completion streams after commentary. A distinct gap remained when the selected harness exposed no finalizeSettledTurn callback: OpenClaw returned not-attempted before reaching its existing safe host fallback.

This refresh keeps the merged available-finalizer behavior and removes only that stale availability precondition.

Why Each Change Exists

  • Request resolution: removes the precondition so an absent callback reaches the existing host-owned fallback; terminal assistant errors remain excluded.
  • Persistence fencing: detached sessions never append a transcript; superseded writers and unresolved targets still fail closed.
  • Cancellation boundary: cancellation before persistence suppresses the outcome; after a successful append, the committed idempotency key remains authoritative so durable state and delivery cannot disagree.
  • Tests: true callback absence, not merely a throwing callback, proves durable, detached, pre-append, and post-append behavior. The integration matrix crosses real SQLite and the production reply dispatcher.
  • Documentation: states the optional-callback and pre/post-commit contracts without suggesting tool replay.

User Impact

A settled tool turn no longer ends silently merely because its harness omits the optional finalizer. OpenClaw emits the deterministic no-model fallback once, while preserving deliberate silence, failure-honest terminal errors, detached non-persistence, and cancellation semantics.

Evidence

  • exact head: 601c46ccf71224c6a5b20c6040009cd4e19fbc35
  • real SQLite → source dispatcher integration: 19/19
  • related settled-finalization and terminal-resolution matrix: 85/85
  • combined fresh local run: 123/123 across five requested test files
  • pnpm check:changed: exit 0
  • pnpm build: exit 0
  • git diff --check origin/main...HEAD: exit 0
  • independent Cursor review on exact head: NO_MATERIAL_FINDINGS
  • Codex protocol inspected directly: item/completed applies item-side effects separately; turn/completed may contain no loaded assistant items
  • current-main relation: fix: truncated OpenCode Go completions stream after tools reports a generic agent failure #140367 / 04081aa1361d6a4097d0b489126a737481220f53 is preserved and remains an ancestor

Scope and Risk

  • no configuration, migration, provider, or tool-execution change
  • no model/tool/attempt replay
  • production change remains concentrated in terminal request resolution and fallback persistence
  • added test-support module only keeps the real integration harness within repository size limits

@clawsweeper

clawsweeper Bot commented Sep 4, 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 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-09-04T12:46:38.249175Z f3705e7 Manual request
ℹ️ 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Sep 4, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3590b70f21

ℹ️ 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".

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".

@@ -102,8 +102,6 @@ export async function prepareTerminalWithSettledTurnFinalization(input: {
prepared.recoveredFinalAssistantPayloadsAfterPromptTimeout,
hasTerminalToolPresentation: input.finalization.hasTerminalToolPresentation,
terminalState: initial.terminalState,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Skip durable fallback writes for detached runs

When sessionPersistence is "detached" and a third-party harness omits the optional finalizer, this newly enters the fallback path. The orchestrator still supplies the resolved durable session identity, and persistSettledToolFallbackTranscript() writes through it without checking sessionPersistence, violating the contract in src/agents/embedded-agent-runner/run/params.ts:98-99 that detached runs never write durable transcript state. If the borrowed session row exists, an ephemeral/helper run can therefore leak this fallback into the durable conversation; skip mirror persistence for detached runs and cover the absent-callback case.

Useful? React with 👍 / 👎.

Comment thread docs/plugins/sdk-agent-harness.md Outdated
tools. Canonical failed-tool metadata remains attached to the terminal result.
Runs with `silentExpected` never synthesize or persist this fallback.

Cancellation remains terminal and does not produce the fallback. Finalization

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Make fallback persistence cancellation-atomic

When the callback is absent and cancellation arrives after appendAssistantMirrorMessageByIdentity() commits its append but before its post-append abort check, the resulting abort is swallowed by persistSettledToolFallbackTranscript() and the outer function returns the original cancelled attempt, while the fallback remains durably visible in the transcript. This contradicts the new cancellation guarantee; make persistence/building cancellation-atomic or retain the committed outcome, and test a committed append followed by cancellation rather than only an ok: false mock.

AGENTS.md reference: AGENTS.md:L135-L135

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

The branch lets settled tool turns receive a deterministic fallback when their agent harness lacks a final-summary callback, and adjusts transcript handling, regression coverage, and harness documentation.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The fix remains useful, but unchanged correctness blockers and partial mocked proof prevent merge readiness.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) 4 actionable review findings remain.

Merge readiness

⛔ Blocked before merge - 7 items remain

This PR still addresses a distinct missing-callback gap on current main and the latest release. Maintainer discussion supports retaining it, but all four prior findings remain unresolved.

Priority: P2
Reviewed head: 69eac3e84f8e2e85545c15105352bf5609d31b77

Before merge

  • Add real behavior proof - The changed finalization owner is covered with real SQLite and the production dispatcher, but reply resolution and delivery are substituted and outer cancellation settlement is bypassed. Supply redacted after-fix runtime output through actual settlement and delivery, including both post-append cancellation intervals; terminal traces or logs are sufficient. Remove keys, IP addresses, phone numbers, private endpoints, and user data. Updating the PR body should trigger review; otherwise ask a maintainer to comment @clawsweeper re-review. No stored-data format or schema changes are introduced. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Carry committed fallback state through outer cancellation (P2) - The changed guard retains the fallback after a successful append even when the queue signal is aborted, but no committed-outcome fact reaches the outer owners. run-entry.ts:634–640 refuses accepted terminal work on that signal, and settleAgentFallbackCycle() returns aborted before committing the outcome. A normal channel turn can therefore retain a durable assistant row while dropping its reply. Carry commitment through those owners while preserving pre-commit cancellation.
  • Capture commitment before transcript notification can abort (P2) - appendAssistantMirrorMessageByIdentity() awaits the actual append, then checks cancellation before publishing the transcript update and returning ok. Cancellation in that interval leaves a committed row but throws into this function's catch, which returns no key. Consequently the new success check never sees the commitment and cancellation discards the fallback. Expose the committed fact before cancellable notification; the added integration aborts only after the entire helper returns and misses this interval.
  • Scope fallback idempotency to the admitted turn (P2) - Removing the availability guard exposes missing-callback turns to persistence keyed only by runId. Admission explicitly permits different operational instances with the same run ID, and transcript replay ignores timestamps. Two such turns in one session can match the fixed fallback text and reuse the first row while the second reply is marked transcript-owned. Include immutable admitted-turn identity while retaining same-turn retry deduplication.
  • Remove the retired availability argument from the remaining caller (P2) - This interface removal leaves terminal-resolution.settled-request.test.ts:246 passing settledTurnFinalizationAvailable in a directly typed object literal. TypeScript rejects the excess property, so the caller cutover is incomplete and test typechecking fails. Remove that remaining argument.
  • Resolve merge risk - The recorded head conflicts with current main; conflict resolution needs fresh review and validation preserving newer cron silence, delivery ownership, and terminal recovery behavior.
  • Complete next step - Resolve the four findings and current-main conflicts, then add after-fix evidence through actual settlement and delivery.

Findings

  • [P2] Carry committed fallback state through outer cancellation — src/agents/embedded-agent-runner/run/settled-turn-finalization.ts:236
  • [P2] Capture commitment before transcript notification can abort — src/agents/embedded-agent-runner/run/settled-turn-finalization.ts:580-584
  • [P2] Scope fallback idempotency to the admitted turn — src/agents/embedded-agent-runner/run/settled-turn-finalization.ts:543
Agent review details

How this fits together

Agent harnesses execute model turns and report completed tool work to OpenClaw. Terminal recovery converts those results into transcript entries and replies that the channel dispatcher can deliver.

flowchart TD
 A[Completed tool work] --> B[Terminal recovery]
 B --> C[Final-summary callback available]
 C -->|Yes| D[Tool-free summary]
 C -->|No or failed| E[Deterministic fallback]
 E --> F[Transcript commitment]
 D --> G[Outer settlement]
 F --> G
 G --> H[Channel reply]
Loading

Technical review

Best possible solution:

Use one committed terminal outcome across transcript persistence, cancellation settlement, and delivery, with deduplication scoped to the admitted turn.

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

Yes, source establishes the missing-callback early return and the remaining cancellation and deduplication failures. No runtime reproduction was executed during this read-only review.

Is this the best way to solve the issue?

The existing host fallback is the right owner, but the patch is incomplete: commitment must survive transcript notification and outer settlement, and its key must distinguish admitted turns.

Full review comments:

  • [P2] Carry committed fallback state through outer cancellation — src/agents/embedded-agent-runner/run/settled-turn-finalization.ts:236
    The changed guard retains the fallback after a successful append even when the queue signal is aborted, but no committed-outcome fact reaches the outer owners. run-entry.ts:634–640 refuses accepted terminal work on that signal, and settleAgentFallbackCycle() returns aborted before committing the outcome. A normal channel turn can therefore retain a durable assistant row while dropping its reply. Carry commitment through those owners while preserving pre-commit cancellation.
    Confidence: 0.98
  • [P2] Capture commitment before transcript notification can abort — src/agents/embedded-agent-runner/run/settled-turn-finalization.ts:580-584
    appendAssistantMirrorMessageByIdentity() awaits the actual append, then checks cancellation before publishing the transcript update and returning ok. Cancellation in that interval leaves a committed row but throws into this function's catch, which returns no key. Consequently the new success check never sees the commitment and cancellation discards the fallback. Expose the committed fact before cancellable notification; the added integration aborts only after the entire helper returns and misses this interval.
    Confidence: 0.98
  • [P2] Scope fallback idempotency to the admitted turn — src/agents/embedded-agent-runner/run/settled-turn-finalization.ts:543
    Removing the availability guard exposes missing-callback turns to persistence keyed only by runId. Admission explicitly permits different operational instances with the same run ID, and transcript replay ignores timestamps. Two such turns in one session can match the fixed fallback text and reuse the first row while the second reply is marked transcript-owned. Include immutable admitted-turn identity while retaining same-turn retry deduplication.
    Confidence: 0.96
  • [P2] Remove the retired availability argument from the remaining caller — src/agents/embedded-agent-runner/run/terminal-resolution.ts:116-119
    This interface removal leaves terminal-resolution.settled-request.test.ts:246 passing settledTurnFinalizationAvailable in a directly typed object literal. TypeScript rejects the excess property, so the caller cutover is incomplete and test typechecking fails. Remove that remaining argument.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 314bae176cb5.

Merge-risk options

Maintainer options:

  1. Repair and refresh the existing branch (recommended)
    Resolve current-main conflicts and carry commitment through the actual settlement owners before validating transcript and delivery agreement.
  2. Pause landing while retaining the contribution
    Keep this distinct fix open until the contributor supplies the corrected settlement behavior and after-fix runtime evidence.

Security

None.

Evidence

What I checked:

PR surface

Source +3, Tests +321, Docs +5. Total +329 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 2 17 14 +3
Tests 6 407 86 +321
Docs 1 7 2 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 431 102 +329

Review metrics

Metric Value Why it matters
Production versus test growth production net +3 lines; tests and support net +321 lines Production growth is justified by lifecycle handling, but the larger test addition still bypasses the cancellation settlement it claims to prove.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded agent-recovery defect affecting turns whose harness lacks the optional finalizer.
  • merge-risk: 🚨 session-state: Cancellation and reused run IDs can leave durable fallback rows inconsistent with the admitted turn's outcome.
  • merge-risk: 🚨 message-delivery: Outer cancellation settlement can suppress a fallback already committed to the transcript.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Preserve append commitment through transcript notification and outer cancellation settlement.
  • Scope deduplication to the admitted turn and remove the stale test argument.
  • Provide redacted after-fix settlement and delivery evidence with cancellation and writer-replacement controls.

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.

History

Review history (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-04T20:47:46.915Z sha f3705e72e960cc363f537a528c5b43abc205c289 :: needs real behavior proof before merge. :: [P2] Carry a committed fallback through outer cancellation | [P2] Publish the committed fallback transcript update | [P2] Scope fallback idempotency to an admitted turn
  • reviewed 2026-09-08T15:14:53.574Z sha 601c46ccf71224c6a5b20c6040009cd4e19fbc35 :: needs real behavior proof before merge. :: [P2] Carry committed fallback state through outer cancellation | [P2] Retain commit evidence before the transcript helper can abort | [P2] Scope fallback idempotency to the admitted turn
  • reviewed 2026-09-08T16:52:39.304Z sha 2ed37d1bc04c02abff9d8e5dda452a859788a58a :: needs real behavior proof before merge. :: [P2] Carry committed fallback state through outer cancellation | [P2] Retain commitment before transcript notification can abort | [P2] Scope fallback idempotency to the admitted turn
  • reviewed 2026-09-08T17:45:28.309Z sha 609eaf35f816d5de7ed971a48c9c460f93dbb518 :: needs real behavior proof before merge. :: [P2] Carry committed fallback state through outer cancellation | [P2] Retain commitment before transcript notification can abort | [P2] Scope fallback idempotency to the admitted turn
  • reviewed 2026-09-09T11:11:41.474Z sha d11773d :: needs real behavior proof before merge. :: [P2] Carry committed fallback state through outer cancellation | [P2] Retain commitment before transcript notification can abort | [P2] Scope fallback idempotency to the admitted turn
  • reviewed 2026-09-12T18:03:16.136Z sha 69eac3e :: needs real behavior proof before merge. :: [P2] Carry committed fallback state through outer cancellation | [P2] Capture commitment before transcript notification can abort | [P2] Scope fallback idempotency to the admitted turn | [P2] Remove the retired availability option from the remaining caller
  • reviewed 2026-09-21T22:54:49.081Z sha 69eac3e :: needs real behavior proof before merge. :: [P2] Carry committed fallback state through outer cancellation | [P2] Capture commitment before transcript notification can abort | [P2] Scope fallback idempotency to the admitted turn | [P2] Remove the retired availability argument from the remaining caller
  • reviewed 2026-09-26T06:59:18.899Z sha 69eac3e :: needs real behavior proof before merge. :: [P2] Carry committed fallback state through outer cancellation | [P2] Capture commitment before transcript notification can abort | [P2] Scope fallback idempotency to the admitted turn | [P2] Remove the retired availability option from the remaining caller

Reviewed October 2, 2026, 9:30 PM ET / October 3, 2026, 01:30 UTC (Revision 10).

@ajmtrz

ajmtrz commented Sep 4, 2026

Copy link
Copy Markdown
Author

Updated the branch at f3705e72e960cc363f537a528c5b43abc205c289 to address both P2 review findings and add real integration evidence.

What changed

  • Detached runs no longer persist the synthesized fallback into the durable transcript.
  • Cancellation before the transcript append remains cancellation and neither persists nor delivers the fallback.
  • Cancellation after a successful append retains the already-committed terminal outcome, so durable state and the returned result cannot disagree.
  • Writer fencing and idempotency prevent stale or duplicate fallback persistence.
  • The implementation does not replay model calls, tools, or other effects.

Evidence

  • RED on the exact base commit (194b7f2a16): the missing-finalizer unit regression failed 6/6 cases; the prepared-harness integration test failed the 4 new boundary cases.
  • GREEN on this SHA: missing-finalizer regression 6/6; real prepared-harness path 19/19.
  • Fresh focused run: 4 test files, 91/91 tests passed.
  • Wider focused/sibling matrix: 403/403 tests passed.
  • pnpm check:docs, pnpm check:changed, pnpm check, pnpm check:test-types, and pnpm build passed with pnpm 12.1.0.
  • The full local suite still has host-dependent failures outside this six-file diff (missing host executables, read-only home/systemd fixtures); representative failures reproduce on the exact base commit. No failure maps to a changed file.
  • Independent read-only Cursor review of the final behavior returned NO_MATERIAL_FINDINGS.

Please re-review the updated SHA, especially the detached and pre/post-append cancellation boundaries.

@codex review

@sylvesterkaczmarek sylvesterkaczmarek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct terminal boundary. An absent finalizer should enter the same deterministic no-model fallback as an exhausted finalizer, while silence, cancellation and persistence fencing remain authoritative. This avoids replaying settled tools.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f3705e72e9

ℹ️ 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".

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".

sessionTarget: committedSessionTarget,
})
: undefined;
if (!transcriptIdempotencyKey && input.finalization.abortSignal.aborted) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the committed fallback through outer cancellation

When a normal channel turn is cancelled after the transcript append commits, this check lets the helper return the fallback, but the outer lifecycle still sees the same aborted signal: src/agents/embedded-agent-runner/run-entry.ts:581-590 declines the accepted terminal and src/auto-reply/reply/agent-runner-fallback-settlement.ts:47-51 returns aborted before committing the outcome. Fresh evidence in this update is that the new integration invokes the helper directly and calls setNoAbort(), bypassing those production checks. The race therefore still leaves a durable assistant row while the channel run drops its returned/delivered payload; carry the committed-append fact through the outer cancellation owner.

AGENTS.md reference: AGENTS.md:L45-L48

Useful? React with 👍 / 👎.

@@ -509,6 +510,9 @@ async function persistSettledToolFallbackTranscript(input: {
idempotencyKey,
signal: input.abortSignal,
text: SETTLED_TOOL_FINALIZATION_FALLBACK_TEXT,
// The append commit owns the cancellation cutoff. Publishing afterward
// must not turn an already-durable fallback into a cancelled terminal.
updateMode: "none",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Broadcast the committed fallback transcript update

For every durable missing-finalizer fallback, updateMode: "none" makes appendAssistantMirrorMessageByIdentity skip its publishTranscriptUpdate call. The resulting payload is marked assistantTranscriptOwned, so downstream delivery uses mirror: false and does not publish later either. Consequently gateway transcript subscribers and transcript-derived session-list previews remain stale until another transcript mutation or reload; preserve the post-commit cancellation cutoff while still broadcasting the successful append without another abort check.

Useful? React with 👍 / 👎.

sessionTarget: committedSessionTarget,
});
if (input.finalization.abortSignal.aborted) {
const transcriptIdempotencyKey = persistSession

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Scope fallback idempotency to the admitted turn

For the newly enabled missing-finalizer path, two distinct admitted turns in one session can reuse a runId, yet this persistence call ultimately uses only ${runId}:settled-finalization-fallback as its key at src/agents/embedded-agent-runner/run/settled-turn-finalization.ts:494. Because the fallback bytes are fixed and replay comparison ignores timestamps, the second append returns the first row as an idempotent success, while the second reply is delivered and marked transcript-owned without its own durable entry. Include immutable admission/turn identity in the key while retaining same-turn retry deduplication.

AGENTS.md reference: AGENTS.md:L159-L159

Useful? React with 👍 / 👎.

@ajmtrz

ajmtrz commented Sep 4, 2026

Copy link
Copy Markdown
Author

CI completed with 162 successful checks. The only test failure is checks-node-compact-small-44, in unrelated test/scripts/plugin-npm-security-scan.test.ts: the hosted runner reported Plugin npm security scanner could not measure RSS where the fixture expected exceeded its process limit (762 other tests in that shard passed). openclaw/ci-gate only reflects that shard failure.

I attempted both the workflow and job-specific rerun. GitHub rejected the workflow rerun and the job endpoint requires upstream repository admin rights. Could a maintainer please rerun failed jobs for Actions run 33873148803?

The requested Codex re-review on f3705e72e9 completed with no suggestions, and the maintainer review comment confirms the terminal boundary behavior.

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. label Sep 4, 2026
@VACInc

VACInc commented Sep 6, 2026

Copy link
Copy Markdown
Member

Related merge: #140367 landed in main on September 6, 2026 (04081aa). It aligns commentary-aware recovery-context capture with the downstream synthetic provider-error payload gate, allowing an available tool-free finalizer to run after a truncated completions stream.

It does not remove the early return when finalizeSettledTurn is unavailable or implement the absent-callback host fallback proposed here. These are distinct reasons finalization can return not-attempted. Leaving this PR open; it is not superseded by #140367.

@ajmtrz
ajmtrz force-pushed the fix/settled-post-tool-finalization-unavailable branch from f3705e7 to 601c46c Compare September 8, 2026 15:06
@ajmtrz

ajmtrz commented Sep 8, 2026

Copy link
Copy Markdown
Author

Thanks for clarifying the boundary and for landing #140367. I rebased this PR onto current main and retained that finalizer-available truncated-stream recovery unchanged.

The refreshed diff now isolates the distinct case you identified: when finalizeSettledTurn is genuinely absent, request resolution reaches the existing deterministic host fallback instead of returning not-attempted.

The refresh also makes the lifecycle contract explicit:

  • no model, tool, or attempt replay;
  • detached sessions deliver without transcript persistence;
  • cancellation before append suppresses persistence and delivery;
  • cancellation after a successful append preserves the committed idempotent outcome and delivers it once;
  • terminal tool errors and deliberate silence remain authoritative.

Fresh proof on 601c46ccf71224c6a5b20c6040009cd4e19fbc35: 19/19 real SQLite-to-dispatch integration cases, 85/85 related finalization/terminal tests, check:changed, build, and diff check all pass. Independent Cursor review returned no material findings.

@ajmtrz
ajmtrz force-pushed the fix/settled-post-tool-finalization-unavailable branch from 601c46c to 2ed37d1 Compare September 8, 2026 16:45
@ajmtrz

ajmtrz commented Sep 8, 2026

Copy link
Copy Markdown
Author

Rebased again onto current main (8d79c6ab2c3dd3db8716bec325a4d846d3ce34c5) and force-pushed 2ed37d1bc04c02abff9d8e5dda452a859788a58a.

To reduce review load, the branch is now a single commit with no orchestration ledgers or intermediate planning commits. The remaining delta is specifically the absent-callback boundary: settled post-tool work receives the deterministic host fallback when finalizeSettledTurn is unavailable, without replaying tools or effects.

The refresh preserves the newer upstream delivery policy:

  • message_tool_only: synthetic fallback remains private;
  • automatic: fallback is source-deliverable;
  • real tool failures and deliberate silence remain unchanged;
  • pre-append cancellation suppresses persistence/delivery;
  • post-append cancellation preserves the committed idempotent delivery.

Fresh evidence on the rebased SHA:

  • related tests: 74/74;
  • pnpm check:changed: pass, including production and test typechecks;
  • full build: pass;
  • git diff --check: pass;
  • independent read-only review: no material findings.

@ajmtrz
ajmtrz force-pushed the fix/settled-post-tool-finalization-unavailable branch from 2ed37d1 to 609eaf3 Compare September 8, 2026 17:37
@ajmtrz
ajmtrz force-pushed the fix/settled-post-tool-finalization-unavailable branch from 609eaf3 to d11773d Compare September 9, 2026 09:33
@ajmtrz

ajmtrz commented Sep 9, 2026

Copy link
Copy Markdown
Author

Hi! I’ve refreshed the branch and resolved the documentation conflict introduced by the agent harness reference split. The focused tests (74/74), check:changed, docs checks, and full build all pass locally. CI is rerunning on the new head. When convenient, I’d appreciate a maintainer review and merge once the refreshed checks are green. Thanks!

@VACInc

VACInc commented Sep 21, 2026

Copy link
Copy Markdown
Member

Related: #154930 merged into main and silences the host-generated missing-summary fallback for cron-triggered runs, preserving that silent outcome through terminal resolution. Release availability and deployment are unverified.

This does not supersede the absent-callback work here. Main still skips settled-turn finalization when the harness callback is absent; the cron change only alters fallback handling after that path is reached. Detached persistence and post-append cancellation semantics are also outside its scope. Keeping this PR open; the merge does not establish that these behaviors are resolved.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Oct 15, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

@ajmtrz
ajmtrz deleted the fix/settled-post-tool-finalization-unavailable branch October 24, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: L stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants