Multiple attachments can overflow the context window, error message is unclear #15096
Replies: 3 comments
|
Thanks for the detailed report and reproduction details. The underlying behavior is understood, but the appropriate fix, especially a dynamic cumulative token-budget check, needs product and implementation discussion before it can be scoped as an issue. I’m moving this to Discussions so we can settle the intended behavior. Once there’s a concrete direction, we can open a focused implementation issue. |
|
I think this is worth treating as a budget-accounting problem rather than only an error-message problem. The current failure is confusing because the user sees an A useful contract would be: For short-term behavior, I would make the error identify the oversized budget class explicitly. Something like: For longer-term behavior, the check probably has to happen after extraction/tokenization, not only at upload time. Byte limits are still useful for storage and abuse prevention, but they cannot reliably predict model tokens across PDF/doc parsing, OCR, markdown conversion, or structured file expansion. The regression test I would want is:
That keeps the current pruning logic honest: if no unit fits after pruning, the system should report which unit overflowed. In this case, the unit is the cumulative attachment payload, not the user's typed message. |
|
Thanks for the detailed report with the full token-budget breakdown, and for the design notes above. Two details I checked against The Where this comes from on main
|
Uh oh!
There was an error while loading. Please reload this page.
What happened?
When attaching files to a chat, each file can get correctly truncated to respect the
fileTokenLimit, but a user may be allowed to upload enough files to overflow the available context for the current chat. For example, on Sonnet 4.5 the entire context window is just 200k tokens, and with the defaultfileTokenLimitat 100k, it can take just two files to overflow the entire context window.Rather than reporting an issue related to the files, LibreChat reports an error of type
empty_messages:To me, it seems like it would be very unclear to a user that this error might be related to their uploaded files, it seems to point to the user's chat message instead, but in this scenario, the size of the message can be arbitrarily small while still triggering the issue.
LibreChat already has size controls for file uploads (
fileSizeLimit,totalSizeLimit) and those have clear and helpful error messages when they are broken, but:Short term, perhaps error messaging could be updated to catch this case, but long term, I would propose some kind of cumulative token-budget check on every uploaded file, and then throwing an error when a file currently being uploaded would overflow the chat's remaining token-budget.
Version Information
LibreChat version: v0.8.8-rc1
Commit: eaef87f
Branch: main
Build date: 2026-08-14 07:28:58 UTC
User agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36
Steps to Reproduce
fileTokenLimitto some value less than your model's context windowN * fileTokenLimitapproaches or goes over the context window sizeWhat browsers are you seeing the problem on?
No response
Relevant log output
{ "level": "warn", "message": "[textTokenLimiter] Text truncated from 3375285 to 97958 tokens (limit: 100000)", "requestId": "4113a72a-54d4-441d-8df3-b98e197df67d", "request_id": "4113a72a-54d4-441d-8df3-b98e197df67d", "request_method": "POST", "request_path": "/api/agents", "timestamp": "2026-08-18T05:04:43.487Z", "userId": "69fdf0af9055e092ab88622f" } { "level": "warn", "message": "[textTokenLimiter] Text truncated from 4999355 to 97963 tokens (limit: 100000)", "requestId": "4113a72a-54d4-441d-8df3-b98e197df67d", "request_id": "4113a72a-54d4-441d-8df3-b98e197df67d", "request_method": "POST", "request_path": "/api/agents", "timestamp": "2026-08-18T05:04:46.292Z", "userId": "69fdf0af9055e092ab88622f" } { "agentId": "bedrock__us.anthropic.claude-sonnet-4-5-20250929-v1__0___Claude Sonnet 4.5", "level": "info", "message": "[agents:graph] Summarization triggered", "requestId": "4113a72a-54d4-441d-8df3-b98e197df67d", "request_id": "4113a72a-54d4-441d-8df3-b98e197df67d", "request_method": "POST", "request_path": "/api/agents", "runId": "83f56351-e002-4cf4-994f-c91f8e2d648d", "timestamp": "2026-08-18T05:04:47.789Z", "userId": "69fdf0af9055e092ab88622f" } { "agentId": "bedrock__us.anthropic.claude-sonnet-4-5-20250929-v1__0___Claude Sonnet 4.5", "level": "info", "message": "[agents:prune] Emergency truncation complete", "requestId": "4113a72a-54d4-441d-8df3-b98e197df67d", "request_id": "4113a72a-54d4-441d-8df3-b98e197df67d", "request_method": "POST", "request_path": "/api/agents", "runId": "83f56351-e002-4cf4-994f-c91f8e2d648d", "timestamp": "2026-08-18T05:04:47.789Z", "userId": "69fdf0af9055e092ab88622f" } { "agentId": "bedrock__us.anthropic.claude-sonnet-4-5-20250929-v1__0___Claude Sonnet 4.5", "effectiveMax": 122657, "emergencyMaxChars": 490628, "level": "warn", "message": "[agents:prune] Empty context, entering emergency truncation", "messageCount": 1, "requestId": "4113a72a-54d4-441d-8df3-b98e197df67d", "request_id": "4113a72a-54d4-441d-8df3-b98e197df67d", "request_method": "POST", "request_path": "/api/agents", "runId": "83f56351-e002-4cf4-994f-c91f8e2d648d", "timestamp": "2026-08-18T05:04:47.788Z", "userId": "69fdf0af9055e092ab88622f" } { "agentId": "bedrock__us.anthropic.claude-sonnet-4-5-20250929-v1__0___Claude Sonnet 4.5", "level": "info", "message": "[agents:prune] Emergency truncation complete", "requestId": "4113a72a-54d4-441d-8df3-b98e197df67d", "request_id": "4113a72a-54d4-441d-8df3-b98e197df67d", "request_method": "POST", "request_path": "/api/agents", "runId": "83f56351-e002-4cf4-994f-c91f8e2d648d", "timestamp": "2026-08-18T05:04:47.811Z", "userId": "69fdf0af9055e092ab88622f" } { "agentId": "bedrock__us.anthropic.claude-sonnet-4-5-20250929-v1__0___Claude Sonnet 4.5", "effectiveMax": 122657, "emergencyMaxChars": 490628, "level": "warn", "message": "[agents:prune] Empty context, entering emergency truncation", "messageCount": 1, "requestId": "4113a72a-54d4-441d-8df3-b98e197df67d", "request_id": "4113a72a-54d4-441d-8df3-b98e197df67d", "request_method": "POST", "request_path": "/api/agents", "runId": "83f56351-e002-4cf4-994f-c91f8e2d648d", "timestamp": "2026-08-18T05:04:47.811Z", "userId": "69fdf0af9055e092ab88622f" } { "agentId": "bedrock__us.anthropic.claude-sonnet-4-5-20250929-v1__0___Claude Sonnet 4.5", "breakdown": "Token budget breakdown:\n maxContextTokens: 129200\n instructionTokens: 83 (system: 83, dynamic: 0, tools: 0 [0 tools])\n summaryTokens: 0\n messageTokens: 196113 (1 messages)\n availableForMessages: 122657", "instructionsExceedBudget": false, "level": "error", "message": "[agents:graph] Empty messages after pruning", "messageCount": 1, "requestId": "4113a72a-54d4-441d-8df3-b98e197df67d", "request_id": "4113a72a-54d4-441d-8df3-b98e197df67d", "request_method": "POST", "request_path": "/api/agents", "runId": "83f56351-e002-4cf4-994f-c91f8e2d648d", "timestamp": "2026-08-18T05:04:47.813Z", "userId": "69fdf0af9055e092ab88622f" } { "level": "error", "message": "{\"type\":\"empty_messages\",\"info\":\"Message pruning removed all messages as none fit in the context window. Please increase the context window size or make your message shorter.\\nToken budget breakdown:\\n maxContextTokens: 129200\\n instructionTokens: ...", "name": "Error", "pregelTaskId": "f42a0e29-3f93-59d5-9fae-3c9afaf663c5", "requestId": "4113a72a-54d4-441d-8df3-b98e197df67d", "request_id": "4113a72a-54d4-441d-8df3-b98e197df67d", "request_method": "POST", "request_path": "/api/agents", "stack": "Error: {\"type\":\"empty_messages\",\"info\":\"Message pruning removed all messages as none fit in the context window. Please increase the context window size or make your message shorter.\\nToken budget breakdown:\\n maxContextTokens: 129200\\n instructionTok...", "timestamp": "2026-08-18T05:04:47.818Z", "userId": "69fdf0af9055e092ab88622f" }Screenshots
Code of Conduct
All reactions