Skip to content

.NET: [Feature]: Add ability to define a custom ChatHistoryProvider for Workflow as Agent #6327

Description

Description

When I create a Workflow as an Agent, for example:

var agent = AgentWorkflowBuilder.BuildSequential(agent1, agent2).AsAIAgent();
var session = await agent.CreateSessionAsync();

The CreateSessionAsync method creates a WorkflowSession that always uses a WorkflowChatHistoryProvider:

this.ChatHistoryProvider = new WorkflowChatHistoryProvider();

It would be useful to have the ability to specify a custom chat history provider, or change its properties, as is possible with regular Agents.

Language/SDK

.NET

Activity

  1. added
    .NETUsage: [Issues, PRs], Target: .Net
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Jun 4, 2026
  2. changed the title [-][Feature]: Add ability to define a custom ChatHistoryProvider for Workflow as Agent[/-] [+].NET: [Feature]: Add ability to define a custom ChatHistoryProvider for Workflow as Agent[/+] on Jun 4, 2026
  3. removed
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Jun 4, 2026
  4. marcominerva commented on Jun 25, 2026

    @marcominerva
    ContributorAuthor

    To provide some additional context, this request stems from the need to customize how Chat History is managed when a workflow is exposed as an Agent. Since we are effectively dealing with an Agent, it would be useful to be able to configure the same properties that are typically available when using an InMemoryChatHistoryProvider in a "classic" Agent, in order to control how history messages are handled. For example:

    var chatHistoryProvider = new InMemoryChatHistoryProvider(new()
    {
        ChatReducer = new MessageCountingChatReducer(20),
        ReducerTriggerEvent = InMemoryChatHistoryProviderOptions.ChatReducerTriggerEvent.AfterMessageAdded,
        StorageInputRequestMessageFilter = messages =>
        {
            return messages.Where(m => m.GetAgentRequestMessageSourceType() != AgentRequestMessageSourceType.ChatHistory
                && m.GetAgentRequestMessageSourceType() != AgentRequestMessageSourceType.AIContextProvider);
        }
    });
  5. VolzM commented on Jul 6, 2026

    @VolzM

    I'm having the same issue. I'm trying to retrieve the Chat History from a WorkflowSession. But since WorkflowSession and WorkflowChatHistoryProvider are both internal I have no clean way to access it.

  6. marcominerva commented on Sep 29, 2026

    @marcominerva
    ContributorAuthor

    I finally found some time to put together a PR: #8840.

    I believe this new feature could be useful in a number of scenarios. I already have several customers with use cases that would benefit from this kind of approach, so I hope the proposal can be considered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

.NETUsage: [Issues, PRs], Target: .Net

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions