microsoft / microsoft/agent-framework-go
[dotnet-code] Extract run logger error helper
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 618
- Forks
- 56
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 122
Description
> [!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](https://github.com/microsoft/agent-framework-go/compare/main...dotnet-code-logging-error-helper-20260916222945-dc7a312b622c0e13?expand=1&title=%5Bdotnet-code%5D%20Extract%20run%20logger%20error%20helper)**
>
> 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 **Settings** → **Actions** → **General** and enable **Allow GitHub Actions to create and approve pull requests**. See also: [gh-aw FAQ](https://github.github.com/gh-aw/reference/faq/#why-is-my-create-pull-request-workflow-failing-with-github-actions-is-not-permitted-to-create-or-approve-pull-requests)
Show patch (47 lines)
```diff
From 3d6c7951f4fd124990562f80e4f76aa38419205b Mon Sep 17 00:00:00 2001
X-GH-AW-Base-Commit: c9acdbc21c5841cccd0b6df5fa1e35e1e2b16022
From: "github-actions[bot]"
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:
>
> ```yaml
> network:
> allowed:
> - defaults
> - "github.com"
> ```
>
> See [Network Configuration](https://github.github.com/gh-aw/reference/network/) for more information.
>
>
> Generated by [.NET-to-Go Code Portability Refactoring Agent](https://github.com/microsoft/agent-framework-go/actions/runs/35157680055) · copilot · gpt55 · 79.6 AIC · ⌖ 15.8 AIC · ⊞ 18.4K · [◷](https://github.com/search?q=repo%3Amicrosoft%2Fagent-framework-go+%22gh-aw-workflow-id%3A+dotnet-code-portability-nightly%22&type=pullrequests)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review agent/logger.go and the existing branch changes first. Run go test ./agent; the work is done when the run logger uses a private error helper, preserves cancellation and failure messages and levels, and changes no public Go API.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- observability
- Issue type
- Refactor
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 15/100