This sample demonstrates how to use the durable agents extension to create a simple console app that orchestrates sequential calls to a single AI agent using the same session for context continuity.
- Orchestrating multiple interactions with the same agent in a deterministic order
- Using the same
AgentSessionacross multiple calls to maintain conversational context - Durable orchestration with automatic checkpointing and resumption from failures
- Waiting for orchestration completion using
WaitForInstanceCompletionAsync
See the README.md file in the parent directory for more information on how to configure the environment, including how to install and run common sample dependencies.
With the environment setup, you can run the sample:
cd dotnet/samples/04-hosting/DurableAgents/ConsoleApps/02_AgentOrchestration_Chaining
dotnet run --framework net10.0The app will start the orchestration, wait for it to complete, and display the result:
=== Single Agent Orchestration Chaining Sample ===
Starting orchestration...
Orchestration started with instance ID: 86313f1d45fb42eeb50b1852626bf3ff
Waiting for completion...
✓ Orchestration completed successfully!
Result: Learning serves as the key, opening doors to boundless opportunities and a brighter future.
The orchestration will proceed to run the WriterAgent twice in sequence:
- First, it writes an inspirational sentence about learning
- Then, it refines the initial output using the same conversation thread
You can view the state of the orchestration in the Durable Task Scheduler dashboard:
- Open your browser and navigate to
http://localhost:8082 - In the dashboard, you can see:
- Orchestrations: View the orchestration instance, including its runtime status, input, output, and execution history
- Agents: View the state of the WriterAgent, including conversation history maintained across the orchestration steps
The orchestration instance ID is displayed in the console output. You can use this ID to find the specific orchestration in the dashboard and inspect its execution details, including the sequence of agent calls and their results.