From 77017eb57d58aa7f3c3362703baaa356a7e9f2af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E6=99=BA=E8=B6=850668000959?= Date: Mon, 8 Jun 2026 17:25:19 +0800 Subject: [PATCH] fix(tools): add ok checks for type assertions in subagent and spawn tools --- pkg/tools/spawn.go | 10 ++++++++-- pkg/tools/subagent.go | 5 ++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/pkg/tools/spawn.go b/pkg/tools/spawn.go index a9a373856..225c2a4b2 100644 --- a/pkg/tools/spawn.go +++ b/pkg/tools/spawn.go @@ -90,8 +90,14 @@ func (t *SpawnTool) execute( return ErrorResult("task is required and must be a non-empty string") } - label, _ := args["label"].(string) - agentID, _ := args["agent_id"].(string) + label, ok := args["label"].(string) + if !ok { + label = "" + } + agentID, ok := args["agent_id"].(string) + if !ok { + agentID = "" + } targetAgentID := strings.TrimSpace(agentID) // Check allowlist if targeting a specific agent diff --git a/pkg/tools/subagent.go b/pkg/tools/subagent.go index feeabe536..1122d5157 100644 --- a/pkg/tools/subagent.go +++ b/pkg/tools/subagent.go @@ -391,7 +391,10 @@ func (t *SubagentTool) Execute(ctx context.Context, args map[string]any) *ToolRe return ErrorResult("task is required").WithError(fmt.Errorf("task parameter is required")) } - label, _ := args["label"].(string) + label, ok := args["label"].(string) + if !ok { + label = "" + } // Build system prompt for subagent systemPrompt := fmt.Sprintf(