Skip to content

fix(spawn): clear ForUser in sub-turn ToolResult to prevent duplicate messages#3142

Open
jincheng-xydt wants to merge 1 commit into
sipeed:mainfrom
jincheng-xydt:fix/3094-spawn-duplicate-message
Open

fix(spawn): clear ForUser in sub-turn ToolResult to prevent duplicate messages#3142
jincheng-xydt wants to merge 1 commit into
sipeed:mainfrom
jincheng-xydt:fix/3094-spawn-duplicate-message

Conversation

@jincheng-xydt

Copy link
Copy Markdown
Contributor

📝 Description

Clear the ForUser field in the spawn sub-turn ToolResult to prevent duplicate message delivery on async sub-agent completion.

Root cause: When a spawn sub-agent finishes, subturn.go set both ForLLM and ForUser to the same content. This triggered two independent push paths:

  1. The async callback in pipeline_execute.go directly pushed to the outbound bus when ForUser was non-empty
  2. The main agent's orchestration path also delivered the result via pendingResults

Fix: Clear ForUser (set to "") so the main agent exclusively controls message delivery, eliminating the duplicate.

🗣️ Type of Change

  • 🐞 Bug fix (non-breaking change which fixes an issue)

🤖 AI Code Generation

  • 🛠️ Mostly AI-generated (AI draft, Human verified/modified)

🔗 Related Issue

Closes #3094

📚 Technical Context (Skip for Docs)

🧪 Test Environment

  • Hardware: PC (x86_64)
  • OS: Linux
  • Model/Provider: N/A (code logic change)
  • Channels: All channels (bug affects all async spawn delivery paths)

☑️ Checklist

  • My code/docs follow the style of this project.
  • I have performed a self-review of my own changes.
  • I have updated the documentation accordingly.

… messages

When a spawn sub-agent completes, the ToolResult's ForUser field was set
to the same content as ForLLM, triggering two independent push paths:
1) The async callback directly pushed to the outbound bus
2) The main agent's orchestration path also delivered the result

Clear ForUser so the main agent exclusively controls message delivery,
eliminating duplicate messages on async sub-agent completion.

Closes sipeed#3094
@CLAassistant

CLAassistant commented Jun 17, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@jincheng-xydt

Copy link
Copy Markdown
Contributor Author

CLA has been signed. Please verify.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 异步子代理(spawn)任务完成时,ForUser字段被同时用于直接推送和主代理汇总,导致重复消息

2 participants