Skip to content

fix(agui): preserve document tool error round trips - #4036

Merged
jujn merged 3 commits into
agentscope-ai:mainfrom
pengmoubuaixuexi:fix/agui-document-tool-errors
Nov 24, 2026
Merged

jujn merged 3 commits into
agentscope-ai:mainfrom
pengmoubuaixuexi:fix/agui-document-tool-errors

Conversation

@pengmoubuaixuexi

@pengmoubuaixuexi pengmoubuaixuexi commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.1.0-SNAPSHOT, based on main 85fa9a60257ceb1570e6a195d0588ceba1e8a8c2.

Description

Fixes #4035.

An ERROR tool result containing only a document currently serializes to structured AG-UI content with an empty error. After JSON deserialization, toMsg restores it as SUCCESS. Results containing both a document and a textual error have a related problem: the structured-input branch prepends the diagnostic again, duplicating it during repeated history conversion.

When failed tool output has blank text, render a document reference before assembling the content; if neither text nor a document reference can be rendered, use Tool execution failed. The fallback is included in both content and error, so a document-only failure keeps a stable block order from its first JSON round trip. On structured input, prepend a distinct error only when no text block already contains it. Document sources, IDs and successful output (including whitespace) retain their behavior; manually built empty/blank failures now retain ERROR too. This follows the structured-document support in #3979 and applies the existing plain-text non-duplication intent from #3932 to this new path.

Sixteen regression cases exercise the public converter and actual JSON round trips: URL/Base64/provider-file document failures and success controls with three-trip output-shape comparisons; empty output, empty text and whitespace-only results with ERROR/SUCCESS controls; a whitespace-only document diagnostic; multiple results with different states; repeated round trips with one diagnostic; and a distinct frontend error. The Base64 case explicitly asserts inline base64 is present in the error and the payload is absent. EN/ZH notes describe the final fallback and stable-shape semantics.

Validation

Windows, Temurin Java 17.0.15, Maven 3.9.12; JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8. Commands ran from the repository root with -B -T1C.

  • Initial ten-case regression on unchanged upstream production: 10 tests, 6 failures, 0 errors/skips. The three successful-document controls and distinct frontend-error control pass.
  • mvn -B -T1C -pl :agentscope-extensions-agui -am -Dtest=AguiToolDocumentErrorTest,AguiMessageConverterTest,AguiReasoningMediaTest -Dsurefire.failIfNoSpecifiedTests=false test (initial implementation): 106 passed, zero failures/errors/skips.
  • mvn -B -T1C -pl :agentscope-extensions-agui -am -DskipTests clean install: passed; this dependency build skips tests.
  • mvn -B -T1C -pl :agentscope-extensions-agui clean verify: 593 passed, zero failures/errors/skips; Spotless, Javadoc and packaging passed.
  • From docs/: npm ci --ignore-scripts, npm test (13 passed), npm run validate: passed.
  • npm run broken-links: 2,224 links in 328 files on both this change and pristine main; all 2,552 ordered file/target rows are identical (existing site issues, no newly introduced targets).
  • git diff --check: passed; complete staged diff inspected. Main was fetched again before initial submission and remained at the stated base.
  • Review follow-up a02699c5: the expanded 16-case regression on prior PR production d2a84a82 has 6 failures, 0 errors/skips (three empty/blank ERROR cases and three document-order comparisons); the final implementation passes 16/16, included in the 593-test module check. Both platform checks passed on d2a84a82; the new commit must complete CI again.

This is an offline converter/serialization regression. It does not download documents, call a model, test a frontend or claim stable-release coverage. Full-repository tests were not run and no coverage percentage is claimed.

After #4297 added outbound media sources, I checked the same failure mode with an image-only tool result on 2fb5400e. The probe calls toAguiMessages, serializes and parses the resulting AguiMessage with the JSON codec, then calls toMsg. On main, both inline Base64 and provider file-ID images retained their source and tool-call ID, but an ERROR result came back as SUCCESS. Both success controls passed. With this PR's existing patch (a02699c5) applied to that main revision, all four cases passed. The three related converter suites also passed (118 cases). The four additional cases were a local compatibility check on Windows with Java 17.

AI assistance was used for investigation, implementation, tests and diff review. The stated checks were executed locally.

Checklist

  • Changed Java code formatted with Spotless.
  • Relevant regressions and complete AG-UI module clean verify pass; full-repository tests not run.
  • Existing converter API and documented tool-error contract retained; Javadoc generation passes.
  • Related EN/ZH documentation updated and validated.
  • Complete diff inspected and ready for maintainer review.

Copilot AI balanced review requested due to automatic review settings November 7, 2026 00:14
@mintlify

mintlify Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit a14e7ae.

Approve preview

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@ningmao-hlyz ningmao-hlyz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is correct and the tests are effective: AguiToolDocumentErrorTest fails 6 of 10 cases on 85fa9a60 and passes 10/10 on d2a84a82. CI is green on both runners and the EN/ZH notes match the implementation.

No blocking concerns. Four small points below.

@jujn jujn added the P1 紧急不重要 label Nov 7, 2026
@ningmao-hlyz

Copy link
Copy Markdown
Contributor

LGTM

@ningmao-hlyz

Copy link
Copy Markdown
Contributor

The fix is correct and the tests are effective: AguiToolDocumentErrorTest fails 6 of 10 cases on 85fa9a60 and passes 10/10 on d2a84a82. CI is green on both runners and the EN/ZH notes match the implementation.

No blocking concerns. Four small points below.

@pengmoubuaixuexi The four threads can be resolved now

@pengmoubuaixuexi

Copy link
Copy Markdown
Contributor Author

Updated this branch to main at decbe55. The resolution keeps the tool sender name that main now emits, along with this PR's handling of failed tool results. The six document cases now check the name alongside the restored success/error state for URL, inline Base64 and file-ID sources. All six failed with a missing name when I tested a resolution that kept the old constructor.

At a14e7ae, all 512 AG-UI module tests passed with no skips (mvn -pl :agentscope-extensions-agui clean verify). The English and Chinese notes now live in the development guides. All 20 documentation tests and site validation passed. The broken-link checker reported the same 2,750 links in the same 483 files on the branch and on clean main at decbe55.

@jujn
jujn merged commit ab38ab5 into agentscope-ai:main Nov 24, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 紧急不重要

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: AG-UI document tool results lose failure state and duplicate error diagnostics

4 participants