Repository navigation
Description
Summary
In OpenClaw 2026.5.26, long-running tools can persist many individually sub-cap toolResult entries into a session. The aggregate persisted tool output can later make even very short follow-up messages exceed the model context window.
This is not specific to one command or provider. The concrete report came from a Telegram direct session with a long-running process task, but the underlying issue is a general persisted-history/tool-output budget problem.
Real environment
- Version observed: OpenClaw 2026.5.26
- Surface: Telegram direct conversation
- Runtime shape: Windows-side OpenClaw bot/session running a long
processtask - Model context: large-context model, but session history still became poisoned by aggregate persisted tool output
User-visible symptom
After a long-running process task produced repeated tool output, normal short Telegram messages failed repeatedly:
Your input exceeds the context window of this model. Please adjust your input and try again.
This happened even for short follow-up messages such as:
1
So the problem was not the current user input length; the previous persisted session history had grown too large.
Evidence from session inspection
The affected direct session contained many repeated persisted messages like:
role: toolResult
toolName: process
content: text chunks, many around ~30k chars each
Each individual chunk could be under an existing per-result cap, but the active branch accumulated enough of them that later prompts replayed too much tool output.
Raw screenshots/logs are intentionally not attached here because they include private Telegram/session details. The relevant error text and persisted-message shape are quoted above in redacted form.
Expected behavior
Persisted session history should not allow repeated tool outputs to grow without an aggregate budget. A long-running tool should not poison future turns such that unrelated short user messages fail context assembly.
Related fix
A proposed fix is in:
The PR keeps the existing per-tool-result cap, and adds an aggregate persisted toolResult budget for the active branch so repeated sub-cap outputs are rewritten/truncated before later user turns can replay them all.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
ooiuuii commentedon May 28, 2026
Proposed fix PR: #87639
clawsweeper commentedon May 28, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed May 28, 2026, 9:38 AM ET / 13:38 UTC.
Summary
Keep open. Current main still lacks aggregate persistence enforcement in the session tool-result guard, and the issue is paired with the open fix PR at #87639.
Reproducibility: yes. source-level. Append several sub-cap toolResult messages through the guarded SessionManager path and inspect the active branch aggregate; current main caps individual results but does not bound the aggregate at persistence time.
Next step
An open linked PR already implements the candidate fix, so a separate repair lane would duplicate current review work.
Review details
Best possible solution:
Review and land the linked PR, or an equivalent narrow fix, so persisted toolResult history has both per-result and aggregate active-branch budgets with regression coverage.
Do we have a high-confidence way to reproduce the issue?
Yes, source-level. Append several sub-cap toolResult messages through the guarded SessionManager path and inspect the active branch aggregate; current main caps individual results but does not bound the aggregate at persistence time.
Is this the best way to solve the issue?
Yes. The linked PR's direction is narrow: keep the existing per-result cap, enforce an aggregate active-branch budget after tool results are persisted, and add focused session-guard coverage.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 76ebc149567b.
Label changes
Label justifications:
P2: This is a normal-priority persisted-session bug with real user impact but a narrow linked fix path.impact:session-state: The failure is caused by accumulated persisted session history poisoning later context assembly.Evidence reviewed
What I checked:
src/agents/session-tool-result-guard.ts:686, 76ebc149567b)src/agents/embedded-agent-runner/run/attempt.ts:3863, 76ebc149567b)src/agents/session-tool-result-guard.ts:541, 8930882a21cd)src/agents/session-tool-result-guard.ts:686, 27ae826f6525)Likely related people:
src/agents/session-tool-result-guard.ts,src/agents/session-tool-result-guard.test.ts)src/agents/session-tool-result-guard.ts,src/agents/session-tool-result-guard.test.ts,src/agents/embedded-agent-runner/tool-result-truncation.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.openclaw-clownfish commentedon Jun 15, 2026
Thanks @ooiuuii for the detailed report and source repro. I am closing this because the fix landed in #87639: #87639. That PR bounds aggregate persisted tool results so long-running tool output cannot keep poisoning later session context, which is the failure tracked here at #87651.
Clownfish is keeping the canonical fix path on the merged PR, and the report/source context here remains part of the attribution for that work. If this still reproduces on current main, or if there is a different path that #87639 did not cover, please reply and we can reopen or split a follow-up.