feat(gateway): make chat history max chars configurable#58900
Conversation
Greptile SummaryThis PR makes Key observations:
Confidence Score: 5/5Safe to merge — no P0/P1 issues found; the feature is correctly implemented and well-validated. All remaining findings are P2 (informational / style). The default-increase observation is worth awareness but is documented and intentional. Tests cover the three key scenarios (config override, RPC override, rejection of invalid values). No files require special attention; the default value change in Prompt To Fix All With AIThis is a comment left during a code review.
Path: scripts/prepush-ci.sh
Line: 44-45
Comment:
**Fallback checks working-tree changes, not committed history**
When `origin/main` is reachable but no Swift changes appear in `origin/main...HEAD`, the function falls through to `git diff --name-only --relative` (line 45), which compares the *working tree* against HEAD — not against the remote. In a typical pre-push scenario all changes are committed, so this fallback will almost never match anything useful. If the intent is just to handle the "no remote tracking branch" case, the fallback could be scoped more explicitly (e.g. `git diff --name-only HEAD~1..HEAD`) to avoid the surprising mix of committed vs. uncommitted semantics.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: src/gateway/server-methods/chat.ts
Line: 95
Comment:
**Default raised 5× — existing deployments will see larger history responses**
The previous hardcoded limit was `12_000`; the new default is `64_000`. Any existing deployment that relies on the old ceiling will now receive responses up to 5× larger without any config change. This is likely intentional (and documented in `schema.help.ts`), but worth confirming that any downstream consumers of `chat.history` — especially the macOS client — handle the larger payload gracefully without a memory or display regression.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "feat(gateway): make chat history max cha..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b65ed1716a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
Adds configurability for chat.history text truncation in the gateway (config + per-request override), updates the gateway protocol/Swift client models accordingly, and introduces a local pre-push CI mirror script while stabilizing a few extension tests.
Changes:
- Make
chat.historytruncation limit configurable viagateway.webchat.chatHistoryMaxCharsand RPCmaxChars. - Extend the gateway protocol schema and Swift client models to include
maxChars. - Add
prepush:cihelper script and improve test robustness in several extensions.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/gateway/server.chat.gateway-server-chat-b.test.ts | Adds gateway chat.history tests for config/RPC maxChars. |
| src/gateway/server-methods/chat.ts | Implements configurable per-field truncation for chat.history sanitization. |
| src/gateway/protocol/schema/logs-chat.ts | Extends chat.history params schema with maxChars. |
| src/config/zod-schema.ts | Adds gateway.webchat.chatHistoryMaxChars to validated config schema. |
| src/config/types.gateway.ts | Introduces GatewayWebchatConfig and gateway.webchat typing/docs. |
| src/config/schema.labels.ts | Adds label for gateway.webchat.chatHistoryMaxChars. |
| src/config/schema.help.ts | Adds help text for gateway.webchat.chatHistoryMaxChars. |
| scripts/prepush-ci.sh | Adds a local CI mirror script (linux + conditional macOS checks). |
| package.json | Adds prepush:ci script entry. |
| extensions/zalo/src/monitor.webhook.test.ts | Improves HTTP server teardown by tracking/destroying sockets. |
| extensions/thread-ownership/index.test.ts | Switches to vi.stubGlobal/vi.unstubAllGlobals for fetch mocking. |
| extensions/feishu/src/docx.test.ts | Moves hoisted mocks to module scope for consistent mocking behavior. |
| apps/shared/OpenClawKit/Sources/OpenClawProtocol/GatewayModels.swift | Updates generated protocol model ChatHistoryParams to include maxChars. |
| apps/macos/Sources/OpenClawProtocol/GatewayModels.swift | Same protocol model update for macOS target. |
| apps/macos/Sources/OpenClaw/GatewayConnection.swift | Exposes maxChars in macOS chatHistory API and request params. |
b65ed17 to
eb5a4e6
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1ca388ce54
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const text = extractAssistantTextForSilentCheck(message); | ||
| if (text !== undefined && isSilentReplyText(text, SILENT_REPLY_TOKEN)) { |
There was a problem hiding this comment.
Strip directives before silent-token history filtering
The silent-reply check now runs on the raw assistant message before sanitizeChatHistoryMessage(...) removes inline directive tags, so an entry like [[reply_to_current]]NO_REPLY is no longer recognized as silent and is returned by chat.history as a visible NO_REPLY message. This is a regression in suppression behavior for directive-tagged assistant text and can leak messages that should be dropped.
Useful? React with 👍 / 👎.
* feat(gateway): make chat history max chars configurable * fix(gateway): address review feedback * docs(changelog): note configurable chat history limits
* feat(gateway): make chat history max chars configurable * fix(gateway): address review feedback * docs(changelog): note configurable chat history limits
* feat(gateway): make chat history max chars configurable * fix(gateway): address review feedback * docs(changelog): note configurable chat history limits
* feat(gateway): make chat history max chars configurable * fix(gateway): address review feedback * docs(changelog): note configurable chat history limits
Summary
chat.historymax text truncation configurable viagateway.webchat.chatHistoryMaxCharsand per-requestmaxCharsusage/costmetadata preservation intact while applying the new truncation limitmaxCharsrequest parameter in the gateway protocol and macOS Swift client modelsprepush:cimirror script and stabilize a few extension tests needed for local CI signalWhy
chat.historybehaviormainstill hardcodes the history text limit, so the feature is still useful, but it needed a fresh implementation on top of current semanticsValidation
pnpm exec vitest run src/gateway/server.chat.gateway-server-chat-b.test.ts src/gateway/server.chat.gateway-server-chat.test.ts src/config/schema.help.quality.test.tspnpm exec vitest run --config vitest.extensions.config.ts extensions/feishu/src/docx.test.ts extensions/thread-ownership/index.test.ts extensions/zalo/src/monitor.webhook.test.tsbash scripts/prepush-ci.shgot throughpnpm check,pnpm build:strict-smoke,pnpm lint:ui:no-raw-window-open, protocol generation, and bundleNotes
main:extensions/openshell/src/remote-fs-bridge.test.ts