Skip to content

feat: add MaxAttachments to Model struct and Gemini/Vertex configs (#258)#272

Open
mvanhorn wants to merge 1 commit intocharmbracelet:mainfrom
mvanhorn:feat/max-attachments-issue-258
Open

feat: add MaxAttachments to Model struct and Gemini/Vertex configs (#258)#272
mvanhorn wants to merge 1 commit intocharmbracelet:mainfrom
mvanhorn:feat/max-attachments-issue-258

Conversation

@mvanhorn
Copy link
Copy Markdown

Closes #258.

What changed

  • pkg/catwalk/provider.go — added MaxAttachments int64 to the Model struct, with json tag max_attachments,omitempty. Documented inline that zero means "no provider-enforced cap" and a positive value is a hard cap the consumer must respect.
  • internal/providers/configs/gemini.json — all 6 models get max_attachments: 10.
  • internal/providers/configs/vertexai.json — all 11 models get max_attachments: 10.

The proposal in #258 lists Gemini and Vertex AI as the only providers with documented per-request image caps; Anthropic and OpenAI gate by context window, so their configs stay at the zero default.

Why this matters

Consumers like Crush hard-code map[InferenceProvider]int{InferenceProviderGemini: 10, ...} in their own source today. That breaks two things:

  1. Granularity: the lookup table is per-provider, so it can't represent a hypothetical future Gemini model with a different limit.
  2. Release coupling: every time a provider changes a limit, every consumer ships a release.

Carrying the limit on Model itself moves it to the same boundary that already carries context_window, default_max_tokens, cost_per_1m_in, etc. The omitempty tag keeps existing consumers that don't know about the field unaffected.

Verification

  • go build ./... — clean
  • go test ./...internal/providers test passes (TestValidDefaultModels)
  • Both updated JSON configs parse cleanly and report max_attachments=10 on every model

…harmbracelet#258)

Adds a per-model hard cap on image attachments so consumers (Crush and
others) can stop maintaining their own per-provider lookup tables for
image limits.

Changes:

- pkg/catwalk/provider.go
  Model gets a new MaxAttachments int64 field with json tag
  max_attachments,omitempty. Zero (the default) means no
  provider-enforced cap and the consumer should fall back to
  context-window sizing. A positive value is a hard cap the consumer
  must respect.

- internal/providers/configs/gemini.json
- internal/providers/configs/vertexai.json
  All Gemini models (6 in gemini.json, 11 in vertexai.json) get
  max_attachments: 10, matching Google's documented per-request limit.
  Anthropic / OpenAI / others stay unchanged so they keep the
  no-hard-limit zero default.

The omitempty tag means existing JSON consumers that don't know about
the field stay unaffected. New consumers can opt into the field as it
suits them.

Closes charmbracelet#258
@mvanhorn mvanhorn requested a review from andreynering as a code owner April 30, 2026 09:46
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