Skip to content

fix(core): repair null streaming tool args from complete raw JSON - #2451

Open
Blue-Berrys wants to merge 1 commit into
agentscope-ai:mainfrom
Blue-Berrys:fix/768-toolcall-accumulator-null-args
Open

fix(core): repair null streaming tool args from complete raw JSON#2451
Blue-Berrys wants to merge 1 commit into
agentscope-ai:mainfrom
Blue-Berrys:fix/768-toolcall-accumulator-null-args

Conversation

@Blue-Berrys

@Blue-Berrys Blue-Berrys commented Jul 28, 2026

Copy link
Copy Markdown

Summary

  • Repair ToolCallsAccumulator so complete raw tool-call JSON fills missing/null input values after streaming.
  • Prevent later null input maps from overwriting previously accumulated non-null arguments.
  • Add regression tests for HTML-like multi-line content and null-overwrite protection.

Closes #768

Description

When streaming tool-call arguments for complex multi-line content (e.g. HTML), early chunks can leave ToolUseBlock.input with keys present but null values. Because build() previously only parsed raw content when finalArgs was empty, those nulls were never repaired even though content held valid complete JSON.

Checklist

  • Code has been formatted with mvn spotless:apply
  • Targeted tests pass (ToolCallsAccumulatorTest, 15 tests)
  • Related documentation has been updated (N/A)
  • Code is ready for review

Testing

JAVA_HOME=/path/to/jdk21 mvn -pl agentscope-core -am \
  -Dspotless.check.skip=true \
  -Dtest=ToolCallsAccumulatorTest \
  -Dsurefire.failIfNoSpecifiedTests=false \
  test

Early stream chunks may leave ToolUseBlock.input with keys but null values
for complex multi-line content. Always re-parse accumulated raw arguments
and fill missing/null keys without overwriting non-null values.
Closes agentscope-ai#768.
@CLAassistant

CLAassistant commented Jul 28, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@oss-maintainer oss-maintainer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review — Approved ✅

Good fix for the null-value streaming tool-call accumulation issue (#768).

Code analysis:

  • merge() now correctly skips null values from partial input maps, preventing early stream chunks from wiping previously accumulated non-null arguments.
  • build() is updated to always attempt raw JSON parsing (not just when finalArgs is empty), which is the right call — the final accumulated raw content is indeed the source of truth.
  • The merge logic in build() correctly preserves existing non-null values while filling in missing/null keys from parsed JSON.

Tests:

  • testRepairNullInputValuesFromCompleteRawContent — directly reproduces the HTML streaming scenario from #768.
  • testNullInputDoesNotOverwriteNonNullArgs — validates the ordering invariant.

Both tests are well-structured and target the exact failure modes.

LGTM. Please sign the CLA.

@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.57143% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...e/core/agent/accumulator/ToolCallsAccumulator.java 78.57% 1 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@Blue-Berrys
Blue-Berrys force-pushed the fix/768-toolcall-accumulator-null-args branch from 997a17a to db566d0 Compare July 28, 2026 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]:很奇怪的一个bug,我让agent写入一个带有格式的html文件,整个参数都是空

3 participants