fix(agent): inject media store in isolation and fix config unmarshal panic
This commit is contained in:
parent
3d621b6401
commit
253412a526
2 changed files with 26 additions and 0 deletions
|
|
@ -1469,6 +1469,9 @@ func (al *AgentLoop) processMessage(ctx context.Context, msg bus.InboundMessage)
|
|||
// Set its ID to match the routed agent so prompts and logs match
|
||||
agent.ID = route.AgentID
|
||||
|
||||
// Inject media store so tools (like send_file) can function
|
||||
agent.Tools.SetMediaStore(al.mediaStore)
|
||||
|
||||
// Re-register shared tools (web, message, spawn) to this transient agent
|
||||
// We pass a mini-registry containing only this agent
|
||||
registerSharedTools(al, al.cfg, al.bus, &AgentRegistry{agents: map[string]*AgentInstance{agent.ID: agent}}, baseAgent.Provider)
|
||||
|
|
|
|||
|
|
@ -1270,6 +1270,29 @@ func (c *Config) SecurityCopyFrom(path string) error {
|
|||
return loadSecurityConfig(c, securityPath(path))
|
||||
}
|
||||
|
||||
func MergeAPIKeys(apiKey string, apiKeys []string) []string {
|
||||
seen := make(map[string]struct{})
|
||||
var all []string
|
||||
|
||||
if k := strings.TrimSpace(apiKey); k != "" {
|
||||
if _, exists := seen[k]; !exists {
|
||||
seen[k] = struct{}{}
|
||||
all = append(all, k)
|
||||
}
|
||||
}
|
||||
|
||||
for _, k := range apiKeys {
|
||||
if trimmed := strings.TrimSpace(k); trimmed != "" && trimmed != "[NOT_HERE]" {
|
||||
if _, exists := seen[trimmed]; !exists {
|
||||
seen[trimmed] = struct{}{}
|
||||
all = append(all, trimmed)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return all
|
||||
}
|
||||
|
||||
// expandMultiKeyModels expands ModelConfig entries with multiple API keys into
|
||||
// separate entries for key-level failover. Each key gets its own ModelConfig entry,
|
||||
// and the original entry's fallbacks are set up to chain through the expanded entries.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue