microsoft / microsoft/agent-framework

.NET: [Bug]: Exception in workflow, that is added as agent, results in json serialisation error message instead of exception

Open
#8,012 1 comment 0 reactions 1 assignee View on GitHub

@peibekwe is already working on this.

Since Sep 2, 2026.

.NET reproduced workflows
Dominant language
Python
Stars
13.6k
Forks
2.3k
Avg merge
2d 45m
Merged PRs (30d)
358

Description

### Description

Have a workflow that throws an exception. Have the workflow registered as an agent.

Call the agent. Instead of the actual exception being logged, it results in a JSON serialisation error towards the user.

This was an issue in Semantic Kernel already: https://github.com/microsoft/semantic-kernel/issues/10708

### Code Sample

```markdown
var workflowAsAgent = builder
.AddWorkflow("super-agent", CreateWorkflowDelegate)
.AddAsAIAgent(); // Now the workflow can be used as an agent
```

### Error Messages / Stack Traces

Internal (swallowed) exception:
```markdown
Exception has occurred: CLR/System.InvalidOperationException
Exception thrown: 'System.InvalidOperationException' in Microsoft.Agents.AI.Workflows.dll: 'Executor 'AggregatorExecutor' cannot send messages of type 'MySolution.Workflow.RawAggregate'.'
at Microsoft.Agents.AI.Workflows.InProc.InProcessRunnerContext.d__30.MoveNext() in /home/vsts/work/1/s/agent-framework/dotnet/src/Microsoft.Agents.AI.Workflows/InProc/InProcessRunnerContext.cs:line 235
```

What the user sees:
> Serialization and deserialization of 'System.Reflection.MethodBase' instances is not supported. Path: $.TargetSite. (Code: execution_error)

Image

### Package Versions

```xml










```

### .NET Version

.Net 10.0

### Additional Context

_No response_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.