agentscope-ai / agentscope-ai/agentscope-java

A2A streaming BufferingTube overflow with parallel tool calls

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

描述

## Bug Description

When using A2A streaming with parallel tool calls (e.g., multiple MCP tools executing concurrently), the A2A SSE response throws `IllegalStateException: overflow buffer is full`
from mutiny-zero's `BufferingTube`. The client loses the stream termination signal.

## Root Cause

`a2a-java-sdk-server-common` defines `AsyncUtils.DEFAULT_TUBE_BUFFER_SIZE = 256` (measured in event count, not bytes). When an agent executes multiple tools in parallel, the
produced streaming events can exceed 256 items before the downstream SSE consumer drains them, causing the `BufferingTube` to overflow.

The `A2aJsonRpcController` in `agentscope-a2a-spring-boot-starter` does not apply any `onBackpressureBuffer()` to the Flux chain, so it relies entirely on the a2a-java-sdk
default capacity of 256.

## Stack Trace

java.lang.IllegalStateException: The following item cannot be propagated because there is no demand and the overflow buffer is full:
io.a2a.spec.SendStreamingMessageResponse@6c031fb4
at mutiny.zero.internal.BufferingTube.handleItem(BufferingTube.java:27)
at io.a2a.transport.jsonrpc.handler.JSONRPCHandler$1.onNext(JSONRPCHandler.java:264)
at io.a2a.server.requesthandlers.DefaultRequestHandler$1.onNext(DefaultRequestHandler.java:445)
...

## Steps to Reproduce

1. Register multiple MCP tools that can be invoked by the agent
2. Send an A2A streaming request that triggers the agent to call multiple tools in parallel
3. When total streaming events exceed 256, the `BufferingTube` overflows and the stream terminates abnormally
4. The A2A client never receives the completion event

## Proposed Fix

Add a configurable `stream-buffer-size` property to `A2aCommonProperties` (default: 1024) and apply `onBackpressureBuffer()` in `A2aJsonRpcController`.

## Environment

- AgentScope Java: 2.0.0-RC3
- a2a-java-sdk: 0.3.3.Final

---

I will submit a PR to fix this.

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

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

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