Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

A request the API rejects (400/413) keeps its user message in history and breaks the chat

Chiusa
#240 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
42/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
ai, backend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug priority: high severity: high

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 (acceptsImages is 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; acceptsImages is 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.

Lingua principale
TypeScript
Stelle
2
Fork
2
Merge medio
3h 50m
PR unite (30g)
67

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di PierrunoYT/patch

Tutte le issue di PierrunoYT/patch

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.