Skip to content

.NET: [Feature]: Consider passing AgentRunOptions to the underlying agents in WorkflowHostAgent. #3679

@javiercn

Description

@javiercn

Description

When mapping a workflow as an agent with AsAgent(), the underlying workflow ignores the agentrunoptions.

protected override async
IAsyncEnumerable<AgentResponseUpdate> RunCoreStreamingAsync(
IEnumerable<ChatMessage> messages,
AgentSession? session = null,
AgentRunOptions? options = null,
[EnumeratorCancellation] CancellationToken cancellationToken = default)
{
await this.ValidateWorkflowAsync().ConfigureAwait(false);
WorkflowSession workflowSession = await this.UpdateSessionAsync(messages, session, cancellationToken).ConfigureAwait(false);
await foreach (AgentResponseUpdate update in workflowSession.InvokeStageAsync(cancellationToken)
.ConfigureAwait(false)
.WithCancellation(cancellationToken))
{
yield return update;
}
}

Currently the AgentRunOptions are not passed to the underlying agents when the WorkflowHostAgent calls them. This means that any options set in AgentRunOptions or any other information that might be included (for example, if they are ChatClientAgentOptions with a ChatOptions and custom AdditionalProperties) can't be accessed.

Ideally the options would flow through InvokeStageAsync https://github.com/microsoft/agent-framework/blob/main/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowSession.cs#L153 and will be included in the TurnToken https://github.com/microsoft/agent-framework/blob/main/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowSession.cs#L167 so that they can be accessed by the underlying agents.

Code Sample

Language/SDK

.NET

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions