fix(agent): inject media store in isolation and fix config unmarshal panic

This commit is contained in:
stevef 2026-03-27 17:52:29 +01:00
parent daf6861f46
commit d289d68091
2 changed files with 26 additions and 0 deletions

View file

@ -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 // Set its ID to match the routed agent so prompts and logs match
agent.ID = route.AgentID 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 // Re-register shared tools (web, message, spawn) to this transient agent
// We pass a mini-registry containing only this 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) registerSharedTools(al, al.cfg, al.bus, &AgentRegistry{agents: map[string]*AgentInstance{agent.ID: agent}}, baseAgent.Provider)

View file

@ -1259,6 +1259,29 @@ func (c *Config) SecurityCopyFrom(path string) error {
return loadSecurityConfig(c, securityPath(path)) 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 // expandMultiKeyModels expands ModelConfig entries with multiple API keys into
// separate entries for key-level failover. Each key gets its own ModelConfig entry, // 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. // and the original entry's fallbacks are set up to chain through the expanded entries.