MCPcopy
hub / github.com/docker/docker-agent / Model

Method Model

pkg/agent/agent.go:183–199  ·  view source on GitHub ↗

Model returns the model to use for this agent. If model override(s) are set, it returns one of the overrides (randomly for alloy). Otherwise, it returns a random model from the available models. ctx is used for log correlation only — the selection itself is local. Pass [context.TODO] from callers t

(ctx context.Context)

Source from the content-addressed store, hash-verified

181// Pass [context.TODO] from callers that don't have a request context
182// (configuration validation, debug commands).
183func (a *Agent) Model(ctx context.Context) provider.Provider {
184 var selected provider.Provider
185 var poolSize int
186 // Check for model override first (set via TUI model switching)
187 if overrides := a.modelOverrides.Load(); overrides != nil && len(*overrides) > 0 {
188 selected = (*overrides)[rand.Intn(len(*overrides))]
189 poolSize = len(*overrides)
190 } else {
191 if len(a.models) == 0 {
192 return nil
193 }
194 selected = a.models[rand.Intn(len(a.models))]
195 poolSize = len(a.models)
196 }
197 slog.InfoContext(ctx, "Model selected", "agent", a.name, "model", selected.ID(), "pool_size", poolSize)
198 return selected
199}
200
201// SetModelOverride sets runtime model override(s) for this agent.
202// The override(s) take precedence over the configured models.

Callers 15

TitleModelsMethod · 0.95
AgentsInfoMethod · 0.80
runStreamLoopMethod · 0.80
TestWithAgentModelFunction · 0.80
NewLocalRuntimeFunction · 0.80
getAgentModelIDFunction · 0.80
compactWithReasonMethod · 0.80

Calls 2

IDMethod · 0.95
LoadMethod · 0.80