Repository navigation
Conversation
Map message conversion failures to the existing RUN_ERROR response while retaining the legacy finish-after-error option. Keep document input unsupported and omit its payload from rejection messages. Refs agentscope-ai#3392
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
Scoped fix for #3392 and the design is right: conversion now happens inside the existing try/catch, so mapErrorCode() gives the caller RUN_STARTED -> RUN_ERROR(INVALID_INPUT_ERROR) instead of a raw error signal, the document rejection is payload-free, and the toString() echo ("Unhandled InputContent type: " + input) is gone. The generic fallback reporting only getClass().getSimpleName() is the correct rule, 13 regression cases across generic / ReActAgent / HarnessAgent with both URL and Base64 sources pin both terminal sequences, and the docs + Javadoc no longer promise a DataBlock mapping that never existed. Deliberately not approving: one payload-reflection path is still open and CI build jobs were still pending at review time.
Findings
- [Warning]
AguiAgentAdapter.java:161— the sanitizedRUN_ERRORis preceded byRUN_STARTED, anderrorEvents()builds it with the caller's originalRunAgentInput(AguiAgentAdapter.java:396), so the document URL / Base64 / metadata is still reflected over the stream and into anything that logs events. Pre-existing shared helper behaviour, not introduced here — but it is the remaining half of the leak this PR is about. - [Info]
AguiMessageConverter.java:343— thenullarm is unreachable (List.copyOfinMessageContent.Blocks, sealedInputContentfully handled); the siblingtoSource()fallback at line 365 still stringifies the Base64valueand deserves the same treatment.
CI / CLA
CLA signed (license/cla=success). validate, Check License, Check Module Sync green; build (ubuntu-latest) and build (windows-latest) were pending on 3b481ef8. Resolving the RUN_STARTED.input point (guard it, or state in docs/v2/*/agui.md that only RUN_ERROR is sanitized) plus a green build is enough for an approval — happy to re-review on the next push.
Automated review by github-manager-bot
| // Convert AG-UI messages and official resume entries to AgentScope | ||
| // messages. | ||
| List<Msg> msgs = | ||
| messageConverter.toMsgList( |
There was a problem hiding this comment.
Routing conversion into errorEvents(threadId, runId, input, error, true) (line 167) does sanitize RUN_ERROR, but it also newly emits a RUN_STARTED built as new AguiEvent.RunStarted(threadId, runId, null, input) (AguiAgentAdapter.java:396), and RunStarted.input is a serialized field — so the rejected DocumentInputContent (URL with query token, Base64 body, metadata) is reflected back to the caller on a path where, before this PR, conversion failures produced no events at all. AguiInputErrorTest asserts only error.message(), so the test suite cannot see the echo. Passing includeRunStarted=true is fine for the protocol sequence; what undercuts the stated goal is the payload riding along in it. Consider new AguiEvent.RunStarted(threadId, runId) on the synchronous-error path (or a copy of input with message content stripped), and extend the assertion to the whole collected event list rather than just events.get(1).
| } | ||
| throw new IllegalStateException( | ||
| "Unhandled InputContent type: " | ||
| + (input == null ? "null" : input.getClass().getSimpleName())); |
There was a problem hiding this comment.
The input == null ? "null" arm is unreachable: the only caller iterates MessageContent.Blocks.parts(), whose compact constructor runs List.copyOf (MessageContent.java:69) and rejects null elements, and InputContent is sealed over exactly the five subtypes handled above (InputContent.java:50-55), so a future subtype is still a non-null instance. The class-name-only rule is the right one, but the sibling fallback at line 365 still breaks it: "Unhandled InputContentSource type: " + inputSource stringifies an InputContentDataSource including its Base64 value. Mirroring line 343 there closes the last payload echo in this file.
|
感谢 review。按建议选择明确文档边界、保留现有事件语义的方案:已在中英文 AG-UI 文档说明,保护仅针对 关于 本地 63 个相关 Java 测试全部通过、无跳过;本次文档的 |
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
Re-review of the two commits pushed since my last pass (6a5627c6, 4b2233cf). Both open findings from the previous round are closed, and the delta itself is sound — a test that pins the new guard and a docs paragraph that states the boundary. Approving; CI detail and one carry-over note below.
On the RUN_STARTED.input reflection (AguiAgentAdapter.java:161) — I accept your reasoning and your resolution. RUN_STARTED carrying input is mandated by the AG-UI state-snapshot semantics, not incidental to this PR, and turning it into a payload-free event would be a protocol-visible change that belongs in its own discussion. Documenting the boundary in both docs/v2/en and docs/v2/zh — stating that only the RUN_ERROR message is sanitized and that consumers who log or forward events must redact — is the right outcome for a scoped fix, and the matching RunStarted(threadId, runId) overload means a future hardening step has a cheap path if the project ever decides to take it. Closed, no action needed.
On the unreachable null arm (AguiMessageConverter.java:343) — keeping it as a defensive guard and proving it with testNullInputContentIsRejectedWithoutDereferencingIt is a better outcome than deleting it. Closed.
Findings
- [Info]
AguiMessageConverter.java:365— carried over, unchanged by these commits: the siblingtoSource()fallback still does"Unhandled InputContentSource type: " + inputSource, which stringifies the whole source, so anInputContentDataSourcewould put its Base64valueinto the exception message that this PR is working to keep clean.InputContentSourceis sealed over exactlyInputContentUrlSource/InputContentDataSourceand both arms are handled, so the fallback is unreachable today — not a blocker, but the next permitted subtype makes it live.inputSource == null ? "null" : inputSource.getClass().getSimpleName()would make the two guards consistent, in either this PR or a follow-up.
CI at review time
validate, Check License, Check Module Sync, build (ubuntu-latest) passed and license/cla is signed on 4b2233cf; build (windows-latest) was still queued when this review was submitted. The added test only relies on getDeclaredMethod + setAccessible on a classpath type, so it is platform-independent and I do not expect the Windows job to diverge — flagging it so the approval is read as "code approved, one build job still running" rather than "all green".
Thanks for the fast turnaround and for keeping the doc wording precise in both languages.
Automated review by github-manager-bot
| } | ||
| throw new IllegalStateException( | ||
| "Unhandled InputContent type: " | ||
| + (input == null ? "null" : input.getClass().getSimpleName())); |
There was a problem hiding this comment.
[Info] Closing the loop on the previous round: keeping the null arm as a defensive guard and pinning it with testNullInputContentIsRejectedWithoutDereferencingIt is a better outcome than deleting it, and the test's own comment ("Blocks rejects null elements, so exercise this defensive guard directly") already explains why it reaches in by reflection. No action here.
The one item still open is the sibling fallback at line 365: "Unhandled InputContentSource type: " + inputSource stringifies the whole source, so an InputContentDataSource would land its Base64 value in the message — the same shape this PR removes above. InputContentSource is sealed over exactly InputContentUrlSource / InputContentDataSource, both handled, so it is unreachable today and not a blocker; the next permitted subtype would make it live. inputSource == null ? "null" : inputSource.getClass().getSimpleName() would make the two guards consistent, here or in a follow-up.
Backport the verified fix to the 2.0.x implementation and retain its existing public contracts where the upstream kernel differs. (cherry picked from commit a732b63) Backport-review-patch: 857d588e0299555e25ba165918367560f54ea3b6 Constraint: No AgentScope Service or SDK migration Confidence: high Not-tested: Whole-repository verification pending after lane integration
AgentScope-Java Version
2.0.4-SNAPSHOT,修复基线为官方 main915507134。Description
Refs #3392
本 PR 不增加 document 支持,仅修复现有拒绝路径中的内容回显和错误事件映射问题,提供一个限定范围的方案供维护者 review。
问题与修复
document输入可以反序列化,但转换时的异常会拼接整个输入对象,包含 URL / Base64 和 metadata。改为明确、无 payload 的拒绝信息,保留现有IllegalStateException类型;InputContent 兜底异常仅报告类型名。try/catch,复用errorEvents()/mapErrorCode(),不新建错误处理机制。RUN_STARTED → RUN_ERROR,document 拒绝的错误码为INVALID_INPUT_ERROR;emitRunFinishedAfterError=true继续保留错误后追加RUN_FINISHED的兼容行为。DocumentInputContent的误导性 Javadoc,并同步 EN/ZH AG-UI 说明。范围与兼容性
仅涉及 AG-UI converter、adapter、相关测试及文档,共 7 个文件。不扩展 DataBlock、模型 provider、文档解析或沙箱上传;不修改 HTTP controller、异步流、取消与清理逻辑。
转换失败从原来的 raw error signal 改为协议错误事件,是本次有意的行为变化,也适用于同一转换入口的其他校验异常。运行上下文构建与 HTTP JSON 解析错误不在本次统一处理范围内。现有
RUN_STARTED.input行为保持不变;本次保证的是拒绝错误信息不包含文档内容,并非对所有协议字段做脱敏。因为本次只处理 Issue 中的干净拒绝路径,不自动关闭 #3392;真正的 document 功能支持可另行讨论。
验证
运行环境:OpenJDK 21.0.7(编译目标 Java 17),Node 22.22.2。
mvn -B -T1 -pl agentscope-extensions/agentscope-extensions-protocol/agentscope-extensions-agui -am verify:成功。Core 2518 个测试(跳过 9),AG-UI 520 个测试(无跳过),无失败或错误。mvn -B -T1 clean verify:96 个模块构建成功;Surefire 报告汇总 9836 个测试,无失败或错误,跳过 212 个。跳过项主要涉及外部 E2E、Docker、provider 凭据和既有禁用测试,本次没有禁用或弱化任何测试。npm test(12 个测试通过)、npm run validate、npm run broken-links均通过;git diff --check通过。未新增真实 HTTP document 上传集成测试或外部模型调用;未在 JDK 17 runtime 和 Windows 上本地验证。
Checklist
mvn spotless:apply