Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[dotnet-port] Port AGUI parallel tool call rendering fixes#217

Merged
gdams merged 1 commit into
mainfrom
dotnet-port-agui-parallel-tool-calls-6b801f88e2f9a670
May 26, 2026
Merged

[dotnet-port] Port AGUI parallel tool call rendering fixes#217
gdams merged 1 commit into
mainfrom
dotnet-port-agui-parallel-tool-calls-6b801f88e2f9a670

Conversation

@qmuntal

@qmuntal qmuntal commented May 25, 2026

Copy link
Copy Markdown
Member

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.

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]>
Copilot AI review requested due to automatic review settings May 25, 2026 10:37
@qmuntal qmuntal requested a review from a team as a code owner May 25, 2026 10:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_RESULT events use deterministic, per-call unique message IDs in result-{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

@github-actions

Copy link
Copy Markdown
Contributor

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:

Bug Go change .NET equivalent
#2 — deterministic ToolCallResultEvent.MessageId contentToEvents now uses "result-"+callID ChatResponseUpdateAGUIExtensions.cs uses result-{CallId}
#3 — coalesce consecutive assistant-tool-call messages toAgentMessages buffers and flushes consecutive assistant messages with tool calls AGUIChatMessageExtensions.cs buffers consecutive AGUIAssistantMessages with ToolCalls

Both fixes are internal to the aguihosting package. No exported Go APIs are added or changed, so there are no user-visible contract differences. The removal of hasFunctionResultContent is also mirrored upstream (dead code after fix #2).

Note: Bug #1 from #6009 (streaming ParentMessageId leakage) is intentionally not included here — no cross-repo alignment concern.

Generated by Go API Consistency Review Agent for issue #217 · ● 3.2M ·

@gdams gdams linked an issue May 26, 2026 that may be closed by this pull request
@gdams gdams merged commit d3eb51c into main May 26, 2026
17 checks passed
@gdams gdams deleted the dotnet-port-agui-parallel-tool-calls-6b801f88e2f9a670 branch May 26, 2026 07:21
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.

[dotnet-port] Port AGUI parallel tool call rendering fixes

3 participants