fix: force preflight compaction before oversized agent turns#87522
Conversation
|
Codex review: needs maintainer review before merge. Reviewed May 31, 2026, 2:31 PM ET / 18:31 UTC. Summary PR surface: Source +82, Tests +142. Total +224 across 9 files. Reproducibility: yes. The current-main source path shows required preflight compaction can call the compactor without force, and the PR supplies production Feishu logs for the below-threshold preflight failure plus after-fix completion evidence. Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land this as the narrow forced-preflight fix once compaction owners accept the force semantics and the branch is refreshed against current main with focused agent/auto-reply validation. Do we have a high-confidence way to reproduce the issue? Yes. The current-main source path shows required preflight compaction can call the compactor without force, and the PR supplies production Feishu logs for the below-threshold preflight failure plus after-fix completion evidence. Is this the best way to solve the issue? Yes, this is the narrowest maintainable fix shape I found: it uses the existing ContextEngine.compact force contract and keeps preflight reason/trigger details internal. The remaining question is maintainer acceptance of the compatibility/session-state semantics, not a concrete code defect. AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against 2fbddce88182. Label changesLabel justifications:
Evidence reviewedPR surface: Source +82, Tests +142. Total +224 across 9 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
|
|
ClawSweeper PR egg: 🎁 locked until real behavior proof passes. Details
|
|
Follow-up after ClawSweeper review:
Remaining known blocker:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Correction to my earlier proof update: a stronger live validation in the affected Feishu group just reproduced the original failure, so this should not be treated as proven yet. Live production failure: The earlier simple probe turns ( |
|
Correction/update to the earlier failed-proof note: The failed live validation at
Pre-restart failure in the affected Feishu group: Post-restart validation in the same affected Feishu group: A subsequent real project turn ( I updated the PR body accordingly. Scope boundary: this is proof for the @clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. Re-review progress:
|
This comment was marked as spam.
This comment was marked as spam.
|
Fresh related observation from the same production incident window:
For this PR specifically, I agree the remaining blocker is exact-head/head-built proof for the oversized preflight path. The production restart proof showed the installed package/runtime behavior after restart, but the maintainer concern that it was not exact PR-head proof is fair. |
|
Status refresh after checking current PR checks without pulling the repo locally:
Given the proof check is now green, this may need either a maintainer rerun/refresh of the unrelated runtime shard or a separate fix for those gateway shared-token tests. I’m not treating this as exact-head merge-ready yet because the status label still says @clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
3b4747e to
18daa7a
Compare
|
Land-ready after maintainer fixups. Summary:
Local proof:
CI proof:
Known proof gaps: none. |
Summary
Fixes the preflight compaction path for oversized embedded agent turns.
When the auto-reply runner detects that the upcoming prompt is already over the safe token budget / transcript byte budget, it now marks the compaction request as preflight-required and forced. The context-engine compaction wrapper honors that force signal, instead of only forcing manual
/compactcalls.This makes the upper-layer preflight budget gate authoritative: if a turn would otherwise fail with context overflow, OpenClaw should compact before submitting the prompt rather than returning no response.
Fixes #87234.
Changes
force: true,forcePreflight: true,preflightRequired: true, and the trigger (tokens/transcript_bytes) from the auto-reply preflight gate.force: truewhile keeping diagnostic reason/trigger metadata internal viaruntimeContext.forceReason: "manual"runtime context hint.Real behavior proof
Preflight compaction required but failed: below threshold, leaving Feishu DM/group sessions apparently unresponsive. This PR makes the upper-layer preflight budget gate force compaction instead of letting the lower compaction threshold veto it./usr/lib/node_modules/openclaw/dist, gateway on127.0.0.1:18789). Installed package / CLI was2026.5.26; the initial failed validation was on a stale running gateway2026.5.22, PID3752207, startedWed May 27 09:52:55 2026. After real systemd restart the running gateway was2026.5.26, PID3953195, startedThu May 28 14:55:53 2026, connectivity probeok.systemctl --user restart openclaw-gateway; verifiedopenclaw gateway statusreported Gateway2026.5.26and new PID/start time; then sent/observed real project messages in the affected Merlin evolution Feishu groupoc_5cc1621461880ae8dccec0147e40896busing sessionagent:main:feishu:group:oc_5cc1621461880ae8dccec0147e40896b.Feishu message history also showed the second post-restart turn produced a visible CardKit reply to user text
merge 483,下一步, including project progress (#483 已 merge; main 也已同步...) and continued workflow updates.Preflight compaction required but failed: below thresholdwas observed for the affected group.below thresholdpreflight failure path and stale-runtime deployment issue in the affected production Feishu group. It is not a blanket proof for every future high-context overflow or unrelated Feishu/card lifecycle failure mode.Verification
Ran targeted tests locally:
Note:
pnpm install --frozen-lockfilewas slow/flaky in this environment because@matrix-org/matrix-sdk-crypto-nodejspostinstall downloads timed out repeatedly. Existingnode_modules/.bin/vitestwas available, so the targeted regression suite was run directly.