fix(sessions): skip parent fork when context too large, surface overflow errors#26912
Closed
markshields-tl wants to merge 1 commit intoopenclaw:mainfrom
Closed
fix(sessions): skip parent fork when context too large, surface overflow errors#26912markshields-tl wants to merge 1 commit intoopenclaw:mainfrom
markshields-tl wants to merge 1 commit intoopenclaw:mainfrom
Conversation
…low errors Two fixes for openclaw#26905 (thread sessions born dead from bloated parent): 1. **Skip fork when parent exceeds 100k tokens** — forkSessionFromParent() now checks parentEntry.totalTokens before copying the parent transcript. If over PARENT_FORK_MAX_TOKENS (100k), the thread session starts fresh instead of inheriting a context that will immediately overflow. 2. **Surface context overflow to users** — When the agent run completes with an embedded context overflow error and no payload text, return a user-visible error message instead of silently dropping the response. Previously, Slack DM sessions would swallow messages with no feedback. Includes test for the fork-skip behavior. Closes openclaw#26905
|
@markshields-tl Nice fix for surfacing overflow errors instead of returning empty replies. One edge case: this branch checks only Could we gate on "any payload content" (text/media/mediaUrls) instead of text-only, and add a regression test for media-only payloads? |
steipete
added a commit
that referenced
this pull request
Feb 25, 2026
Lands #26912 from @markshields-tl with configurable session.parentForkMaxTokens and docs/tests/changelog updates. Co-authored-by: Mark Shields <239231357+markshields-tl@users.noreply.github.com>
Contributor
|
Landed manually on
SHAs:
Thanks @markshields-tl for the fix and report context. |
This was referenced Feb 25, 2026
Closed
This was referenced Feb 26, 2026
brianleach
pushed a commit
to brianleach/openclaw
that referenced
this pull request
Feb 26, 2026
…w#26912) Lands openclaw#26912 from @markshields-tl with configurable session.parentForkMaxTokens and docs/tests/changelog updates. Co-authored-by: Mark Shields <239231357+markshields-tl@users.noreply.github.com>
2 tasks
Contributor
Author
|
Thank you for approving @steipete ! Was pleasantly surprised to see myself listed as a contributor in the latest release. |
execute008
pushed a commit
to execute008/openclaw
that referenced
this pull request
Feb 27, 2026
…w#26912) Lands openclaw#26912 from @markshields-tl with configurable session.parentForkMaxTokens and docs/tests/changelog updates. Co-authored-by: Mark Shields <239231357+markshields-tl@users.noreply.github.com>
r4jiv007
pushed a commit
to r4jiv007/openclaw
that referenced
this pull request
Feb 28, 2026
…w#26912) Lands openclaw#26912 from @markshields-tl with configurable session.parentForkMaxTokens and docs/tests/changelog updates. Co-authored-by: Mark Shields <239231357+markshields-tl@users.noreply.github.com>
vincentkoc
pushed a commit
to Sid-Qin/openclaw
that referenced
this pull request
Feb 28, 2026
…w#26912) Lands openclaw#26912 from @markshields-tl with configurable session.parentForkMaxTokens and docs/tests/changelog updates. Co-authored-by: Mark Shields <239231357+markshields-tl@users.noreply.github.com>
vincentkoc
pushed a commit
to rylena/rylen-openclaw
that referenced
this pull request
Feb 28, 2026
…w#26912) Lands openclaw#26912 from @markshields-tl with configurable session.parentForkMaxTokens and docs/tests/changelog updates. Co-authored-by: Mark Shields <239231357+markshields-tl@users.noreply.github.com>
steipete
added a commit
to Sid-Qin/openclaw
that referenced
this pull request
Mar 2, 2026
…w#26912) Lands openclaw#26912 from @markshields-tl with configurable session.parentForkMaxTokens and docs/tests/changelog updates. Co-authored-by: Mark Shields <239231357+markshields-tl@users.noreply.github.com>
zooqueen
pushed a commit
to hanzoai/bot
that referenced
this pull request
Mar 6, 2026
…w#26912) Lands openclaw#26912 from @markshields-tl with configurable session.parentForkMaxTokens and docs/tests/changelog updates. Co-authored-by: Mark Shields <239231357+markshields-tl@users.noreply.github.com>
thebenjaminlee
pushed a commit
to escape-velocity-ventures/openclaw
that referenced
this pull request
Mar 7, 2026
…w#26912) Lands openclaw#26912 from @markshields-tl with configurable session.parentForkMaxTokens and docs/tests/changelog updates. Co-authored-by: Mark Shields <239231357+markshields-tl@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #26905 — Thread sessions forked from parent DM sessions inherit the full parent context and immediately overflow the model's context window, causing silent message failures on Slack.
Changes
1. Skip fork when parent context exceeds threshold (
session.ts)Added
PARENT_FORK_MAX_TOKENS(100,000) check beforeforkSessionFromParent(). When the parent session'stotalTokensexceeds this threshold, the thread session starts fresh instead of inheriting a near-full context that would immediately overflow.The session is still marked
forkedFromParent = trueto prevent re-fork attempts on subsequent messages.2. Surface context overflow errors to users (
agent-runner-execution.ts)After the main run loop, if the result contains an embedded context overflow error and no payload text, return a user-visible error message (
⚠️ Context overflow — this conversation is too large...) instead of returningkind: 'success'with an empty result. This prevents silent message swallowing on Slack and other channels.Testing
skips fork and creates fresh session when parent tokens exceed thresholdtsc --noEmit)Context
This caused 3+ incidents over 2 days in our Slack integration:
usage: {input: 0, output: 0}AI Disclosure
This PR was authored with assistance from an AI coding agent (OpenClaw/Claude). All changes were reviewed and tested by the submitter.
Greptile Summary
Prevents silent message failures in Slack threads by implementing two complementary fixes:
Session forking skip logic: Added
PARENT_FORK_MAX_TOKENS(100,000) threshold insession.ts. When a parent DM session exceeds this token count, thread sessions start fresh instead of inheriting a near-full context that would immediately overflow. The session is still marked asforkedFromParent = trueto prevent re-fork attempts on subsequent messages.Error surfacing: Enhanced
agent-runner-execution.tsto detect when the run completes with an embedded context overflow error but no payload text, and return a user-visible error message (⚠️ Context overflow...) instead of silently returning success with an empty result.The 100k threshold is reasonable (about 50% of Claude Opus 4-6's 190k token limit) and provides sufficient headroom. The test coverage comprehensively validates the skip-fork behavior. Implementation follows existing patterns and handles edge cases properly (e.g.,
totalTokens ?? 0defaults to safe fork behavior when token count is unknown).Confidence Score: 5/5
Last reviewed commit: e9e61ab