openclaw - ✅(Solved) Fix [Bug]: chat.history limit=2000 exceeds server maximum of 1000, no retry [3 pull requests, 1 comments, 2 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#66573Fetched 2026-04-15 06:25:35
View on GitHub
Comments
1
Participants
2
Timeline
10
Reactions
0
Timeline (top)
cross-referenced ×3referenced ×3commented ×1labeled ×1

chat.history API 调用时 limit 参数超过服务器上限(1000),导致历史记录加载失败。客户端代码写死 limit=2000,无校验或重试机制。

Root Cause

chat.history API 调用时 limit 参数超过服务器上限(1000),导致历史记录加载失败。客户端代码写死 limit=2000,无校验或重试机制。

Fix Action

Fix / Workaround

21:16:17 [ws] ⇄ res ✗ chat.history 1ms errorCode=INVALID_REQUEST errorMessage=invalid chat.history params: at /limit: must be <= 1000 conn=f4161ef4…5846 id=822898fc…2bb5
21:16:17 [tools] sessions_history failed: invalid chat.history params: at /limit: must be <= 1000 raw_params={"sessionKey":"agent:main:feishu:group:oc_xxx","includeTools":true,"limit":2000}
21:16:20 [feishu] feishu[default]: dispatch complete (queuedFinal=true, replies=1)

PR fix notes

PR #66610: fix(sessions_history): retry with server-capped limit on INVALID_REQUEST

Description (problem / solution / changelog)

Summary

Issue: #66573 — chat.history limit=2000 exceeds server maximum of 1000, no retry

Root Cause: tool calls with a hardcoded limit of 2000. When the server's maximum is 1000, it returns and the tool silently fails, losing conversation context.

Fix: Catch the error, parse the server's max limit from the error message, and retry with a compliant limit.

Changes:

  • — catch , extract server max, retry with capped limit
  • — added test coverage

Testing: Unit tests pass

Closes #66573

Changed files

  • src/agents/openclaw-tools.sessions.test.ts (modified, +43/-0)
  • src/agents/tools/sessions-history-tool.ts (modified, +17/-4)
  • src/daemon/launchd-plist.ts (modified, +1/-1)
  • src/gateway/server-plugins.ts (modified, +1/-1)

PR #66615: fix(gateway): increase chat.history limit from 1000 to 2000

Description (problem / solution / changelog)

Description

Fix chat.history API rejecting limit=2000 with INVALID_REQUEST error, causing silent failures and lost conversation context.

Root Cause

The schema validation in ChatHistoryParamsSchema capped the limit parameter at 1000, but clients (like Feishu channel integration) were requesting limit=2000. This caused the server to reject the request before the actual limit-clamping logic could handle it.

Solution

  • Increased ChatHistoryParamsSchema maximum limit from 1000 to 2000
  • Synced server-side hardMax constant from 1000 to 2000
  • Maintains backward compatibility (default limit still 200)

Testing

  • Code changes validated
  • Tests need to pass on CI
  • Manual testing with Feishu channel integration recommended

Related Issues

Closes #66573

Changed files

  • src/gateway/protocol/schema/logs-chat.ts (modified, +1/-1)
  • src/gateway/server-methods/chat.ts (modified, +1/-1)

PR #66650: fix(tools): clamp sessions_history limit to chat.history max

Description (problem / solution / changelog)

## Summary

chat.history rejects limit > 1000. The sessions_history tool accepted larger values (e.g. 2000), leading to INVALID_REQUEST and silent history loss.

This change:

  • Adds maximum: 1000 to the tool schema.
  • Clamps outgoing requests to 1000.
  • Updates tests.

Fixes #66573.

Test plan

  • pnpm exec vitest run src/agents/openclaw-tools.sessions.test.ts

Changed files

  • src/agents/openclaw-tools.sessions.test.ts (modified, +1/-0)
  • src/agents/tools/sessions-history-tool.ts (modified, +4/-2)

Code Example

21:16:17 [ws] ⇄ res ✗ chat.history 1ms errorCode=INVALID_REQUEST errorMessage=invalid chat.history params: at /limit: must be <= 1000 conn=f4161ef4…5846 id=822898fc…2bb5
21:16:17 [tools] sessions_history failed: invalid chat.history params: at /limit: must be <= 1000 raw_params={"sessionKey":"agent:main:feishu:group:oc_xxx","includeTools":true,"limit":2000}
21:16:20 [feishu] feishu[default]: dispatch complete (queuedFinal=true, replies=1)
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

chat.history API 调用时 limit 参数超过服务器上限(1000),导致历史记录加载失败。客户端代码写死 limit=2000,无校验或重试机制。

Steps to reproduce

启动 OpenClaw Gateway 任意发送消息触发 chat.history 调用(例如群里 @ 机器人) 观察日志

Expected behavior

chat.history 应该请求 ≤1000 的 limit 值,或在服务器拒绝后自动调整为有效值并重试。

Actual behavior

客户端发送 limit: 2000,服务器返回错误:

INVALID_REQUEST: invalid chat.history params: at /limit: must be <= 1000 错误后静默跳过,不重试,消息上下文丢失。

OpenClaw version

OpenClaw 2026.4.12

Operating system

OS: Windows (PowerShell) Version: 2026.4.10 Config: feishu websocket channel, groupPolicy=all

Install method

npm install -g openclaw openclaw gateway

Model

Model: ollama/qwen3.5:9b

Provider / routing chain

Provider: ollama (本地)

Additional provider/model setup details

No response

Logs, screenshots, and evidence

21:16:17 [ws] ⇄ res ✗ chat.history 1ms errorCode=INVALID_REQUEST errorMessage=invalid chat.history params: at /limit: must be <= 1000 conn=f4161ef4…5846 id=822898fc…2bb5
21:16:17 [tools] sessions_history failed: invalid chat.history params: at /limit: must be <= 1000 raw_params={"sessionKey":"agent:main:feishu:group:oc_xxx","includeTools":true,"limit":2000}
21:16:20 [feishu] feishu[default]: dispatch complete (queuedFinal=true, replies=1)

Impact and severity

历史对话上下文丢失,影响多轮对话质量 用户感知不到问题(消息仍发出),难以定位根因 静默失败缺少反馈,不符合 fail-safe 原则

Additional information

方案1(代码层):客户端不指定 limit,由服务器返回默认值 方案2(健壮层):请求前校验 schema 上限,或在收到 INVALID_REQUEST 后解析错误信息自动调整 limit 并重试

extent analysis

TL;DR

Adjust the limit parameter in the chat.history API call to be within the server's limit of 1000 or implement a retry mechanism with adjusted limit.

Guidance

  • Verify the current limit value being sent in the chat.history API call and adjust it to be within the server's limit of 1000.
  • Consider implementing a retry mechanism that checks the error response and adjusts the limit parameter accordingly.
  • Review the client-side code to ensure it handles errors and exceptions properly, providing feedback to the user when necessary.
  • Evaluate the two proposed solutions: (1) not specifying the limit parameter to use the server's default value, or (2) implementing a pre-request validation and retry mechanism.

Example

No code snippet is provided as the issue does not include specific code details, but an example of adjusting the limit parameter could be:

// Before
const limit = 2000;
// After
const limit = 1000; // or implement a dynamic adjustment based on server response

Notes

The provided solutions (方案1 and 方案2) seem viable, but their implementation details are not specified. It's essential to consider the trade-offs between simplicity and robustness when choosing a solution.

Recommendation

Apply workaround: Implement a retry mechanism with an adjusted limit parameter to ensure the chat.history API call succeeds within the server's limits, providing a better user experience and adhering to fail-safe principles.

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…

FAQ

Expected behavior

chat.history 应该请求 ≤1000 的 limit 值,或在服务器拒绝后自动调整为有效值并重试。

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Bug]: chat.history limit=2000 exceeds server maximum of 1000, no retry [3 pull requests, 1 comments, 2 participants]