openclaw - ✅(Solved) Fix Bug: SESSIONS_HISTORY_TEXT_MAX_CHARS environment variable not生效(硬编码4000字符) [1 pull requests, 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#64970Fetched 2026-04-12 13:26:11
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Participants
Timeline (top)
cross-referenced ×1referenced ×1

Fix Action

Fixed

PR fix notes

PR #65029: fix(sessions): allow env override for sessions_history text truncation limit

Description (problem / solution / changelog)

Summary

SESSIONS_HISTORY_TEXT_MAX_CHARS was hardcoded to 4000 in src/agents/tools/sessions-history-tool.ts, unlike PI_BASH_MAX_OUTPUT_CHARS which reads from env via readEnvInt(). Users with large context windows or long conversation histories had no way to increase the per-entry text truncation limit.

Fixes #64970

Root cause

// sessions-history-tool.ts:32 (before fix)
const SESSIONS_HISTORY_TEXT_MAX_CHARS = 4000;  // hardcoded, no env override

// bash-tools.exec-runtime.ts:105 (existing pattern)
readEnvInt("PI_BASH_MAX_OUTPUT_CHARS"),  // reads from env, falls back to default

Fix

const SESSIONS_HISTORY_TEXT_MAX_CHARS = readEnvInt("SESSIONS_HISTORY_TEXT_MAX_CHARS") ?? 4000;

Matches the existing env-override pattern used by PI_BASH_MAX_OUTPUT_CHARS and OPENCLAW_BASH_PENDING_MAX_OUTPUT_CHARS in bash-tools.exec-runtime.ts. Import added from ../bash-tools.shared.js where readEnvInt is already exported.

Scope

  • Files: sessions-history-tool.ts (+6/-1)
  • Production LOC: 1 line changed (+ import + comment)
  • oxlint clean
  • Zero competing PRs

Credit to @Galaxy-Chen for identifying the inconsistency in #64970.

Changed files

  • src/agents/tools/sessions-history-tool.ts (modified, +11/-1)

Code Example

const SESSIONS_HISTORY_TEXT_MAX_CHARS = 4e3;  // 4000 字符!
RAW_BUFFERClick to expand / collapse

Bug描述: 配置文件中设置 SESSIONS_HISTORY_TEXT_MAX_CHARS=16000,但源码硬编码为 4000,导致配置无效。

影响: 子 Agent 输出超过 4000 字符时被截断,影响任务执行。

复现步骤

  1. 在 openclaw.json 中设置 env.SESSIONS_HISTORY_TEXT_MAX_CHARS=16000
  2. 启动子 Agent 并输出超过 4000 字符的内容
  3. 父 Agent 收到的输出被截断

源码位置: pi-embedded-*.js 文件中硬编码:

const SESSIONS_HISTORY_TEXT_MAX_CHARS = 4e3;  // 4000 字符!

对比: PI_BASH_MAX_OUTPUT_CHARS 环境变量正常生效,但 SESSIONS_HISTORY_TEXT_MAX_CHARS 不生效。

建议修复: 使用 readEnvInt 读取环境变量,与 PI_BASH_MAX_OUTPUT_CHARS 保持一致。

环境: OpenClaw 2026.4.8

extent analysis

TL;DR

Update the pi-embedded-*.js file to use the readEnvInt function to read the SESSIONS_HISTORY_TEXT_MAX_CHARS environment variable instead of hardcoding it to 4000.

Guidance

  • Identify the hardcoded value in pi-embedded-*.js and replace it with a call to readEnvInt to read the SESSIONS_HISTORY_TEXT_MAX_CHARS environment variable.
  • Verify that the SESSIONS_HISTORY_TEXT_MAX_CHARS environment variable is set correctly in the openclaw.json file.
  • Test the fix by restarting the sub Agent and checking if the output is no longer truncated.
  • Compare the implementation with the PI_BASH_MAX_OUTPUT_CHARS environment variable to ensure consistency.

Example

const SESSIONS_HISTORY_TEXT_MAX_CHARS = readEnvInt('SESSIONS_HISTORY_TEXT_MAX_CHARS');

Notes

The fix assumes that the readEnvInt function is already implemented and working correctly for other environment variables, such as PI_BASH_MAX_OUTPUT_CHARS.

Recommendation

Apply the workaround by updating the pi-embedded-*.js file to use the readEnvInt function, as it is a more flexible and consistent approach.

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