Skip to content

Commit 3291c46

Browse files
intel352claude
andcommitted
fix: send_message tool name collision, thinking leak, team error reporting
1. send_message tool: renamed 'type' param to 'message_type' to avoid JSON Schema keyword collision that caused LLMs to silently drop it. Made message_type optional with default 'task'. Only 'to' and 'content' are now required. 2. Thinking events: mesh forwarder now maps executor.EventThinking to "thinking" type. Team event converter suppresses thinking events from team output (model reasoning is noise in team context). 3. Team error reporting: completion now emits error events for each agent failure before the completion event, so users see what went wrong instead of just "completed". Note: Qwen3 thinking content still leaks as regular text when Ollama's think mode is not explicitly enabled. This is an Ollama/model behavior issue — without think:true in config, reasoning is mixed into the content stream with no way to separate it at the Genkit level. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 48e1ab6 commit 3291c46

3 files changed

Lines changed: 35 additions & 8 deletions

File tree

internal/daemon/teams.go

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,11 @@ func (tm *TeamManager) StartMeshTeam(
635635
},
636636
},
637637
}
638+
case "thinking":
639+
// Suppress thinking events from team output — they contain
640+
// the model's internal reasoning which is noise in team context.
641+
// If we want to expose this later, TeamEvent needs a Thinking variant.
642+
continue
638643
case "error":
639644
pbEv = &pb.TeamEvent{
640645
Event: &pb.TeamEvent_Error{
@@ -668,10 +673,26 @@ func (tm *TeamManager) StartMeshTeam(
668673
// doneCh, so Result() is safe to call without waiting again).
669674
result := handle.Result()
670675

671-
summary := fmt.Sprintf("Team completed task: %s (status: %s)", task, result.Status)
676+
// Emit error events for any agent failures before the completion event.
672677
if len(result.Errors) > 0 {
673-
summary += fmt.Sprintf(" [%d errors]", len(result.Errors))
678+
for _, err := range result.Errors {
679+
select {
680+
case eventCh <- &pb.TeamEvent{
681+
Event: &pb.TeamEvent_Error{
682+
Error: &pb.ErrorEvent{Message: err.Error()},
683+
},
684+
}:
685+
case <-ctx.Done():
686+
return
687+
}
688+
}
689+
}
690+
691+
status := result.Status
692+
if status == "" {
693+
status = "completed"
674694
}
695+
summary := fmt.Sprintf("Team %s task: %s", status, task)
675696

676697
select {
677698
case eventCh <- &pb.TeamEvent{
@@ -684,7 +705,7 @@ func (tm *TeamManager) StartMeshTeam(
684705
case <-ctx.Done():
685706
}
686707

687-
tm.markDone(ti, result.Status)
708+
tm.markDone(ti, status)
688709
}()
689710

690711
return teamID, eventCh

internal/mesh/mesh.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,8 @@ func makeEventForwarder(ch chan<- Event, agentID string) func(executor.Event) {
364364
evType = "tool_call"
365365
case executor.EventText:
366366
evType = "text"
367+
case executor.EventThinking:
368+
evType = "thinking"
367369
case executor.EventCompleted:
368370
evType = "complete"
369371
case executor.EventFailed:

internal/mesh/tools.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,27 +190,31 @@ func (t *SendMessageTool) Definition() provider.ToolDef {
190190
"type": "string",
191191
"description": "Target agent name (e.g., 'coder'), node ID, or '*' for broadcast",
192192
},
193-
"type": map[string]any{
193+
"message_type": map[string]any{
194194
"type": "string",
195195
"description": "Message type: task, result, feedback, or request",
196+
"default": "task",
196197
},
197198
"content": map[string]any{
198199
"type": "string",
199200
"description": "Message body",
200201
},
201202
},
202-
"required": []string{"to", "type", "content"},
203+
"required": []string{"to", "content"},
203204
},
204205
}
205206
}
206207

207208
func (t *SendMessageTool) Execute(_ context.Context, args map[string]any) (any, error) {
208209
to, _ := args["to"].(string)
209-
msgType, _ := args["type"].(string)
210+
msgType, _ := args["message_type"].(string)
210211
content, _ := args["content"].(string)
211212

212-
if to == "" || msgType == "" {
213-
return nil, fmt.Errorf("to and type are required")
213+
if to == "" {
214+
return nil, fmt.Errorf("'to' is required")
215+
}
216+
if msgType == "" {
217+
msgType = "task" // default when omitted
214218
}
215219

216220
msg := Message{

0 commit comments

Comments
 (0)