feat: add MaxAttachments to Model struct and Gemini/Vertex configs (#258)#272
Open
mvanhorn wants to merge 1 commit intocharmbracelet:mainfrom
Open
feat: add MaxAttachments to Model struct and Gemini/Vertex configs (#258)#272mvanhorn wants to merge 1 commit intocharmbracelet:mainfrom
mvanhorn wants to merge 1 commit intocharmbracelet:mainfrom
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #258.
What changed
MaxAttachments int64to theModelstruct, with json tagmax_attachments,omitempty. Documented inline that zero means "no provider-enforced cap" and a positive value is a hard cap the consumer must respect.max_attachments: 10.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:Carrying the limit on
Modelitself moves it to the same boundary that already carriescontext_window,default_max_tokens,cost_per_1m_in, etc. Theomitemptytag keeps existing consumers that don't know about the field unaffected.Verification
go build ./...— cleango test ./...—internal/providerstest passes (TestValidDefaultModels)max_attachments=10on every model