-
-
Notifications
You must be signed in to change notification settings - Fork 39.8k
Closed
Labels
bugSomething isn't workingSomething isn't workingclose:already-fixedclaw-marshal labelclaw-marshal labeltriage:doneclaw-marshal labelclaw-marshal label
Description
Summary
sessions_history tool has no default limit on the number of messages returned. When an agent calls it without specifying limit, all messages from the target session are returned, which can easily cause context overflow in the calling session.
Steps to Reproduce
- Have a long-running session with many tool calls (large history)
- From another session (or the same session after reset), call
sessions_historywithout alimitparameter - The tool returns the entire session history, potentially hundreds of messages with full tool outputs
- The calling session context overflows immediately
Root Cause
In src/agents/tools/sessions-history-tool.ts (lines 251-254), when limit is not provided, it resolves to undefined, which is passed directly to the gateway chat.history method — resulting in all messages being returned:
const limit =
typeof params.limit === "number" && Number.isFinite(params.limit)
? Math.max(1, Math.floor(params.limit))
: undefined; // <-- no default, returns everythingImpact
- Agent calls
sessions_historyto investigate an issue → gets entire session dump → instant context overflow - This is especially dangerous after a context overflow + reset, where the agent naturally wants to check what happened in the previous session
- In our case, this caused two consecutive context overflows within minutes
Proposed Fix
Set a reasonable default limit (e.g., 20 messages) when the caller does not specify one:
const limit =
typeof params.limit === "number" && Number.isFinite(params.limit)
? Math.max(1, Math.floor(params.limit))
: 20; // safe defaultAgents that need more history can explicitly pass a higher limit.
Environment
- OpenClaw 2026.2.6-3 (85ed6c7)
- macOS Darwin 24.6.0 (arm64)
- Model: anthropic/claude-sonnet-4-5 (200k context)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingclose:already-fixedclaw-marshal labelclaw-marshal labeltriage:doneclaw-marshal labelclaw-marshal label