-
Notifications
You must be signed in to change notification settings - Fork 763
.NET: Background responses sample #1821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.NET: Background responses sample #1821
Conversation
…ng and agent state persistence
There was a problem hiding this 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 |
...les/GettingStarted/Agents/Agent_Step20_BackgroundResponsesWithToolsAndPersistence/Program.cs
Outdated
Show resolved
Hide resolved
...tingStarted/Agents/Agent_Step20_BackgroundResponsesWithToolsAndPersistence/AgentFunctions.cs
Outdated
Show resolved
Hide resolved
...tingStarted/Agents/Agent_Step20_BackgroundResponsesWithToolsAndPersistence/AgentFunctions.cs
Outdated
Show resolved
Hide resolved
| 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()]); |
There was a problem hiding this comment.
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>.
| tools: [.. new AgentFunctions().AsAITools()]); | |
| tools: new AgentFunctions().AsAITools()); |
| public IEnumerable<AITool> AsAITools() | ||
| { | ||
| yield return AIFunctionFactory.Create(this.ResearchSpaceFactsAsync); | ||
| yield return AIFunctionFactory.Create(this.GenerateCharacterProfilesAsync); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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) | |
| ]; |
Motivation and Context
Description
Contribution Checklist