Fix oversized chat session message loads#874
Merged
simple-agent-manager[bot] merged 2 commits intomainfrom May 1, 2026
Merged
Conversation
|
This was referenced May 1, 2026
simple-agent-manager Bot
pushed a commit
that referenced
this pull request
May 5, 2026
Two regressions from PR #874 (May 1): 1. Message limit dropped from 1000 to 200 by reusing SAM_HISTORY_LOAD_LIMIT (designed for SAM conversation persistence) for chat session REST endpoints. Added DEFAULT_CHAT_SESSION_MESSAGE_LIMIT (3000) with CHAT_SESSION_MESSAGE_LIMIT env var override. 2. Polling fallback (every 3s) and WebSocket catch-up used 'replace' merge strategy that discarded all earlier-loaded messages. After clicking "Load earlier messages", the next poll cycle would reset back to 200. Fixed mergeReplace() to preserve messages older than the incoming window, and removed hasMore reset from polling/catch-up (only initial load and explicit loadMore should update pagination state). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
6 tasks
simple-agent-manager Bot
added a commit
that referenced
this pull request
May 5, 2026
#898) * task: activate fix-chat-message-loading-regression Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: restore chat message loading limits and preserve earlier messages Two regressions from PR #874 (May 1): 1. Message limit dropped from 1000 to 200 by reusing SAM_HISTORY_LOAD_LIMIT (designed for SAM conversation persistence) for chat session REST endpoints. Added DEFAULT_CHAT_SESSION_MESSAGE_LIMIT (3000) with CHAT_SESSION_MESSAGE_LIMIT env var override. 2. Polling fallback (every 3s) and WebSocket catch-up used 'replace' merge strategy that discarded all earlier-loaded messages. After clicking "Load earlier messages", the next poll cycle would reset back to 200. Fixed mergeReplace() to preserve messages older than the incoming window, and removed hasMore reset from polling/catch-up (only initial load and explicit loadMore should update pagination state). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: correct test syntax error and update catch-up test expectation - Fix extra closing brace in merge-messages.test.ts that caused parse error - Update project-message-view catch-up test: empty incoming now correctly preserves existing messages (intentional behavior change from the fix) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: address review findings — move constant, clean onCatchUp interface - Move DEFAULT_CHAT_SESSION_MESSAGE_LIMIT from sam.ts to defaults.ts (it's a chat REST limit, not a SAM agent constant) - Remove hasMore param from onCatchUp interface in useChatWebSocket.ts (catch-up should not reset pagination state) - Update WorkspaceChatView.tsx onCatchUp to match new 2-param contract - Update test mocks to match new interface Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: prevent silent message drop at same-timestamp boundary The mergeReplace boundary condition now preserves messages from prev at the same timestamp as oldestIncoming when their ID is not in the incoming set. This prevents silent drops when the server returns only some messages at the boundary timestamp (e.g., batched tool calls). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Raphaël Titsworth-Morin <raphael@raphaeltm.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Production Investigation
Agent Preflight
Classification
External References
Cloudflare Workers Observability logs were queried directly with the production debugging token to identify the runtime exception. No external API contract changed.
Codebase Impact Analysis
Changed apps/api/src/routes/chat.ts session-detail loading behavior and apps/api/tests/unit/routes/chat-session-agent-routing.test.ts regression coverage. Added tasks/backlog/2026-05-01-tail-worker-log-ingest-auth.md for a separate log-ingest issue found during investigation.
Documentation & Specs
No behavior docs required for the API cap itself; the discovered tail-worker observability bug was documented as a backlog task with context and acceptance criteria.
Constitution & Risk Check
Checked Principle XI by using existing configurable SAM_HISTORY_LOAD_LIMIT with DEFAULT_SAM_HISTORY_LOAD_LIMIT rather than adding a new hardcoded limit. Risk is bounded to initial/paginated chat history batch size; UI already supports hasMore pagination.
Verification
Specialist Review Evidence
Staging