fix: add default limit of 20 to sessions_history tool [AI-assisted]#12433
Closed
Baoxd123 wants to merge 1 commit intoopenclaw:mainfrom
Closed
fix: add default limit of 20 to sessions_history tool [AI-assisted]#12433Baoxd123 wants to merge 1 commit intoopenclaw:mainfrom
Baoxd123 wants to merge 1 commit intoopenclaw:mainfrom
Conversation
When the caller does not specify a limit, sessions_history returns all messages from the target session, which can cause context overflow in the calling session. Set a safe default of 20 messages. Agents needing more can explicitly pass a higher limit. Fixes openclaw#12432
Takhoffman
added a commit
that referenced
this pull request
Feb 10, 2026
Contributor
|
Fixed in #12988. This will go out in the next OpenClaw release. If you still see this after updating to the first release that includes #12988, please open a new issue with:
Link back here for context. |
bfc1ccb to
f92900f
Compare
Contributor
|
Closing as superseded/already fixed.
If we want to enforce a default message-count policy as a product choice (separate from overflow safety), we can open a focused follow-up PR with tests for that behavior. |
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
Adds a safe default limit of 20 messages to the
sessions_historytool when the caller does not specify one.Problem
When
limitis not provided,sessions_historyreturns all messages from the target session. This can cause instant context overflow in the calling session, especially when querying sessions with large histories (many tool calls, long conversations).Fix
One-line change in
src/agents/tools/sessions-history-tool.ts(line 254):Agents that need more history can explicitly pass a higher
limitparameter.Testing
limitas an optional number parameterlimitis not providedlimitare unaffectedpnpm build && pnpm check && pnpm test(running locally)AI Disclosure 🤖
limitparameter fallback increateSessionsHistoryTool(). Whenparams.limitis not a finite number, instead of passingundefined(which fetches all messages), it now defaults to20.Fixes #12432