bug: uploading a JSON file inlines its full content into the prompt, causing "prompt is too long" errors
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
Uploading a JSON file to a Coder Agents chat appears to inline the entire file content into the prompt instead of handling it as an attachment. For a chat-export-style JSON file (version, scope: "chat", exported_at, ...), continuing the conversation after the upload immediately failed with:
Request failed
Anthropic returned an unexpected error.
prompt is too long: 2326643 tokens > 1000000 maximum
HTTP 4002.3M tokens from a single uploaded file is well past what should ever be sent as raw prompt content, which suggests the upload path is dumping the file inline (and possibly duplicating it turn over turn) rather than storing it out-of-band and referencing/summarizing it.
Session: https://dogfood.cdr.dev/agents/44f617c2-e8c8-45f0-aee1-3f914ec0d39b
Expected Behavior
Uploaded files (JSON in particular) should not blow the context window on a single upload. Options worth considering:
- Store the upload as an attachment/reference and let the model pull relevant portions instead of inlining the whole thing into the prompt.
- Chunk, truncate, or summarize large text/JSON uploads before they hit the model.
- At minimum, reject the upload (or warn) client-side when it would clearly exceed the model's context window, instead of silently accepting it and failing later with an opaque 400 on the next turn.
Steps to Reproduce
- Start a Coder Agents chat.
- Upload a moderately large JSON file (in this case, a chat export JSON).
- Send/continue the conversation.
- Observe the request fails with
prompt is too long: N tokens > 1000000 maximum(HTTP 400).
Relevant Log Output
Request failed
Anthropic returned an unexpected error.
prompt is too long: 2326643 tokens > 1000000 maximum
HTTP 400Environment
- Coder Agents (dogfood.cdr.dev)
- Model: Sonnet 5
Additional Context
No response
This issue was written by Coder Agents on behalf of @bpmct.
Source: coder/coder