fix(multiagent): repair StreamingMeta index collisions on agentic streams - #286
Open
oierxjn wants to merge 1 commit into
Open
fix(multiagent): repair StreamingMeta index collisions on agentic streams#286oierxjn wants to merge 1 commit into
oierxjn wants to merge 1 commit into
Conversation
…eams Some providers (e.g. Cloudflare Workers AI gateways) interleave text chunks between parallel tool-call chunks in one SSE stream. The chunk converter in eino-ext acl/openai assigns such a text block the same StreamingMeta.Index as the preceding tool-call block, so schema.ConcatAgenticMessages fails with a block type mismatch. The ADK retry checker swallows that error and sees a nil message, surfacing as a misleading empty-model-output rejection and a deterministic retry-exhausted failure on the first parallel tool call round. Wrap agentic chat models (OpenAI-compatible and Claude paths) with a stream repair layer that reassigns colliding blocks to fresh negative indices, keeping every concat group single-typed while preserving all block content. Valid streams pass through untouched. Root cause reported upstream: cloudwego/eino-ext#975 (fix PR: cloudwego/eino-ext#976). This wrapper is a defensive boundary fix and can be removed after the eino-ext fix lands in a released dependency. Fixes Ed1s0nZ#285
oierxjn
marked this pull request as ready for review
August 28, 2026 09:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #285
问题
部分模型网关(实测 Cloudflare Workers AI 经 new-api 中转)在并行 tool_calls 的流式响应中,会在两个工具调用之间插入空白文本帧。eino-ext
acl/openai的chunkConverter会给该文本块分配与工具调用块相同的StreamingMeta.Index(上游 bug,已报 cloudwego/eino-ext#975,修复 PR cloudwego/eino-ext#976),导致:schema.ConcatAgenticMessages分组类型冲突报错(content block type mismatch)typedConsumeStream吞掉该错误返回 nil 消息ShouldRetry误判为empty_model_output,确定性重试耗尽,整轮失败单工具调用正常;并行调用(如 Agent 首轮常见的 skill + exec)在该类网关下必现。
修复
新增
agenticStreamBlockIndexRepairModel包装器(与既有streamToolCallIndexRepairModel同一防御思路),挂在newEinoAgenticChatModelFactory的 OpenAI 兼容与 Claude 两条路径:StreamingMeta.Index冲突覆盖 eino 单代理 / Deep / Supervisor / Plan-Execute 主代理与子代理、failover 备用通道。
测试
"\n"→ 工具调用2)验证修复前 concat 报类型冲突、修复后 2 个工具调用与文本完整聚合;另有"正常流不被改动"用例go test ./internal/multiagent/全部通过备注
本补丁为框架边界防御。待 eino-ext 上游修复发版、本项目升级依赖后,该包装器可移除(保留亦无副作用)。