mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-04-15 00:27:29 +08:00
Tighten subagent prompt file workflow
This commit is contained in:
@@ -49,11 +49,18 @@ func UpsertConfigSubagent(configPath string, args map[string]interface{}) (map[s
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mainID := strings.TrimSpace(cfg.Agents.Router.MainAgentID)
|
||||
if mainID == "" {
|
||||
mainID = "main"
|
||||
}
|
||||
if cfg.Agents.Subagents == nil {
|
||||
cfg.Agents.Subagents = map[string]config.SubagentConfig{}
|
||||
}
|
||||
subcfg := cfg.Agents.Subagents[agentID]
|
||||
if enabled, ok := boolArgFromMap(args, "enabled"); ok {
|
||||
if agentID == mainID && !enabled {
|
||||
return nil, fmt.Errorf("main agent %q cannot be disabled", agentID)
|
||||
}
|
||||
subcfg.Enabled = enabled
|
||||
} else if !subcfg.Enabled {
|
||||
subcfg.Enabled = true
|
||||
@@ -84,6 +91,9 @@ func UpsertConfigSubagent(configPath string, args map[string]interface{}) (map[s
|
||||
} else if strings.TrimSpace(subcfg.Type) == "" {
|
||||
subcfg.Type = "worker"
|
||||
}
|
||||
if subcfg.Enabled && strings.TrimSpace(subcfg.SystemPromptFile) == "" {
|
||||
return nil, fmt.Errorf("system_prompt_file is required for enabled agent %q", agentID)
|
||||
}
|
||||
cfg.Agents.Subagents[agentID] = subcfg
|
||||
if kws := stringListArgFromMap(args, "routing_keywords"); len(kws) > 0 {
|
||||
cfg.Agents.Router.Rules = upsertRouteRuleConfig(cfg.Agents.Router.Rules, config.AgentRouteRule{
|
||||
@@ -123,6 +133,13 @@ func DeleteConfigSubagent(configPath, agentID string) (map[string]interface{}, e
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mainID := strings.TrimSpace(cfg.Agents.Router.MainAgentID)
|
||||
if mainID == "" {
|
||||
mainID = "main"
|
||||
}
|
||||
if agentID == mainID {
|
||||
return nil, fmt.Errorf("main agent %q cannot be deleted", agentID)
|
||||
}
|
||||
if cfg.Agents.Subagents == nil {
|
||||
return map[string]interface{}{"ok": false, "found": false, "agent_id": agentID}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user