openclaw - 💡(How to fix) Fix Feature: Configurable max result size for tool outputs to prevent context overflow [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#61397Fetched 2026-04-08 02:59:02
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Participants
Timeline (top)
closed ×1

Code Example

{
  "agents": {
    "maxToolResultChars": 8000
  }
}
RAW_BUFFERClick to expand / collapse

Problem

When tools like exec return large outputs (thousands of lines), the entire result is injected into the context window, consuming a significant portion of the available context budget. This frequently causes context overflow, especially when multiple large results accumulate in a session.

Example scenarios:

  • exec returns 2000+ lines of logs
  • Sub-agent (sessions_spawn) returns a 20KB analysis report
  • File reads return full large files

Proposed Solution

Add a configurable maxToolResultChars option that:

  1. When a tool result exceeds the threshold, persist the full result to a temp file
  2. Return only the first N characters + a reference to the full file path
  3. Allow the agent to explicitly request the full result if needed

Inspiration

Claude Code implements this via maxResultSizeChars — large tool results are truncated with a "see full output" mechanism. This is critical for context management in long sessions.

Config example

{
  "agents": {
    "maxToolResultChars": 8000
  }
}

Or per-tool override for tools known to return large outputs (exec, sessions_spawn, etc.).

extent analysis

TL;DR

Implement a configurable maxToolResultChars option to truncate large tool results and prevent context overflow.

Guidance

  • Introduce a maxToolResultChars configuration option to set a threshold for tool result sizes.
  • When a tool result exceeds this threshold, store the full result in a temporary file and return a truncated version with a reference to the full file path.
  • Consider implementing a mechanism for the agent to request the full result if needed, similar to Claude Code's "see full output" feature.
  • Evaluate the need for per-tool overrides for tools known to return large outputs, such as exec and sessions_spawn.

Example

{
  "agents": {
    "maxToolResultChars": 8000
  }
}

This configuration example sets the maximum tool result size to 8000 characters.

Notes

The proposed solution is inspired by Claude Code's maxResultSizeChars feature, which suggests that this approach can be effective in managing context size.

Recommendation

Apply the proposed workaround by implementing the maxToolResultChars option to prevent context overflow and improve performance. This solution allows for flexible configuration and can be tailored to specific tool requirements.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING