Skip to content

Conversation

@markwallace-microsoft
Copy link
Member

Motivation and Context

Description

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

Copilot AI review requested due to automatic review settings October 30, 2025 20:23
@markwallace-microsoft markwallace-microsoft added documentation Improvements or additions to documentation .NET labels Oct 30, 2025
@github-actions github-actions bot changed the title Background responses sample .NET: Background responses sample Oct 30, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new advanced sample demonstrating background responses with function calling and state persistence. The sample (Agent_Step20_BackgroundResponses_Advanced) builds on the simpler Agent_Step17_BackgroundResponses sample by introducing function tools and state persistence capabilities.

  • Demonstrates polling for background responses with function calling
  • Shows how to persist and restore agent state (thread and continuation token) between polling cycles
  • Includes example functions with simulated long-running operations

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
dotnet/samples/GettingStarted/Agents/Agent_Step20_BackgroundResponses_Advanced/README.md Documentation explaining the advanced background responses sample with prerequisites
dotnet/samples/GettingStarted/Agents/Agent_Step20_BackgroundResponses_Advanced/Program.cs Main sample code demonstrating background responses with state persistence
dotnet/samples/GettingStarted/Agents/Agent_Step20_BackgroundResponses_Advanced/Agent_Step20_BackgroundResponses_Advanced.csproj Project configuration file
dotnet/samples/GettingStarted/Agents/Agent_Step20_BackgroundResponses_Advanced/AgentStateStore.cs Helper class for persisting and restoring agent state
dotnet/samples/GettingStarted/Agents/Agent_Step20_BackgroundResponses_Advanced/AgentFunctions.cs Sample functions for research and character generation
dotnet/agent-framework-dotnet.slnx Added new sample project to the solution

name: "SpaceNovelWriter",
instructions: "You are a space novel writer. Always research relevant facts and generate character profiles for the main characters before writing novels." +
"Write complete chapters without asking for approval or feedback. Do not ask the user about tone, style, pace, or format preferences - just write the novel based on the request.",
tools: [.. new AgentFunctions().AsAITools()]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of returning an IEnumerable<AIFunction> that could be a IList<AIFunction>.

Suggested change
tools: [.. new AgentFunctions().AsAITools()]);
tools: new AgentFunctions().AsAITools());

Comment on lines +60 to +64
public IEnumerable<AITool> AsAITools()
{
yield return AIFunctionFactory.Create(this.ResearchSpaceFactsAsync);
yield return AIFunctionFactory.Create(this.GenerateCharacterProfilesAsync);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public IEnumerable<AITool> AsAITools()
{
yield return AIFunctionFactory.Create(this.ResearchSpaceFactsAsync);
yield return AIFunctionFactory.Create(this.GenerateCharacterProfilesAsync);
}
public IList<AITool> AsAITools() =>
[
AIFunctionFactory.Create(this.ResearchSpaceFactsAsync),
AIFunctionFactory.Create(this.GenerateCharacterProfilesAsync)
];

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

Labels

documentation Improvements or additions to documentation .NET

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants