Skip to content

fix(agents): front-load exec retention-loss disclosure past session caps - #128997

Merged
obviyus merged 1 commit into
openclaw:mainfrom
Finn763:fix/issue-128967-session-truncation-disclosure
Aug 30, 2026
Merged

obviyus merged 1 commit into
openclaw:mainfrom
Finn763:fix/issue-128967-session-truncation-disclosure

Conversation

@Finn763

@Finn763 Finn763 commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

OpenClaw can discard early exec output at its aggregate retention cap. The exec and process tools disclose that loss, but they placed the disclosure after the retained output. The session result cap keeps the head, so it could remove the producer disclosure while keeping only its own later truncation notice.

The persisted transcript then looked fully accounted for even though an earlier, unrecoverable loss was hidden. This can make an agent retry the same read without knowing why the output is incomplete.

Partially addresses #128967. The separate find and grep stderr-tail paths remain tracked there.

Root Cause

The exec/process owner retained a capped output tail and appended the aggregate-loss notice. The SQLite transcript guard then applied a second, head-preserving cap. That composition removed the first notice.

process poll also appended its retained-output omission note. Under the same cap, the transcript could lose the distinction between output discarded at the aggregate cap and output still available through process log.

Fix

  • Own the aggregate-retention wording once in the shared exec output renderer.
  • Put the unrecoverable aggregate-loss notice before foreground exec output and every process poll/log result.
  • Put the poll omission notice before poll output, while keeping the ordinary log paging note after the slice it describes.
  • Keep retention sizes, session limits, process lifecycle, configuration, storage schema, and documented behavior unchanged.

Evidence

The live proof runs a real Node child that writes 250,000 characters through the production foreground exec and background process paths. It persists each tool result through the guarded SQLite session manager, reopens the database, and inspects the stored text.

Exact main eeec0d4b2a0cada60046aba548d005cd7ace125a is red:

  • Foreground exec, process poll, and process log each return the aggregate-loss notice before persistence.
  • After SQLite reopen, all three stored results lose that notice.
  • All three still contain the session result-cap notice, proving the later cap hid only the earlier disclosure.

Exact candidate 34f704e3fdbd7308a05fd98960a7d43332412254 is green:

  • All three reopened results retain the aggregate-loss notice.
  • All three retain the session result-cap notice.
  • Poll also retains the separate note that earlier output is omitted from this poll and remains available through process log.

Regression proof:

  • The new owner-boundary persistence test fails on pre-fix main because stored text begins with retained output instead of the loss notice.
  • The repaired head passes 90 focused tests across foreground exec, process poll/log, and session result persistence.
  • Formatting, Oxlint, diff checks, and all permitted changed-file ratchets pass locally. Hosted CI owns repository-wide type checks and builds.

Scope

Production is +4 lines after unifying the duplicate notice text. Tests are +36 lines. No configuration, dependency, protocol, schema, migration, or documentation contract changes.

@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 25, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 25, 2026
@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 8:04 AM ET / 12:04 UTC.

ClawSweeper review

What this changes

Moves exec and background-process retention-loss disclosures before retained command output so the session transcript cap preserves the warning.

Regression provenance

Possible regression — probable (reviewed change; known regression link). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open. Current main still puts the aggregate-loss disclosure after retained output; this branch moves it to the producer boundary across foreground exec and process poll/log paths. No introduced correctness defect was found, but exact-head checks are still in progress.

Priority: P1
Reviewed head: 34f704e3fdbd7308a05fd98960a7d43332412254

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The narrow producer-boundary repair and focused coverage are sound; required exact-head validation remains in progress.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The supplied PR evidence describes a real Node child through foreground exec and background process paths, followed by guarded session persistence and reopen; source inspection confirms that the changed producers and the head-preserving guard correspond to that scenario.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The supplied PR evidence describes a real Node child through foreground exec and background process paths, followed by guarded session persistence and reopen; source inspection confirms that the changed producers and the head-preserving guard correspond to that scenario.
Evidence reviewed 5 items Current-main behavior: Current main appends the aggregate-retention notice after retained output in both foreground exec and process paths, so a head-preserving transcript cap can hide it.
Introduced repair: The PR uses one shared note and places it before warning text and retained output in foreground results; process poll/log paths make the same ordering change.
Caller and cap boundary: The exec entry point derives aggregate loss from the process session before constructing the foreground result, while the session guard applies the generic head-preserving result cap.
Findings None None.
Security None None.

How this fits together

Exec and process tools create model-visible command results that the session transcript guard later caps before persistence. This change ensures an unrecoverable-output warning reaches later agent turns even when retained output is shortened again.

flowchart LR
  A[Command child output] --> B[Exec or process result]
  B --> C[Aggregate retention cap]
  C --> D[Loss disclosure]
  D --> E[Session transcript cap]
  E --> F[Persisted agent context]
Loading

Before merge

  • Resolve merge risk (P1) - This changes model-visible text persisted for later agent turns; wait for the required exact-head CI checks now in progress before merging.
  • Complete next step (P2) - No mechanical repair remains; a maintainer should wait for exact-head CI before deciding whether to merge.
Agent review details

Security

None.

PR surface

Source +4, Tests +36. Total +40 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 22 18 +4
Tests 3 45 9 +36
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 67 27 +40

Review metrics

Metric Value Why it matters
Production versus tests production +22/-18 (net +4); tests +45/-9 (net +36) The net production growth is the shared disclosure constant; the remainder is an ordering refactor with focused boundary coverage.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #128967
Summary: This PR is the candidate repair for the exec/process portion of the open session-result truncation report; separate remaining paths are tracked elsewhere.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Validate the current head (recommended)
    Merge after required checks for the current head complete successfully, confirming the transcript-visible ordering across the broader agent suite.

Technical review

Best possible solution:

Keep the irreversible-loss fact first at the exec/process producer boundary while retaining the session guard’s generic truncation behavior, then merge after exact-head validation is green.

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

Yes. Current main’s producer appends the loss notice after retained output, while the session guard retains the head of oversized tool results; the resulting loss of the notice follows directly from those source paths.

Is this the best way to solve the issue?

Yes. Front-loading the producer-owned irreversible-loss disclosure is the narrow canonical repair, avoiding special cases in the generic session guard and preserving the separately tracked find/grep work.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against a8c8c8270836.

Labels

Label justifications:

  • P1: The PR repairs a missing model-visible disclosure in persisted command results.
  • merge-risk: 🚨 session-state: It changes text retained in session transcripts for subsequent agent turns.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The supplied PR evidence describes a real Node child through foreground exec and background process paths, followed by guarded session persistence and reopen; source inspection confirms that the changed producers and the head-preserving guard correspond to that scenario.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied PR evidence describes a real Node child through foreground exec and background process paths, followed by guarded session persistence and reopen; source inspection confirms that the changed producers and the head-preserving guard correspond to that scenario.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Wait for the current head’s required checks to complete green.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (8 earlier review cycles)
  • reviewed 2026-08-25T04:07:11.530Z sha a1ba00783544de421e5bad3a94ed01755b05a383 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-25T04:39:06.346Z sha a1ba00783544de421e5bad3a94ed01755b05a383 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-25T10:02:45.270Z sha a1ba00783544de421e5bad3a94ed01755b05a383 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-25T10:45:16.495Z sha a1ba00783544de421e5bad3a94ed01755b05a383 :: found issues before merge. :: [P1] Remove the closing reference for the remaining stderr-tail defect
  • reviewed 2026-08-25T14:47:47.195Z sha a1ba00783544de421e5bad3a94ed01755b05a383 :: needs changes before merge. :: [P1] Remove the stale closing directive from the head commit | [P2] Place the retention disclosure before unbounded warnings
  • reviewed 2026-08-25T17:00:42.581Z sha fe2dc35afc58a078a89fdb2a692bfa5d03b9e79a :: needs maintainer review before merge. :: none
  • reviewed 2026-08-25T18:56:07.222Z sha 13b12e784078e9564805accf78737d31d5cae010 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-26T19:30:08.423Z sha 6092cda :: needs maintainer review before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Aug 25, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 25, 2026
@Finn763

Finn763 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@Finn763

Finn763 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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 Aug 25, 2026
@Finn763

Finn763 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Removed the Closes #128967 closing reference as requested (P1): the PR now states "Partially addresses #128967 (remaining 64 KiB stderr-tail loss tracked there)", so merging will not auto-close the report whose stderr-tail defect remains open.

@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. label Aug 25, 2026
@Finn763
Finn763 force-pushed the fix/issue-128967-session-truncation-disclosure branch from a1ba007 to fe2dc35 Compare August 25, 2026 16:54
@Finn763

Finn763 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

P1 (commit message no longer closes the issue), P2 (disclosure front-loaded ahead of unbounded warningText + oversized-warning boundary regressions), and rebase onto latest main (incl. #129273) are all done. New head: fe2dc35afc58a078a89fdb2a692bfa5d03b9e79a

@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 25, 2026
@Finn763

Finn763 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

CI triage: most checks-node-compact-* failures are a pre-existing main-branch red window; one was PR-caused (fixed)

The bulk of the failing shards in run 32874714349 are not caused by this PR. One — large-19 — was a PR-introduced regression and is now fixed on 13b12e7840 (still verifying on a fresh run).

large-19 was PR-caused (now fixed):

  • src/agents/bash-tools.test.ts > exec tool backgrounding > 'applies default tail only when no exp…' (line 671) — expected '[showing last 200 of 201 lines; pass …' to be 'line-2'.
  • This PR's prior head (fe2dc35afc5) front-loaded both retentionCapNote and defaultTailNote before the slice on action=log, so snapshot.lines[0] started with the [showing last 200 of 201 lines…] marker instead of line-2.
  • Fix on 13b12e7840: keep retentionCapNote front-loaded (the producer disclosure still has to survive head-preserving caps), but move defaultTailNote back to its trailing position after the slice and restore the original \n\n[showing last …] leading-newline format. All 66 tests in the four bash-tools* + session-tool-result-guard test files pass locally; oxlint and pnpm tsgo:core clean.

The remaining failing shards are a main red window, not this PR:

Shard Job Failing test
large-11 97890039719 src/media-understanding/runner.local-no-auth.test.ts:287 — uses OpenAI API key auth for audio when the default OpenAI profile is OAuth — timeout
large-17 97890039848 src/auto-reply/reply/commands-learn.test.ts:106 — includes the load-bearing skill authoring standards — assertion
large-29 97890039800 src/agents/model-auth.oauth-refresh-fail-closed.test.ts:37 — does not fall back to env after a configured OAuth profile refresh fails — timeout
large-3 97890039807 src/agents/embedded-agent-runner/model-resolution-consistency.test.ts:185 — timeout
large-9 97890039780 src/agents/runtime-plan/resolve-auth.test.ts:112 — timeout
small-20 97890041517 src/cron/isolated-agent.session-identity.test.ts
small-21 97890041713 src/cron/isolated-agent.delivery-awareness.test.ts
small-22 97890041654 src/commands/onboard-custom.test.ts:113 — timeout
small-23 97890041608 src/secrets/runtime.auth-migration-isolation.test.ts:34 — timeout

Cross-checks:

Disposition: large-19 is fixed by 13b12e7840 and will rerun on the next push's CI. Everything else is a pre-existing main-branch red window and should clear once main is green; no further fix is included here.

@Finn763

Finn763 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review for head 13b12e78 (just pushed: large-19 bash-tools regression fixed in the same diff; evidence comment posted for the rest as main red window). Thanks!

@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added 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 Aug 25, 2026
@Finn763

Finn763 commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

"PR context and evidence" is green on this PR — no body changes or push needed.

What happened: the checker (.github/workflows/real-behavior-proof.yml) requires external PR bodies to include authored "What Problem This Solves" and "Evidence" sections. Two runs failed on that requirement on Aug 25 while the body was still being completed:

  • 32808788854 (04:23Z) — fail
  • 32885071757 (18:39Z) — fail: "External PRs must include authored What Problem This Solves and Evidence sections"

Once the evidence sections were in the body, the check passed on the immediate re-run at the same head 13b12e784078 — 32885120630 (18:40Z) — and has stayed green since.

Note: the remaining red checks (checks-node-compact-large-3/4/17/20, small-20/21/22, ci-gate) are from the same main red-window run (Aug 25 18:05Z); push-to-main has been green since 12:38Z today (32969689537, 32969705904, 32970558530). Happy to have those re-run too if useful.

@Finn763
Finn763 force-pushed the fix/issue-128967-session-truncation-disclosure branch from 13b12e7 to 6092cda Compare August 26, 2026 19:24
@Finn763

Finn763 commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto the latest origin/main (adb3fb2) and force-pushed.

  • New head: 6092cda9563 — clean rebase on the current branch (fix/issue-128967-session-truncation-disclosure).
  • Local: bash-tools + session-tool-result-guard suites 83/83 pass.

@steipete could you please re-run the failed CI jobs? Thanks!

@obviyus
obviyus force-pushed the fix/issue-128967-session-truncation-disclosure branch from 6092cda to 34f704e Compare August 30, 2026 11:58
@obviyus
obviyus merged commit be67a8b into openclaw:main Aug 30, 2026
254 checks passed
@obviyus

obviyus commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

Thanks @Finn763!

Proof: A real child produced 250,000 characters through foreground exec and background process poll/log. Current main lost the aggregate-loss notice after SQLite persistence; the merged candidate kept both that notice and the session result-cap notice after reopen. Exact-head CI passed.

  • Bug: The session result cap kept the output head and silently removed an aggregate-loss disclosure placed at the tail.
  • Fix: The shared exec/process output owner now puts unrecoverable loss first, while poll omission and log paging stay distinct.

Example

Before After
Stored output showed only the later result-cap truncation notice. Stored output shows the earlier aggregate loss and the later result-cap truncation.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 31, 2026
…law#128997)

Exec and process results placed their aggregate-retention disclosure after retained output, so the SQLite session result cap could hide the earlier unrecoverable loss.

Own the disclosure once and place it first across foreground exec, process poll, and process log. Preserve the separate poll omission and log paging semantics, and cover the composed persistence boundary with a red-to-green regression.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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.

2 participants