Make the 16-image conversation limit configurable and batching-aware

Aperta
#1,080 2 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
58/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
c

Direzione di ricerca

Trace the fixed 16-image checks and replay structures in visible_image_key, visible_prompt_key, and build_live_prompt_suffix, then inspect how --batched-session is parsed and applied. Verify the 16/17-image reproducer and text-only replay behavior. Done means --max-images controls validation and replay bookkeeping, defaults differ for batched sessions, errors show actual and configured counts, and the replay limit is documented.

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

Descrizione

ds4-server rejects requests containing more than 16 images:

size_t count = 0;
for (int i = 0; msgs && i < msgs->len; i++)
    count += msgs->v[i].images.len;

if (count > 16) {
    snprintf(err, errlen, "too many images; at most 16 are allowed");
    return false;
}

This counts images across the submitted history, not only the newest turn.

DS4 requires Chat Completions and Anthropic clients to replay conversation history. Its Responses endpoint likewise rejects durable previous_response_id/conversation references and instructs clients to replay the full input.

The request limit therefore becomes a cumulative conversation limit. Once history contains 17 images, every subsequent request fails before inference, including text-only turns. Retrying cannot recover because it submits the same history. The client must rewrite or discard history, and the model cannot handle the condition because it never receives another turn.

This is easy to reach in agent workflows that retain screenshots or other image tool results.

Reproducer

Submit a request containing N small images:

Images Result
16 200
17 400: too many images; at most 16 are allowed

Append a text-only message and replay the same history. The request returns the same 400 before prefill.

Current implementation

The limit was introduced with server-side vision in 4771329 (2026-08-28). It is also embedded in replay bookkeeping:

  • Request validation rejects count > 16.
  • visible_image_key contains offsets[16].
  • visible_prompt_key rejects req->image_count > 16.
  • build_live_prompt_suffix rejects req->image_count > 16 and uses ds4_vision_span spans[16].

Later image-embedding caching avoids encoder execution on cache hits, although request-owned embedding memory still scales with image count.

Relation to --batched-session

Cold image encoding holds the global inference_mu. With --batched-session N>1, an image-heavy request can therefore delay other resident sessions, making a conservative default useful for fairness.

With one resident session, there is no cross-slot inference contention. Request memory and abuse protection still justify a limit, but the case for a low ceiling of 16 is weaker: the operator may prefer accepting higher latency or memory use over making the conversation unusable.

Requested change

Add:

--max-images N

Suggested defaults:

  • --batched-session N>1: default to 16.
  • One resident session: use a higher or resource-derived default.
  • An explicit --max-images value overrides either default.

Implementation would need to replace the fixed [16] replay structures and validation literals with the configured limit.

Also:

  • Document that replayed history counts toward the limit.

  • Include the actual and configured counts in the error:

    request contains 17 images; server limit is 16 (--max-images)
    

This preserves a conservative fairness bound for batched serving while allowing single-session and replay-heavy deployments to choose an appropriate limit.

Happy to make a PR if the solution direction is ok.

Lingua principale
C
Stelle
24.4k
Fork
2.4k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

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 antirez/ds4

Tutte le issue di antirez/ds4

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.