Send A2A ErrorContent as text instead of a JSON blob - #1116
PratikDhanave (PratikDhanave) wants to merge 2 commits into
Conversation
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.
There was a problem hiding this comment.
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
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.ErrorContentcase incontentsToPartsto emitcmp.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.
| // 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) { |
This comment has been minimized.
This comment has been minimized.
Move the TestRunWithValidUserMessage comment back above its test rather than leaving it above the newly inserted TestRunSendsErrorContentAsText.
|
Scope: user-visible behavior (bug fix) Changed Go contract: No exported Go API added, changed, or removed. Upstream evidence reviewed:
Result: aligned. The Go fix (
|

When converting framework contents to A2A parts,
contentsToPartshad no case for*message.ErrorContent, so it fell through to thedefaultbranch and wasjson.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
*message.ErrorContentcase that emitscmp.Or(c.Message, "An error occurred.")as a text part.contentsToPartsis the shared outbound converter, so both client and hosting paths benefit.Test
TestRunSendsErrorContentAsText: an input message carrying anErrorContent{Message:"boom"}now sends a text part"boom". Fails before (the JSON blob), passes after.