Sessions
Session services
Section titled “Session services”The SDK uses ISessionService to persist a Session.
Built-in implementations:
InMemorySessionServiceJsonFileSessionServiceSessionServiceFactoryhelpers for common setups
Both built-in services skip persisting partial streaming events.
ReceiveAsync pattern
Section titled “ReceiveAsync pattern”Use this when the agent should run a request to completion:
await agent.SendAsync("Review the authentication module");
await foreach (var evt in agent.ReceiveAsync()){ // consume streamed events}StepAsync pattern
Section titled “StepAsync pattern”Use this when you need explicit control over tool calls or turn boundaries:
await agent.SendAsync("Deploy version 2.1.0 to production");
var turn = await agent.StepAsync();foreach (var toolCall in turn.ToolCalls){ Console.WriteLine(toolCall.ToolName);}TurnResult exposes:
FinishReasonEventsToolCallsRequiresNextTurn
Session helpers
Section titled “Session helpers”SessionHelpers includes source-backed utilities for:
ForkRewindResumeAtRemoveFailedToolsCreateCheckpoint
These are useful for approvals, retries, and experimentation without mutating the original session in place.