Skip to content

Conversation

@SergeyMenshykh
Copy link
Member

@SergeyMenshykh SergeyMenshykh commented Nov 3, 2025

Motivation and Context

This PR presents a POC for an alternative design for background responses in AF. It proposes using the RunBackgroundAsync and RunBackgroundStreamingAsync methods for background responses, as well as for non-background responses, instead of the RunAsync and RunStreamingAsync methods with AgentRunOptions.AllowBackgroundResponses.

The reason for introducing a new pair of methods is to allow developers to explicitly call them when their code is ready to handle both background and non-background responses. The concern with the current approach, which uses AgentRunOptions.AllowBackgroundResponses, is that in a large application, agent run options with enabled background responses can inadvertently propagate through the system and may enable background responses for agents even when the application code is not prepared to handle them, leading to potential silent errors.

Pros:

  • The design is less error-prone, as developers will need to explicitly opt-in to the background responses behavior through the method call rather than via an option.

Cons:

  • Not all agents support background responses, and adding methods to the abstraction that are only supported by a few does not sound appropriate.
  • Background responses can still be initiated when using the ChatClientAgent.Run{Streaming}Async methods via ChatClientOptions but will have to be continued/resumed via RunBackgroundStreamingAsync.
  • The developer experience will differ from that of chat clients that use ChatClientOptions.AllowBackgroundResponses.
  • All decorators will need to be updated.
  • The methods need to be named in a way that clearly reflects their background and non-background nature, which can be challenging.
  • It may create a confusing experience for consumers trying to decide which method to use.

Related to: #1841

@SergeyMenshykh SergeyMenshykh self-assigned this Nov 3, 2025
@TaoChenOSU TaoChenOSU removed the workflows Related to Workflows in agent-framework label Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants