Skip to content

fix(doctor): warn when maxActiveTranscriptBytes is set without truncateAfterCompaction - #110356

Closed
lee-xydt wants to merge 4 commits into
openclaw:mainfrom
lee-xydt:feat/issue-100529
Closed

lee-xydt wants to merge 4 commits into
openclaw:mainfrom
lee-xydt:feat/issue-100529

Conversation

@lee-xydt

@lee-xydt lee-xydt commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes #100529

  • Problem: resolveMaxActiveTranscriptBytes() at src/auto-reply/reply/memory-flush.ts:27-29 returns undefined when truncateAfterCompaction is not true, even when maxActiveTranscriptBytes is configured with a positive value. The byte guard silently has no effect, and no diagnostic warns the operator.
  • Solution: Add a Doctor health check (core/doctor/inactive-compaction-byte-guard) that runs in the default openclaw doctor --lint path. It warns when maxActiveTranscriptBytes resolves to a positive effective byte limit while truncateAfterCompaction is not enabled. Uses parseNonNegativeByteSize to normalize values so zero-value forms ("0mb", 0, etc.) do not produce false-positive warnings.

What changed

  • src/flows/doctor-health-contributions.ts — added collectCompactionByteGuardFindings (uses parseNonNegativeByteSize), runCompactionByteGuardHealth, and the doctor:compaction-byte-guard contribution. Runs in the default Doctor lint path (no defaultEnabled: false gate).
  • src/flows/doctor-health-contributions.test.ts — 4 test cases covering all config states plus zero-value forms.

Evidence

All cases below run the built openclaw doctor --lint against a minimal openclaw.json config. The check runs in the default path (22 core checks, no --only filtering). Output is JSON mode (stdout not a TTY).

Case A: Warning — maxActiveTranscriptBytes=100MB, truncateAfterCompaction=false

Config: {"agents":{"defaults":{"compaction":{"maxActiveTranscriptBytes":"100MB","truncateAfterCompaction":false}}}}

$ OPENCLAW_CONFIG_PATH=/tmp/proof-warn.json OPENCLAW_DISABLE_BUNDLED_PLUGINS=1 node openclaw.mjs doctor --lint
{"ok":false,"checksRun":22,"checksSkipped":31,"findings":[
  ...,
  {"checkId":"core/doctor/inactive-compaction-byte-guard","severity":"warning","message":"agents.defaults.compaction.maxActiveTranscriptBytes is set to \"100MB\" but truncateAfterCompaction is not enabled, so the byte guard has no effect.","path":"agents.defaults.compaction","requirement":"truncateAfterCompaction enabled when maxActiveTranscriptBytes is configured","fixHint":"Set agents.defaults.compaction.truncateAfterCompaction to true or remove maxActiveTranscriptBytes."}
]}

→ inactive-compaction-byte-guard warning present. Exit code 1 (findings exist).

Case B: Silent — maxActiveTranscriptBytes=0mb, truncateAfterCompaction=false (zero-value)

Config: {"agents":{"defaults":{"compaction":{"maxActiveTranscriptBytes":"0mb","truncateAfterCompaction":false}}}}

$ OPENCLAW_CONFIG_PATH=/tmp/proof-silent-zero.json OPENCLAW_DISABLE_BUNDLED_PLUGINS=1 node openclaw.mjs doctor --lint
{"ok":false,"checksRun":22,"checksSkipped":31,"findings":[...]}

→ No inactive-compaction-byte-guard finding. Zero-value forms ("0mb", "0", etc.) do not trigger false positives.

Case C: Silent — maxActiveTranscriptBytes=100MB, truncateAfterCompaction=true (guard active)

Config: {"agents":{"defaults":{"compaction":{"maxActiveTranscriptBytes":"100MB","truncateAfterCompaction":true}}}}

$ OPENCLAW_CONFIG_PATH=/tmp/proof-silent-truncate.json OPENCLAW_DISABLE_BUNDLED_PLUGINS=1 node openclaw.mjs doctor --lint
{"ok":false,"checksRun":22,"checksSkipped":31,"findings":[...]}

→ No inactive-compaction-byte-guard finding. Truncation enabled → guard works → warning suppressed.

Test Suite

$ node scripts/run-vitest.mjs src/flows/doctor-health-contributions.test.ts
 Test Files  1 passed (1)
      Tests  94 passed (94)

@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. labels Jul 18, 2026
@clawsweeper

clawsweeper Bot commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 26, 2026, 9:08 PM ET / July 27, 2026, 01:08 UTC.

ClawSweeper review

What this changes

Adds a default Doctor lint warning when a positive compaction transcript-byte limit is configured without the required transcript-rotation setting, plus coverage for active, inactive, and zero-value configurations.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

The patch is a focused diagnostic for a real inactive configuration state and the supplied terminal proof shows the warning and its suppression cases. No discrete correctness defect is evident, but enabling it in the default Doctor lint path changes the result and exit status for existing configurations, so a maintainer should explicitly accept that operator-facing compatibility choice before merge.

Priority: P2
Reviewed head: bc505f2b04dac284d53786fff4a4b952e8736eb1
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, well-proven diagnostic patch with one remaining maintainer decision about default Doctor compatibility.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body provides after-fix built-CLI terminal output for the warning and both suppression cases, with focused test evidence; no sensitive values are shown.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body provides after-fix built-CLI terminal output for the warning and both suppression cases, with focused test evidence; no sensitive values are shown.
Evidence reviewed 4 items Current runtime contract: The current runtime returns no active-transcript byte limit unless truncateAfterCompaction is exactly true, so a positive configured byte limit is inactive in the reported configuration state.
Documented configuration contract: The current session-management reference says the byte-size guard is active only with truncateAfterCompaction; leaving it unset or setting it to zero disables it. That supports a diagnostic rather than a new runtime mode.
After-fix behavior proof: The PR body includes built-CLI JSON output showing a warning for a positive 100MB limit with rotation disabled, and no finding for zero values or enabled rotation; it also reports the focused Doctor contribution test passing.
Findings None None.
Security None None.

How this fits together

OpenClaw's compaction settings govern when a long session is summarized and whether its active transcript is rotated to a smaller successor. Doctor reads the effective configuration before runtime and reports unsafe or ineffective settings to operators and automation.

flowchart LR
  Config[Operator compaction config] --> Doctor[Doctor lint]
  Doctor --> Parse[Parse byte-size limit]
  Parse --> Decision{Positive limit and rotation disabled?}
  Decision -->|Yes| Warning[Health warning and nonzero lint result]
  Decision -->|No| Clean[No byte-guard finding]
  Config --> Runtime[Compaction runtime]
  Runtime --> Transcript[Active successor transcript]
Loading

Decision needed

Question Recommendation
Should default openclaw doctor --lint warn and return a finding for existing positive maxActiveTranscriptBytes settings when truncateAfterCompaction is disabled? Accept the default warning: Treat the documented inactive configuration as a default Doctor lint warning, preserving runtime behavior while making the ineffective setting visible.

Why: The source and docs establish that this setting combination leaves the guard inactive, but making Doctor flag it by default changes existing automation-visible lint results rather than only correcting runtime behavior.

Before merge

  • Resolve merge risk (P1) - Existing operator configurations with a positive byte limit and disabled transcript rotation will newly make default openclaw doctor --lint report a warning and exit nonzero; this can affect health-gate or automation scripts even though runtime behavior remains unchanged.
Agent review details

Security

None.

PR surface

Source +63, Tests +143. Total +206 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 3 64 1 +63
Tests 1 143 0 +143
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 207 1 +206

Review metrics

Metric Value Why it matters
Default Doctor findings 1 added The new contribution participates in ordinary Doctor lint rather than only an explicitly selected health-check path, so it can alter existing automation outcomes.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/flows/doctor-health-contribution-core.ts, migration/backfill/repair: src/flows/doctor-health-contribution-runners.state.ts, migration/backfill/repair: src/flows/doctor-health-contributions-initial.ts, migration/backfill/repair: src/flows/doctor-health-contributions.test.ts, unknown-data-model-change: src/flows/doctor-health-contribution-runners.state.ts, unknown-data-model-change: src/flows/doctor-health-contributions.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: partial_overlap
Canonical: #100529
Summary: This PR addresses the linked issue's inactive compaction byte-guard diagnostic, while that issue also tracks distinct tool-result pruning and compaction-policy concerns.

Members:

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

Merge-risk options

Maintainer options:

  1. Confirm the default Doctor contract (recommended)
    Merge after confirming that warning and nonzero lint output for this previously accepted but ineffective configuration is desired for operator automation.
  2. Preserve default lint compatibility
    Revise the contribution to require explicit selection if maintainers do not want existing lint gates to flag the documented inactive setting by default.
  3. Pause the policy change
    Close or defer this PR if the configuration diagnostic is not worth changing default Doctor semantics.

Technical review

Best possible solution:

Keep the diagnostic narrowly scoped to the documented inactive byte-guard configuration, and land it only after maintainers confirm that a default Doctor lint warning and nonzero result is the intended upgrade behavior.

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

Yes from source inspection: current main disables the byte-size guard whenever transcript rotation is not enabled, even if the configured byte limit is positive. The PR body also supplies an after-fix built-CLI demonstration, but no failing current-main execution was run in this read-only review.

Is this the best way to solve the issue?

Unclear: the check accurately reflects the runtime and documented configuration dependency, but default Doctor lint behavior is an operator-facing policy choice because it changes existing lint results.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This improves diagnosis of a bounded session-compaction configuration error without changing the runtime compaction path.
  • merge-risk: 🚨 compatibility: The added default lint finding can cause existing operator health checks to become warning/nonzero after upgrade.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster 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 PR body provides after-fix built-CLI terminal output for the warning and both suppression cases, with focused test evidence; no sensitive values are shown.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix built-CLI terminal output for the warning and both suppression cases, with focused test evidence; no sensitive values are shown.

Evidence

What I checked:

Likely related people:

  • steipete: The oversized-transcript compaction commit established the byte-guard and transcript-rotation contract that this Doctor check diagnoses. (role: feature introducer; confidence: medium; commits: 29af4add2a8e; files: src/auto-reply/reply/memory-flush.ts, docs/reference/session-management-compaction.md)

Rank-up moves

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

  • Confirm the intended default doctor --lint behavior for existing inactive byte-guard configurations.

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 (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-07-18T03:34:40.098Z sha a6dc32e51da3c21774029c125074fbcf0bd6733b :: needs real behavior proof before merge. :: [P2] Run the warning in normal Doctor execution
  • reviewed 2026-07-18T03:44:00.272Z sha 0604ae4e543953b5ae65208682b0847e7939fae7 :: needs real behavior proof before merge. :: [P2] Enable the warning in normal Doctor execution
  • reviewed 2026-07-18T04:35:06.707Z sha bc6db0742461cd12505c8d880c5560fd93e8f363 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-18T05:25:05.140Z sha 3d95a6bc706a7b0cab9c208634fd650a4b6ed2fc :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-18T06:18:05.337Z sha 3d95a6bc706a7b0cab9c208634fd650a4b6ed2fc :: needs maintainer review before merge. :: none
  • reviewed 2026-07-18T06:50:48.513Z sha bf3cad43c33fbc2b2d4c3ae4bb7478ade56a7a17 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-18T06:58:28.100Z sha bf3cad43c33fbc2b2d4c3ae4bb7478ade56a7a17 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-26T16:01:55.192Z sha e65a30ba4a65e6fb3fb92e18c017a2bd30b688f0 :: needs maintainer review before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot added size: M triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed size: S labels Jul 18, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Jul 18, 2026
@lee-xydt
lee-xydt force-pushed the feat/issue-100529 branch from bc6db07 to 3d95a6b Compare July 18, 2026 05:21
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 18, 2026
@lee-xydt

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 18, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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: 🧂 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 Jul 18, 2026
@lee-xydt
lee-xydt force-pushed the feat/issue-100529 branch from 3d95a6b to b2dc493 Compare July 18, 2026 06:29
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jul 18, 2026
@lee-xydt
lee-xydt force-pushed the feat/issue-100529 branch from b2dc493 to bf3cad4 Compare July 18, 2026 06:46
@lee-xydt
lee-xydt force-pushed the feat/issue-100529 branch from bf3cad4 to e65a30b Compare July 26, 2026 15:57
lee-xydt added 4 commits July 27, 2026 09:03
…teAfterCompaction

Add a Doctor health check that warns when agents.defaults.compaction.maxActiveTranscriptBytes
is configured but truncateAfterCompaction is not enabled, because resolveMaxActiveTranscriptBytes
returns undefined in that case and the byte guard has no effect.

Closes openclaw#100529
@steipete

Copy link
Copy Markdown
Contributor

Closing as obsolete — thanks for the contribution; the misconfiguration this PR warns about no longer exists.

PR #115206 (landed as 2160b97cdc7) retired agents.defaults.compaction.truncateAfterCompaction entirely: maxActiveTranscriptBytes > 0 is now the single opt-in for byte-triggered compaction and the Codex native-rollout byte guard, so the warned-about state (threshold set, gate off) cannot be configured anymore, and openclaw doctor --fix migrates existing configs (preserving explicit truncateAfterCompaction: false opt-outs by removing the threshold too). The retired key is also gone from the config types, so this branch would no longer typecheck, and its fixHint would instruct users to add a retired key.

The deeper fix beat the warning: rather than diagnosing the trap, main deleted it. The linked issue #100529 is closed by the same landing.

@steipete steipete closed this Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

Tool-result pruning silently omits results (reads as 'empty output'); maxActiveTranscriptBytes silently no-ops without truncateAfterCompaction

2 participants