feat: wire image_model config to agent loop for vision-capable models
- Add ImageModel and ImageModelCandidates fields to AgentInstance - Resolve image_model candidates at agent creation time - Route to image_model when media attachments are detected in selectCandidates Fixes issue #1578
This commit is contained in:
parent
f2addff099
commit
32c7637a5e
1 changed files with 22 additions and 0 deletions
|
|
@ -47,6 +47,11 @@ type AgentInstance struct {
|
||||||
// LightCandidates holds the resolved provider candidates for the light model.
|
// LightCandidates holds the resolved provider candidates for the light model.
|
||||||
// Pre-computed at agent creation to avoid repeated model_list lookups at runtime.
|
// Pre-computed at agent creation to avoid repeated model_list lookups at runtime.
|
||||||
LightCandidates []providers.FallbackCandidate
|
LightCandidates []providers.FallbackCandidate
|
||||||
|
// ImageModel holds the configured image model name from config.
|
||||||
|
ImageModel string
|
||||||
|
// ImageModelCandidates holds the resolved provider candidates for the image model.
|
||||||
|
// Pre-computed at agent creation to avoid repeated model_list lookups at runtime.
|
||||||
|
ImageModelCandidates []providers.FallbackCandidate
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewAgentInstance creates an agent instance from config.
|
// NewAgentInstance creates an agent instance from config.
|
||||||
|
|
@ -214,6 +219,21 @@ func NewAgentInstance(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Image model setup: pre-resolve image model candidates at creation time
|
||||||
|
// to avoid repeated model_list lookups when processing image attachments.
|
||||||
|
var imageModelCandidates []providers.FallbackCandidate
|
||||||
|
imageModel := defaults.ImageModel
|
||||||
|
if imageModel != "" {
|
||||||
|
imageModelCfg := providers.ModelConfig{Primary: imageModel, Fallbacks: defaults.ImageModelFallbacks}
|
||||||
|
resolved := providers.ResolveCandidatesWithLookup(imageModelCfg, defaults.Provider, resolveFromModelList)
|
||||||
|
if len(resolved) > 0 {
|
||||||
|
imageModelCandidates = resolved
|
||||||
|
} else {
|
||||||
|
log.Printf("image_model %q not found in model_list — image attachments will use primary model",
|
||||||
|
imageModel)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return &AgentInstance{
|
return &AgentInstance{
|
||||||
ID: agentID,
|
ID: agentID,
|
||||||
Name: agentName,
|
Name: agentName,
|
||||||
|
|
@ -236,6 +256,8 @@ func NewAgentInstance(
|
||||||
Candidates: candidates,
|
Candidates: candidates,
|
||||||
Router: router,
|
Router: router,
|
||||||
LightCandidates: lightCandidates,
|
LightCandidates: lightCandidates,
|
||||||
|
ImageModel: imageModel,
|
||||||
|
ImageModelCandidates: imageModelCandidates,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue