Skip to content

Stop the chat from sending its whole history with each message - #245

Merged
clbotdev merged 1 commit into
mainfrom
fix/chat-history-limit
Nov 28, 2026
Merged

clbotdev merged 1 commit into
mainfrom
fix/chat-history-limit

Conversation

@clbotdev

Copy link
Copy Markdown
Contributor

Problem

Once an embedded chat passed 20 messages, every new message failed with `400 too_big` and the visitor saw "Sorry, something went wrong. Please try again."

The chat sent all earlier messages as `history` with each new one, and the API capped that field at 20. The API stopped reading `history` when persisted ticket messages became the model's history (see `apps/api/docs/ai-agent.md`). The client kept sending it, and the cap stayed.

Fix

  • The chat sends only the new message (plus the conversation ID and token).
  • Removed `history` from the public chat request schema and updated the doc.

Testing

  • Typecheck passes, and the drift check passes.
  • API tests: `critical-path`, `sessions`, `alerts` and `conformance` all pass, 17 tests.
  • Local browser test: in a chat with 22 messages, message 23 sent with a 200 response, and the "Message sent" notice showed with no error. Before the fix, the same request got a 400.

The chat sent every earlier message as `history` alongside the new one,
and the API capped that field at 20 entries. The API stopped reading it
when persisted ticket messages became the model history, so once a
conversation passed 20 messages every new message failed with a 400 and
the visitor saw "Sorry, something went wrong". The chat now sends only
the new message, and the field is gone from the API.
@clbotdev

Copy link
Copy Markdown
Contributor Author

QA e2e passed. I deployed sites image qa-pr245-467bbdb (this fix on top of #242 + #243). In an embedded chat with 22 messages, message 23 sent with a 200 response and showed the "Message sent" notice, with no error. Before the fix, the same send returned 400 too_big.

@clbotdev
clbotdev merged commit fbbfb58 into main Nov 28, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants