Repository navigation
Conversation
结构化输出清理仅移除内部输出工具内容,保留业务调用及其配对结果。沿用最终结果的 usage 归属,避免保留副本重复计数。 补充混合顺序、分轮、纯输出、状态存储与重建 Agent 的回归测试,并同步中英文说明。 Refs agentscope-ai#4073
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
5 tasks done
juruoO-o
approved these changes
Nov 11, 2026
juruoO-o
left a comment
Collaborator
There was a problem hiding this comment.
修复必要,范围限定在结构化输出清理:保留混合消息中的业务工具配对,去除已归集的 usage,未改变公共 API 或工具调度。针对当前 head 与 main 的合并结果,先前本地验证的 ReActAgentStructuredOutputCleanupTest 8 项全部通过。本轮复核 head 未变;未发现阻塞问题。
chickenlj
added a commit
that referenced
this pull request
Nov 13, 2026
RiemannChow
added a commit
to RiemannChow/agentscope-java
that referenced
this pull request
Nov 15, 2026
Upstream PR agentscope-ai#4086 already fixed agentscope-ai#4073 in ReActAgent#compressStructuredOutputContext: mixed messages are rebuilt with the synthetic generate_response blocks removed and CHAT_USAGE is dropped from the retained copy. Keep that implementation and remove the now-unused stripStructuredOutputBlocks / isStructuredOutputBlock helpers from this branch, so the two fixes do not coexist in the same method. This branch keeps its javadoc clarification on the cleanup method and the StructuredMixedBatchAuditTest regression suite, which still passes against the upstream implementation.
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.
AgentScope-Java Version
2.1.0-SNAPSHOT,验证基线为
main的5baff2613401bf87b3a967b185f2f14945ec594e。Description
Fixes #4073.
问题与修复
降级结构化输出路径允许模型在同一响应中返回业务工具调用与内部
generate_response调用。原来的compressStructuredOutputContext会删除整个混合消息,业务工具结果却仍保留,导致持久化历史以及下一轮请求出现没有对应tool_use的tool_result。本 PR 仅调整该清理方法:
不修改共用分类函数、usage/thinking 收集器、工具调度、权限、重试、native structured-output 路径或公共 API;不迁移此前已损坏的历史。
回归测试
新增
ReActAgentStructuredOutputCleanupTest,使用假模型和真实本地 Java 工具,不需要网络或模型凭证:InMemoryAgentStateStore,共 8 个参数化场景。同步补充中英文 Agent 文档中的历史清理行为说明。
验证结果与边界
以下 Maven 检查在上述基线加本提交上完成,本地使用离线缓存和 central-only settings:
mvn -B -T1C -pl agentscope-core -am test mvn -B -T1C -pl agentscope-core -am spotless:checkgit diff --check通过。npm test13 项通过,npm run validate通过,npm run broken-links未发现坏链接。尚未执行全仓库
clean verify、Windows 或真实模型厂商集成测试;不将这些列为已验证。与相关 PR 的协调
提交前注意到 #4078 也针对 #4073 提供了实现,两个 PR 存在重叠。本实现同时包含非零 usage 的历史总量断言、原消息不变性和持久化后重建 Agent 的回归检查,保留混合消息时不再重复携带已归集到最终结果的 usage。这里说明本实现的设计与验证范围,并非对 #4078 未验证行为的缺陷判断。
欢迎维护者比较、选择或整合合适的实现与测试;不需要合并两个重复修复。
Checklist
mvn test) — 已验证上述 core 范围,未执行全仓库测试。