Skip to content

.NET: [Bug]: Declarative Workflows - Gracefully handle agent scenarios where no response is returned #5375

@peibekwe

Description

@peibekwe

Description

Declarative workflow runs that include InvokeAzureAgent actions could crash with:

Unhandled workflow failure - #<action_id> (InvokeAzureAgent)
→ System.InvalidOperationException: Sequence contains no elements

The crash is deterministic whenever an invoked agent returns an AgentResponse with zero Messages (e.g., a tool-only
turn where the model emits remote_function_call / mcp_call items without a final assistant text message,
content-filtered responses, or streams that close before the terminal assistant message).

Code Sample

Error Messages / Stack Traces

Package Versions

Microsoft.Agents.AI.Workflows.Declarative

.NET Version

No response

Additional Context

No response

Metadata

Metadata

Assignees

Labels

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions