Skip to content

[dotnet-port-fixes] Surface response.failed error content #787

Description

@github-actions

Summary

Port the .NET failure-handling fix from microsoft/agent-framework#7497 into the shared Go Responses provider path so response.failed events surface structured ErrorContent instead of empty updates. The Go change also applies the same fallback to failed non-streaming responses when the provider omits explicit error details, using a default message/code rather than silently dropping the failure.

Ported .NET PRs

Upstream commit referenced: d56e81357e5179b6f916b180c0cb34ea2e73c80b.

Breaking Changes

No. This keeps the public Go API unchanged and only corrects how existing failed Responses API events are surfaced to callers.

Tests and Examples

  • go test ./provider/openaiprovider
  • go test ./provider/foundryprovider
  • Added coverage for streaming response.failed events and failed responses without explicit provider error details

Notes

  • Duplicate check: no recent [dotnet-port-fixes] or [dotnet-port-api] issue/PR title in microsoft/agent-framework-go matched this failure-handling area.
  • The fix is intentionally scoped to the shared OpenAI Responses translation path used by Foundry, so no exported API or docs/example updates were needed.

Generated by .NET to Go Fixes and Test Porting Agent · gpt54 · 282.5 AIC · ⌖ 13.4 AIC · ⊞ 24.2K · ◷


Note

This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branch dotnet-port-fixes-response-failed-error-content-5fff6162ef959527.

Click here to create the pull request

To fix the permissions issue, go to Settings → Actions → General and enable Allow GitHub Actions to create and approve pull requests. See also: gh-aw FAQ

Show patch preview (230 of 230 lines)
From 4fe40a4d95252323cc9a6e1b3a03343fac489e13 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Wed, 5 Aug 2026 03:38:25 +0000
Subject: [PATCH] [dotnet-port-fixes] Surface response.failed error content

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
 provider/openaiprovider/responses.go      | 52 +++++++++++---
 provider/openaiprovider/responses_test.go | 88 ++++++++++++++++++++---
 2 files changed, 120 insertions(+), 20 deletions(-)

diff --git a/provider/openaiprovider/responses.go b/provider/openaiprovider/responses.go
index 4605453ce..41954ed1d 100644
--- a/provider/openaiprovider/responses.go
+++ b/provider/openaiprovider/responses.go
@@ -947,12 +947,8 @@ func responsesProcessResponse(resp *responses.Response, seqNum int64, yield func
 	if usage := responsesUsageToContent(resp.Usage); usage != nil {
 		currentUpdate.Contents = append(currentUpdate.Contents, usage)
 	}
-	// If there's an error in the response, add an ErrorContent
-	if resp.Error.Message != "" {
-		currentUpdate.Contents = append(currentUpdate.Contents, &message.ErrorContent{
-			Message:   resp.Error.Message,
-			ErrorCode: string(resp.Error.Code),
-		})
+	if failure := responsesFailureContent(resp); failure != nil {
+		currentUpdate.Contents = append(currentUpdate.Contents, failure)
 	}
 	yield(currentUpdate, nil)
 }
@@ -1001,6 +997,35 @@ func responsesUsageToContent(usage responses.ResponseUsage) *message.UsageConten
 	}
 }
 
+const (
+	responsesDefaultFailureMessage = "The agent run failed."
+	responsesDefaultFailureCode    = "failed"
+)
+
+func responsesFailureContent(resp *responses.Response) *message.ErrorContent {
+	if resp == nil {
+		return nil
+	}
+	if resp.Status != responses.ResponseStatusFailed && resp.Error.Message == "" && resp.Error.Code == "" {
+		return nil
+	}
+	return responsesErrorContent(resp.Error.Message, string(resp.Error.Code), "")
+}
+
+func responsesErrorContent(msg string, code string, 
... (truncated)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions