Skip to content

[dotnet-code] Extract run logger error helper #1094

Description

@github-actions

Tip

Your pull request is ready to create! 🎉 ✅

Everything is OK—the changes have been pushed to branch dotnet-code-logging-error-helper-20260916222945-dc7a312b622c0e13. Please review the changes, including any protected files, before creating the pull request.

Create the pull request

The original pull request description is below.


Summary

Extracted the run logger middleware's cancellation/failure branch into an unexported logRunError helper. This keeps the Go logging middleware's internal structure closer to .NET's LoggingAgent, where canceled and failed invocation paths are separated into dedicated logging helpers, while preserving existing log messages and levels.

.NET Reference

  • dotnet/src/Microsoft.Agents.AI/LoggingAgent.cs - separates canceled and failed invocation logging into private helper methods.

Public API and Behavior

No public Go API changed. No intentional behavior change was made.

Tests

  • go test ./agent

Notes

Rejected candidates:

  • dotnet/src/Microsoft.Agents.AI.Workflows/Edge.cs / workflow/edge.go: an existing origin/dotnet-code-edge-connection-helper-b84489a37052b0dc branch appears to cover edge-connection helper cleanup.
  • dotnet/src/Microsoft.Agents.AI.Workflows/Run.cs / workflow/inproc/run.go: the event sink/bookmark structure is already closely aligned, including incremental NewEvents behavior.

The requested upstream git fetch was blocked by the environment, so the .NET reference files were read through the configured read-only GitHub MCP bridge instead.


Note

GitHub Actions is not permitted to create or approve pull requests in this repository.

The changes have been pushed to branch dotnet-code-logging-error-helper-20260916222945-dc7a312b622c0e13 and are ready to review.

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

Show patch (47 lines)
From 3d6c7951f4fd124990562f80e4f76aa38419205b Mon Sep 17 00:00:00 2001
X-GH-AW-Base-Commit: c9acdbc21c5841cccd0b6df5fa1e35e1e2b16022
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Wed, 16 Sep 2026 22:29:45 +0000
Subject: [PATCH] [dotnet-code] Extract run logger error helper

Split the internal run logger error path into a small helper so cancellation and failure logging mirror the separated .NET LoggingAgent paths without changing behavior.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
 agent/logger.go | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/agent/logger.go b/agent/logger.go
index 644e568..00a4895 100644
--- a/agent/logger.go
+++ b/agent/logger.go
@@ -32,11 +32,7 @@ func (l *runLoggerMiddleware) Run(next RunFunc, ctx context.Context, messages []
 		l.log(ctx, slog.LevelDebug, "run invoked", slogx.SensitiveData("messages", messages), slogx.SensitiveData("opts", opts))
 		for update, err := range next(ctx, messages, opts...) {
 			if err != nil {
-				if errors.Is(err, context.Canceled) {
-					l.log(ctx, slog.LevelDebug, "run canceled", "error", err)
-				} else {
-					l.log(ctx, slog.LevelError, "run failed", "error", err)
-				}
+				l.logRunError(ctx, err)
 			} else if l.l.SensitiveData {
 				l.log(ctx, slog.LevelDebug, "run received update", slogx.SensitiveData("update", update))
 			}
@@ -48,6 +44,14 @@ func (l *runLoggerMiddleware) Run(next RunFunc, ctx context.Context, messages []
 	}
 }
 
+func (l *runLoggerMiddleware) logRunError(ctx context.Context, err error) {
+	if errors.Is(err, context.Canceled) {
+		l.log(ctx, slog.LevelDebug, "run canceled", "error", err)
+		return
+	}
+	l.log(ctx, slog.LevelError, "run failed", "error", err)
+}
+
 func (l *runLoggerMiddleware) log(ctx context.Context, level slog.Level, msg string, args ...any) {
 	a, ok := AgentFromContext(ctx)
 	if ok {
-- 
2.54.0

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • github.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "github.com"

See Network Configuration for more information.

Generated by .NET-to-Go Code Portability Refactoring Agent · copilot · gpt55 · 79.6 AIC · ⌖ 15.8 AIC · ⊞ 18.4K ·

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