agentscope-ai / agentscope-ai/agentscope-java

[Bug]: Gemini formatter splits parallel function responses into multiple user contents

未關閉
#2,351 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
area/core/model area/core/tool bug
主要語言
Java
星號
5.6k
分支
1.3k
平均合併
4 天 12 小時
30 天內合併 PR
77

描述

## Describe the bug

Gemini function calling requires responses to parallel function calls to be returned together in one `Content` with `role: "user"`. `GeminiMessageConverter#convertMessages` currently appends an independent user content block for every `ToolResultBlock`.

## To Reproduce

1. Construct one `Msg` with `MsgRole.TOOL` and two `ToolResultBlock` instances.
2. Convert it with `GeminiMessageConverter#convertMessages`.
3. Observe two user contents, each containing one `FunctionResponse` part.

## Expected behavior

The converter should emit one `Content(role=user)` containing both `FunctionResponse` parts in their original order.

## Actual behavior

The converter emits one user content per tool result. This violates Gemini's parallel function-calling response grouping contract and can cause a replayed tool turn to be rejected or interpreted incorrectly.

## Scope

This is intentionally separate from #2335, which addresses Gemini thinking and thought-signature persistence. The issue concerns grouping of parallel tool results only.

## Proposed fix

Buffer function-response parts while converting one source `Msg`, then emit a single user content block before regular message parts. A regression test covers two tool results in one message.

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。