Skip to content

fix(a2a): render pi-go tool calls as kagent tool cards - #473

Merged
dimetron merged 1 commit into
mainfrom
fix/a2a-kagent-tool-parts
Nov 14, 2026
Merged

dimetron merged 1 commit into
mainfrom
fix/a2a-kagent-tool-parts

Conversation

@dimetron

Copy link
Copy Markdown
Owner

Problem

In KAgent Substrate, pi-go's tool calls and results rendered as unrecognized data rather than as tool cards, unlike the Claude and Codex harnesses.

The kagent UI classifies a data part only by the kagent.dev/a2a/part-type metadata key (ui/src/api/chat/a2aGrpcChatClient.ts, dataKindOf). pi-go wrote only the legacy adk_type key.

Fix

Emit the same parts kagent's own harness emits (go/harness/runtime/a2a/executor.go, go/api/a2a/tool_activity.go):

  • Part type: tool parts carry kagent.dev/a2a/part-type; thinking carries kagent.dev/a2a/thought. The adk_* keys are kept for ADK clients.
  • Tool name: cards are named by the registered tool name (bash) with args in the body, as Claude/Codex do, instead of by the display title. The ACP adapter passes the name in _meta["pi.dev/tool-name"] (ACP clients ignore unknown _meta). The title remains the fallback.
  • Result shape: {id, name, response: {result, isError}}. A failed call is now visibly failed.
  • Subagent bug: a running subagent's card is re-sent per nested call as a non-terminal update. Each was treated as a result: a stray nameless result card per nested call, and the real result lost its name. Only completed/failed updates now emit a result.
  • Reload order: every artifact carries kagent.dev/a2a/timeline-position. It is repeated on the closing text replacement (a replacement overwrites artifact metadata). It uses a fixed-width nanosecond format, because the UI sorts positions as strings and RFC3339Nano trims trailing zeros (.33171Z < .331709Z).
  • Tool inputs/outputs are converted to plain JSON values, since the gRPC path converts data parts to a protobuf Struct.

Verification

  • New tests: kagent part shape, title fallback, non-terminal updates are not results, failed results are marked, struct payloads become JSON values, and the stored task's timeline is complete and ordered. The adapter test pins the _meta tool name.
  • Guards confirmed to fail when the bug is reintroduced: dropping the part-type key fails TestServeStreamingEvents and TestToolPartsMatchKagentShape; dropping the terminal-status check fails TestNonTerminalToolUpdateIsNotAResult. The timeline test caught the RFC3339Nano ordering bug.
  • go test passes for internal/a2a/..., internal/acp/..., internal/cli/... and internal/kagent/.... make lint reports 0 issues and make vet is clean.
  • Not yet verified against a live Substrate deployment.

The kagent UI classifies a data part as a tool call or result only by the
kagent.dev/a2a/part-type metadata key. pi-go wrote only the legacy adk_type
key, so every tool call and result rendered as unrecognized data rather than
a tool card. Emit the parts kagent's Claude and Codex harnesses emit
(go/harness/runtime/a2a/executor.go):

- tag tool parts with kagent.dev/a2a/part-type and thinking with
  kagent.dev/a2a/thought, keeping the adk_* keys for ADK clients
- name the card by the registered tool name, carried from the ACP adapter
  in _meta["pi.dev/tool-name"], falling back to the display title
- result shape {id, name, response: {result, isError}}
- emit a result only for a terminal update: a running subagent's
  per-nested-call card refresh produced a nameless result card each time
  and orphaned the real result's name
- set kagent.dev/a2a/timeline-position on every artifact (repeated on the
  closing replacement, which overwrites artifact metadata) in a fixed-width
  format, since the UI sorts positions as strings and RFC3339Nano trims
  trailing zeros
- convert tool inputs and outputs to plain JSON values for the gRPC Struct

Signed-off-by: pi <dimetron@me.com>

@dimetron dimetron left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Reviewed git diff main...HEAD at 4f7525f, including the inherited model-documentation and release changes, against the local kagent reference.

Standards: no actionable findings.

Spec: no actionable findings. Checked tool metadata, registered names, result envelopes, terminal update filtering, JSON normalization, and timeline reconstruction against kagent's harness and UI consumer.

Validation: go test ./internal/a2a/... ./internal/acp/server/adapter ./hack/modelsdoc passed. Live Substrate behavior was not exercised. Tracked files remain unchanged.

— Codex review

@dimetron

Copy link
Copy Markdown
Owner Author

govulncheck — make vulncheck on 4f7525f

Gate: pass. There are no findings with an available fix.

9 findings have no released fix. They are reported here and do not fail the gate. All are in github.com/ollama/ollama, and none was introduced by this PR (no dependency changes):
GO-2025-3557, GO-2025-3558, GO-2025-3559, GO-2025-3582, GO-2025-3689, GO-2025-3695, GO-2025-3824, GO-2025-4251, GO-2026-5750.

Scanner: govulncheck v1.9.0 · Go 1.27.4 · DB https://vuln.go.dev, updated 2026-11-11 02:51 UTC

@codecov

codecov Bot commented Nov 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.24324% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.58%. Comparing base (aa9f94e) to head (4f7525f).

Files with missing lines Patch % Lines
internal/a2a/server/stream.go 92.30% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #473      +/-   ##
==========================================
- Coverage   91.60%   91.58%   -0.03%     
==========================================
  Files         390      390              
  Lines       50146    50197      +51     
==========================================
+ Hits        45937    45971      +34     
- Misses       4203     4220      +17     
  Partials        6        6              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dimetron
dimetron merged commit fec5ff9 into main Nov 14, 2026
14 of 15 checks passed
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.

1 participant