diff --git a/pkg/agent/loop.go b/pkg/agent/loop.go index d85a02ce8..0edb4fd24 100644 --- a/pkg/agent/loop.go +++ b/pkg/agent/loop.go @@ -880,12 +880,12 @@ func formatDurationMs(ms int64) string { tenths := (ms % 1000) / 100 return fmt.Sprintf("%d.%ds", totalSec, tenths) } - min := totalSec / 60 + mins := totalSec / 60 sec := totalSec % 60 if sec == 0 { - return fmt.Sprintf("%dm", min) + return fmt.Sprintf("%dm", mins) } - return fmt.Sprintf("%dm%ds", min, sec) + return fmt.Sprintf("%dm%ds", mins, sec) } // acquireSessionLock gets or creates a per-session semaphore and acquires it. @@ -1152,8 +1152,11 @@ func (al *AgentLoop) runAgentLoop(ctx context.Context, agent *AgentInstance, opt "", nil, opts.Channel, opts.ChatID, ) messages = append(messages, providers.Message{ - Role: "user", - Content: fmt.Sprintf("[System] Phase %d is now active. Continue working on the next steps.", agent.ContextBuilder.GetCurrentPhase()), + Role: "user", + Content: fmt.Sprintf( + "[System] Phase %d is now active. Continue working on the next steps.", + agent.ContextBuilder.GetCurrentPhase(), + ), }) if len(messages) > 0 { al.lastSystemPrompt.Store(messages[0].Content) @@ -1240,7 +1243,7 @@ func (al *AgentLoop) runAgentLoop(ctx context.Context, agent *AgentInstance, opt if agent.ContextBuilder.IsCurrentPhaseComplete() { if phaseLoop >= maxPhaseTransitions { logger.WarnCF("agent", "Max phase transitions reached, stopping", - map[string]interface{}{"agent_id": agent.ID, "transitions": phaseLoop}) + map[string]any{"agent_id": agent.ID, "transitions": phaseLoop}) break } prev := agent.ContextBuilder.GetCurrentPhase() diff --git a/pkg/orch/reporter.go b/pkg/orch/reporter.go index 5294ac7f9..a717336ee 100644 --- a/pkg/orch/reporter.go +++ b/pkg/orch/reporter.go @@ -11,10 +11,10 @@ type AgentReporter interface { type noopReporter struct{} -func (n *noopReporter) ReportSpawn(id, label, task string) {} +func (n *noopReporter) ReportSpawn(id, label, task string) {} func (n *noopReporter) ReportStateChange(id string, state AgentState, tool string) {} -func (n *noopReporter) ReportConversation(from, to, text string) {} -func (n *noopReporter) ReportGC(id, reason string) {} +func (n *noopReporter) ReportConversation(from, to, text string) {} +func (n *noopReporter) ReportGC(id, reason string) {} // Noop is the AgentReporter to use when orchestration is disabled. // Allows nil-free code in callers. diff --git a/pkg/tools/shell.go b/pkg/tools/shell.go index 232976985..dd8a7f29d 100644 --- a/pkg/tools/shell.go +++ b/pkg/tools/shell.go @@ -903,7 +903,11 @@ func checkCurlLocalNet(command string) string { } host := u.Hostname() if !isLocalHost(host) { - return fmt.Sprintf("Command blocked by safety guard (curl/wget is restricted to localhost and private network; %q is a public address)", host) + return fmt.Sprintf( + "Command blocked by safety guard "+ + "(curl/wget is restricted to localhost and private network; %q is a public address)", + host, + ) } } return "" diff --git a/pkg/tools/spawn.go b/pkg/tools/spawn.go index bbb5ffdf9..fe1bb5259 100644 --- a/pkg/tools/spawn.go +++ b/pkg/tools/spawn.go @@ -73,7 +73,10 @@ func (t *SpawnTool) SetAllowlistChecker(check func(targetAgentID string) bool) { func (t *SpawnTool) Execute(ctx context.Context, args map[string]any) *ToolResult { task, ok := args["task"].(string) if !ok || strings.TrimSpace(task) == "" { - return ErrorResult(`Required parameter "task" (string) is missing. Example: {"task": "describe what you need done", "preset": "scout"}`) + return ErrorResult( + `Required parameter "task" (string) is missing. ` + + `Example: {"task": "describe what you need done", "preset": "scout"}`, + ) } label, _ := args["label"].(string) diff --git a/pkg/tools/spawn_test.go b/pkg/tools/spawn_test.go index b5652784a..f36542ec1 100644 --- a/pkg/tools/spawn_test.go +++ b/pkg/tools/spawn_test.go @@ -33,8 +33,8 @@ func TestSpawnTool_Execute_EmptyTask(t *testing.T) { if !result.IsError { t.Error("Expected error for invalid task parameter") } - if !strings.Contains(result.ForLLM, "task is required") { - t.Errorf("Error message should mention 'task is required', got: %s", result.ForLLM) + if !strings.Contains(result.ForLLM, `"task"`) { + t.Errorf("Error message should mention '\"task\"', got: %s", result.ForLLM) } }) } @@ -73,7 +73,7 @@ func TestSpawnTool_Execute_NilManager(t *testing.T) { if !result.IsError { t.Error("Expected error for nil manager") } - if !strings.Contains(result.ForLLM, "Subagent manager not configured") { - t.Errorf("Error message should mention manager not configured, got: %s", result.ForLLM) + if !strings.Contains(result.ForLLM, "spawn tool is not available") { + t.Errorf("Error message should mention spawn tool not available, got: %s", result.ForLLM) } } diff --git a/pkg/tools/subagent.go b/pkg/tools/subagent.go index 073b5274a..5dd9853ee 100644 --- a/pkg/tools/subagent.go +++ b/pkg/tools/subagent.go @@ -434,8 +434,10 @@ func (t *SubagentTool) SetContext(channel, chatID string) { func (t *SubagentTool) Execute(ctx context.Context, args map[string]any) *ToolResult { task, ok := args["task"].(string) if !ok { - return ErrorResult(`Required parameter "task" (string) is missing. Example: {"task": "describe what you need done"}`). - WithError(fmt.Errorf("task parameter is required")) + return ErrorResult( + `Required parameter "task" (string) is missing. ` + + `Example: {"task": "describe what you need done"}`, + ).WithError(fmt.Errorf("task parameter is required")) } label, _ := args["label"].(string) diff --git a/pkg/tools/subagent_tool_test.go b/pkg/tools/subagent_tool_test.go index 010bf13da..481ea394e 100644 --- a/pkg/tools/subagent_tool_test.go +++ b/pkg/tools/subagent_tool_test.go @@ -365,7 +365,11 @@ func TestFormatToolStats(t *testing.T) { }{ {"empty", map[string]int{}, ""}, {"single", map[string]int{"exec": 3}, "exec:3"}, - {"multiple sorted", map[string]int{"read_file": 5, "exec": 3, "write_file": 1}, "exec:3,read_file:5,write_file:1"}, + { + "multiple sorted", + map[string]int{"read_file": 5, "exec": 3, "write_file": 1}, + "exec:3,read_file:5,write_file:1", + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/pkg/tools/toolloop_reporter_test.go b/pkg/tools/toolloop_reporter_test.go index e8b3da971..c4a70bccb 100644 --- a/pkg/tools/toolloop_reporter_test.go +++ b/pkg/tools/toolloop_reporter_test.go @@ -21,9 +21,9 @@ type spyCall struct { tool string } -func (r *reporterSpy) ReportSpawn(id, label, task string) {} -func (r *reporterSpy) ReportConversation(from, to, text string) {} -func (r *reporterSpy) ReportGC(id, reason string) {} +func (r *reporterSpy) ReportSpawn(id, label, task string) {} +func (r *reporterSpy) ReportConversation(from, to, text string) {} +func (r *reporterSpy) ReportGC(id, reason string) {} func (r *reporterSpy) ReportStateChange(id string, state orch.AgentState, tool string) { r.mu.Lock() r.calls = append(r.calls, spyCall{state, tool})