Fix A2A fallback artifact text#4548
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens the A2A gateway’s non-streaming fallback behavior so tasks can’t be marked completed without preserving textual content, and adds decoding for Agent.Chat responses that provide text in provider-style fields (when reply is missing).
Changes:
- Fail tasks with a diagnostic message when the fallback/non-stream Agent.Chat path returns an empty (or whitespace-only) reply.
- Decode Agent.Chat responses from multiple provider-compatible text fields (
reply,answer,content,text, andmessage.{content,text}). - Add regression tests for the streaming-unsupported fallback path and the new reply decoder.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
gateway/a2a/a2a.go |
Adds empty-reply failure handling in the dispatcher and introduces decodeAgentChatReply to extract text from multiple response shapes. |
gateway/a2a/a2a_test.go |
Adds regression coverage for fallback completion with empty text and coverage for the decoder’s provider-field fallbacks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+557
to
+562
| if got := textOf(event.Result.Artifacts[0].Parts); got == "" { | ||
| t.Fatalf("fallback artifact text is empty: %+v", event.Result.Artifacts) | ||
| } | ||
| if got := textOf(event.Result.History[len(event.Result.History)-1].Parts); got == "" { | ||
| t.Fatalf("fallback history text is empty: %+v", event.Result.History) | ||
| } |
Comment on lines
+565
to
+583
| func TestDecodeAgentChatReplyFallsBackToProviderTextFields(t *testing.T) { | ||
| for name, body := range map[string]string{ | ||
| "answer": `{"answer":"answer text"}`, | ||
| "content": `{"content":"content text"}`, | ||
| "text": `{"text":"text field"}`, | ||
| "message_content": `{"message":{"content":"message content"}}`, | ||
| "message_text": `{"message":{"text":"message text"}}`, | ||
| } { | ||
| t.Run(name, func(t *testing.T) { | ||
| got, err := decodeAgentChatReply([]byte(body)) | ||
| if err != nil { | ||
| t.Fatalf("decodeAgentChatReply error: %v", err) | ||
| } | ||
| if strings.TrimSpace(got) == "" { | ||
| t.Fatalf("decodeAgentChatReply(%s) returned empty text", body) | ||
| } | ||
| }) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
replyis absent.Testing:
Closes #4522
Closes #4547