Skip to content

fix(adk): encode automatic transfer arguments as JSON - #1271

Open
ruirui6946 wants to merge 1 commit into
cloudwego:mainfrom
ruirui6946:fix/786-transfer-tool-json
Open

fix(adk): encode automatic transfer arguments as JSON#1271
ruirui6946 wants to merge 1 commit into
cloudwego:mainfrom
ruirui6946:fix/786-transfer-tool-json

Conversation

@ruirui6946

Copy link
Copy Markdown

What type of PR is this?

fix

Check the PR title.

  • This PR title matches the format: (optional scope):
  • The title describes the user-visible fix.

Description

When an application collects supervisor runner events and sends those messages back in the next turn, the automatic transfer-back tool call contains a bare agent name (MainAgent) in Function.Arguments. Model adapters that decode arguments as a JSON object reject that history with invalid character 'M' looking for beginning of value, as reported in #786.

Encode generated transfer arguments as {"agent_name":"MainAgent"}, matching the existing transfer tool schema. JSON marshaling also handles quotes, backslashes, control characters, and Unicode names. Update the existing history assertions to reflect the encoded arguments.

The supervisor regression test collects the actual first-turn events, replays them in a second runner invocation, and uses a mock model that parses all historical tool arguments as JSON objects. Both this integration test and the new argument round-trip test fail before the fix and pass afterward; no external model credentials are required.

Related prior work: #741 proposed the same argument-format correction and was closed without merging. This PR ties the correction to the concrete two-turn failure in #786 and includes a regression for that path.

Validation

  • Linux amd64, Go 1.25.9: go test -race ./adk/... — all 16 packages passed.
  • Windows amd64, Go 1.24.1: go test -race ./adk ./adk/prebuilt/... — passed.
  • golangci-lint v2.8.0, checked against the base revision for this change: 0 new issues.
  • Full golangci-lint run --timeout 5m ./adk/... reports three gci formatting findings in unchanged files: adk/agent_tool.go, adk/call_option.go, and adk/callback.go.
  • git diff --check — passed.

Which issue(s) this PR fixes

Fixes #786

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

使用supervisor Agent创建的adk.Runner,内部通过tool调用sub agent后ToolCall.Function.Arguments格式错误

1 participant