Skip to content

feat: add MaxAttachments field to Model struct#259

Open
iceymoss wants to merge 1 commit intocharmbracelet:mainfrom
iceymoss:feat/max-attachments
Open

feat: add MaxAttachments field to Model struct#259
iceymoss wants to merge 1 commit intocharmbracelet:mainfrom
iceymoss:feat/max-attachments

Conversation

@iceymoss
Copy link
Copy Markdown

Summary

  • Add MaxAttachments int field to catwalk.Model struct (json:"max_attachments,omitempty")
  • Set max_attachments: 10 for all Gemini models in gemini.json and vertexai.json

Motivation

Some AI providers enforce hard per-request limits on image attachments. For example, Google Gemini caps at 10 images per request — exceeding this makes sessions permanently unusable (see charmbracelet/crush#2604). Currently there is no way to express this limit in Catwalk's Model struct, forcing downstream consumers to hard-code provider-specific limits.

Changes

pkg/catwalk/provider.go

type Model struct {
    // ... existing fields ...
    SupportsImages         bool         `json:"supports_attachments"`
    MaxAttachments         int          `json:"max_attachments,omitempty"` // NEW
    Options                ModelOptions `json:"options,omitzero"`
}

Semantics:

  • 0 (zero / omitted): no hard limit, rely on context window limits instead
  • > 0: maximum number of image attachments allowed in a single request

internal/providers/configs/gemini.json

Add "max_attachments": 10 to all 6 Gemini models.

internal/providers/configs/vertexai.json

Add "max_attachments": 10 to all 6 Gemini models. Claude models on Vertex AI are left without the field (no known hard limit).

Known limits

Provider Model Limit Source
Gemini All models 10 Google docs
Vertex AI Gemini models 10 Same as Gemini
Anthropic All models No hard limit (context window)
OpenAI All models No hard limit (context window)

Downstream impact

Once this ships, Crush can replace its hard-coded maxImagesForModel() switch with a simple read from model.CatwalkCfg.MaxAttachments, eliminating provider-specific logic from the consumer side.

Test plan

  • go build ./... — passes
  • go test ./... -count=1 — all existing tests pass
  • JSON configs correctly deserialize with the new field

Closes #258

Add a per-model MaxAttachments field that specifies the maximum number
of image attachments allowed in a single request. A value of 0 means
no hard limit (context window governs).

Set max_attachments: 10 for all Gemini and Vertex AI Gemini models,
which enforce a 10-image per-request cap.

Closes charmbracelet#258
@iceymoss iceymoss requested a review from andreynering as a code owner April 24, 2026 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Add MaxAttachments field to Model struct

1 participant