mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
fix(tools): prevent nil pointer dereference in spawn tools
Add nil checks in NewSpawnTool and NewSubagentTool constructors to handle nil manager gracefully. Fix spelling errors (cancelled->canceled) and remove unused test code. Update tests to use mock spawner.
This commit is contained in:
+4
-1
@@ -18,6 +18,9 @@ type SpawnTool struct {
|
||||
var _ AsyncExecutor = (*SpawnTool)(nil)
|
||||
|
||||
func NewSpawnTool(manager *SubagentManager) *SpawnTool {
|
||||
if manager == nil {
|
||||
return &SpawnTool{}
|
||||
}
|
||||
return &SpawnTool{
|
||||
defaultModel: manager.defaultModel,
|
||||
maxTokens: manager.maxTokens,
|
||||
@@ -131,5 +134,5 @@ Task: %s`, label, task)
|
||||
}
|
||||
|
||||
// Fallback: spawner not configured
|
||||
return ErrorResult("SpawnTool: spawner not configured - call SetSpawner() during initialization")
|
||||
return ErrorResult("Subagent manager not configured")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user