[dotnet-port] Port AGUI parallel tool call rendering fixes#217
Conversation
Fix two bugs that prevent parallel tool calls from rendering correctly in AG-UI protocol clients: Bug #2: Make ToolCallResultEvent.MessageId deterministically unique using result-{callId} format. Multiple tool results in the same update batch previously shared a single generated message ID, collapsing them in FE reconciliation. Bug #3: Coalesce consecutive assistant-with-tool-calls messages in toAgentMessages. The AG-UI client creates one assistant message per tool call when parentMessageId is absent. Sending them as separate messages to the LLM triggers HTTP 400 because OpenAI requires tool results to immediately follow every tool_call_id in an assistant message. Also removes the now-dead hasFunctionResultContent helper. Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR ports AG-UI parallel tool call rendering fixes from the .NET implementation to the Go hosting layer, addressing front-end reconciliation collisions for tool results and preventing invalid message ordering that can trigger OpenAI API 400 errors.
Changes:
- Make
TOOL_CALL_RESULTevents use deterministic, per-call unique message IDs inresult-{callId}format. - Coalesce consecutive assistant messages containing tool calls into a single assistant message before forwarding to the agent/LLM.
- Add/adjust tests to validate deterministic tool-result IDs and the coalescing behavior; remove the now-unused helper for detecting function results.
Show a summary per file
| File | Description |
|---|---|
agent/hosting/aguihosting/events.go |
Emits deterministic result-{callId} message IDs for tool results and removes obsolete ID-splitting logic. |
agent/hosting/aguihosting/convert.go |
Coalesces consecutive assistant tool-call messages to satisfy OpenAI tool-call/result ordering requirements. |
agent/hosting/aguihosting/agui_test.go |
Updates existing assertions and adds coverage for parallel tool result ID uniqueness and assistant-message coalescing. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 0
Cross-repo parity review ✅This PR ports Bugs #2 and #3 from the upstream .NET fix microsoft/agent-framework#6009. The Go changes are semantically identical to their .NET counterparts:
Both fixes are internal to the Note: Bug #1 from #6009 (streaming
|
Fix two bugs that prevent parallel tool calls from rendering correctly in AG-UI protocol clients:
Bug #2: Make ToolCallResultEvent.MessageId deterministically unique using result-{callId} format. Multiple tool results in the same update batch previously shared a single generated message ID, collapsing them in FE reconciliation.
Bug #3: Coalesce consecutive assistant-with-tool-calls messages in toAgentMessages. The AG-UI client creates one assistant message per tool call when parentMessageId is absent. Sending them as separate messages to the LLM triggers HTTP 400 because OpenAI requires tool results to immediately follow every tool_call_id in an assistant message.
Also removes the now-dead hasFunctionResultContent helper.