A request the API rejects (400/413) keeps its user message in history and breaks the chat
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 42/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- typescript
Research direction
Start in agent/agent.ts at Agent.send (around lines 124-127), where addUserMessage runs before run, and at retryDecision, which returns null for 400/413. The minimal first step is to drop the trailing user message when the first request of a run fails with a non-retryable 4xx. Done means a test using MockApiServer that mocks a 400 on the first send, then sends again, shows the second request has no image. The image sniffing, size cap and tool-result changes are separate pieces and can be split off.
Written by the indexing model from the issue text.
Description
Found in the 2026-10-09 codebase audit.
Problem
Agent.send (agent/agent.ts:124-127) calls addUserMessage and then run; nothing removes the message when the request fails for good. retryDecision returns null for 400/413, but the message stays and every later request re-sends it. Compaction keeps the last ~40k characters, so it is never summarized away.
Confirmed with MockApiServer: after a 400 on a message with an image, the next send re-sent the image.
Triggers:
- An image to a text-only custom OpenAI-compatible model (
acceptsImagesis true for every non-Claude model). - Several large images over the 32 MB request limit (413).
- Tool-result images (browser screenshots, MCP image blocks) to a model that refuses them;
acceptsImagesis checked only for user attachments. - Possibly a media type that doesn't match the bytes (taken from the extension).
Fix
When the first request of a run fails with a non-retryable 4xx before any assistant turn is recorded, discard the trailing user message (a message the API never accepted is not part of history). Also sniff image magic bytes, cap the total image size per request, and replace tool-result images with text when the model doesn't accept images.
Test
Mock a 400 on the first send, send again; the second request has no image.
- Dominant language
- TypeScript
- Stars
- 2
- Forks
- 2
- Avg merge
- 5h 28m
- Merged PRs (30d)
- 24
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PierrunoYT/patch
-
enhancement priority: low security severity: low
Difficulty 4/5 3-5 days Newbie friendliness 35/100
PierrunoYT/patch#260 ·
Maintainers usually reply within 1 day
-
bug priority: low severity: low
Difficulty 3/5 1-2 days Newbie friendliness 25/100
PierrunoYT/patch#259 · 1 comment ·
Maintainers usually reply within 1 day
-
platform: macos priority: medium security severity: low tests
Difficulty 4/5 3-5 days Newbie friendliness 15/100
PierrunoYT/patch#257 ·
Maintainers usually reply within 1 day
-
bug platform: windows priority: medium severity: medium
Difficulty 4/5 3-5 days Newbie friendliness 30/100
PierrunoYT/patch#242 · 1 comment ·
Maintainers usually reply within 1 day
-
bug platform: macos priority: medium security severity: high
Difficulty 3/5 1-2 days Newbie friendliness 35/100
PierrunoYT/patch#232 · 1 comment ·
Maintainers usually reply within 1 day
All issues in PierrunoYT/patch
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:other issue-rating: 🦞 diamond lobster no-stale P2
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
openclaw/openclaw#168089 · 2 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
✨ enhancement needs-discussion
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
[Bug]: [MCP/CLI] Bare loopback IP addresses (127.0.0.1:port) and hosts with ports fail to navigate due to erroneous scheme inferencePossibly taken @alok-108 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/playwright#43263 ·
Maintainers usually reply within 1 day
-
area:studio type:security
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day