Skip to content

Send A2A ErrorContent as text instead of a JSON blob - #1116

Open
PratikDhanave (PratikDhanave) wants to merge 2 commits into
microsoft:mainfrom
PratikDhanaveFork:fix/a2a-error-content-text-part
Open

PratikDhanave (PratikDhanave) wants to merge 2 commits into
microsoft:mainfrom
PratikDhanaveFork:fix/a2a-error-content-text-part

Conversation

@PratikDhanave

Copy link
Copy Markdown
Contributor

When converting framework contents to A2A parts, contentsToParts had no case for *message.ErrorContent, so it fell through to the default branch and was json.Marshaled into an opaque text part like {"Message":"boom","Type":"error"} instead of the human-readable error text.

The Python client maps an error to a text part carrying content.message: case "error": parts.append(A2APart(text=content.message or "An error occurred.")).

Change

  • Add a *message.ErrorContent case that emits cmp.Or(c.Message, "An error occurred.") as a text part. contentsToParts is the shared outbound converter, so both client and hosting paths benefit.

Test

  • TestRunSendsErrorContentAsText: an input message carrying an ErrorContent{Message:"boom"} now sends a text part "boom". Fails before (the JSON blob), passes after.

contentsToParts had no case for ErrorContent, so it fell through to the
default branch and was serialized as a JSON object
({"Message":"boom","Type":"error"}) instead of the readable error
text. Emit the error message as a text part, matching the Python client.
Copilot AI lite review requested due to automatic review settings September 20, 2026 04:21
@github-actions github-actions Bot added area:provider Changes files in the provider area area:provider/a2a Changes files in the provider / a2a area size:medium At most 100 changed lines across at most 5 files labels Sep 20, 2026

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 review overview

🟢 Approval recommended

The functional change is small, targeted, and covered by a new regression test; only a minor test comment placement issue was found.

Review effort: Lite
Findings: 1 Low severity

Open (1)
What changed in this PR

This PR updates the A2A provider’s outbound content conversion so *message.ErrorContent is emitted as a human-readable text part (instead of falling back to JSON-marshaled text), aligning behavior with the Python client and improving readability for downstream consumers.

Changes:

  • Add an explicit *message.ErrorContent case in contentsToParts to emit cmp.Or(c.Message, "An error occurred.") as a text part.
  • Add a regression test verifying ErrorContent{Message:"boom"} is sent as the text part "boom".
File Description
provider/​a2aprovider/​a2a.go Adds explicit outbound conversion for *message.ErrorContent to a readable text part.
provider/​a2aprovider/​a2a_test.go Adds a test ensuring ErrorContent is sent as text, not JSON-blob text.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread provider/a2aprovider/a2a_test.go Outdated
Comment on lines +302 to +305
// TestRunWithValidUserMessage tests successful run with valid user message
// An ErrorContent must be sent to A2A as its human-readable text, not as an
// opaque JSON blob (the default-branch behavior), matching the Python client.
func TestRunSendsErrorContentAsText(t *testing.T) {
@github-actions github-actions Bot added kind:code Changes production behavior or code kind:tests Changes tests, fixtures, or test infrastructure labels Sep 20, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot added the parity-approved Go API consistency review found no parity issues label Sep 20, 2026
Move the TestRunWithValidUserMessage comment back above its test rather than
leaving it above the newly inserted TestRunSendsErrorContentAsText.
@github-actions

Copy link
Copy Markdown
Contributor

Scope: user-visible behavior (bug fix)

Changed Go contract: No exported Go API added, changed, or removed. contentsToParts (internal helper in provider/a2aprovider/a2a.go) is a private function; the user-visible change is the wire-format output of the A2A outbound converter — *message.ErrorContent now serializes to a plain text part (cmp.Or(c.Message, "An error occurred.")) instead of an opaque JSON blob ({"Message":"...","Type":"error"}) via the default branch's json.Marshal.

Upstream evidence reviewed:

  • Python: python/packages/a2a/agent_framework_a2a/_agent.py, _prepare_message_for_a2a, case "error": branch (~line 1047-1052): A2APart(text=content.message or "An error occurred.", metadata=content.additional_properties or {}).
  • .NET: searched dotnet/src/Microsoft.Agents.AI.A2A/Extensions/A2AAIContentExtensions.cs (ToPart/ToParts) — the concrete per-content-type ToPart() implementation is not present in this repo (likely supplied by the external A2A SDK), so no .NET evidence could be located for this specific mapping. No equivalent found in-repo.

Result: aligned. The Go fix (cmp.Or(c.Message, "An error occurred.") as a text part) exactly mirrors the Python content.message or "An error occurred." text-part behavior, including the same fallback string. This is a bug fix restoring parity that was previously broken (error content fell through to the JSON-blob default case), not a new public API or behavior divergence. No exported Go symbols changed, so public-api-change is not applicable; no label added/removed.

Generated by Go API Consistency Review Agent · copilot · auto · 31.3 AIC · ⌖ 6.94 AIC · ⊞ 9.2K · ◷

@github-actions github-actions Bot added the kind:dependencies Changes dependencies or manifests label Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:provider/a2a Changes files in the provider / a2a area area:provider Changes files in the provider area kind:code Changes production behavior or code kind:dependencies Changes dependencies or manifests kind:tests Changes tests, fixtures, or test infrastructure parity-approved Go API consistency review found no parity issues size:medium At most 100 changed lines across at most 5 files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants