Agents
Constructing an agent
Section titled “Constructing an agent”The verified constructor takes an ISessionService:
await using var agent = new Agent(new InMemorySessionService()){ Model = provider.CreateLanguageModel("claude-sonnet-4-5-20250929"), SystemPrompt = "You are a helpful assistant."};Key configuration properties
Section titled “Key configuration properties”Important runtime knobs on Agent include:
Modelas either anILanguageModelinstance or a string model IDSystemPromptContextBuilderTemperatureMaxTokensThinkingProviderOptionsToolsToolTimeoutWorkingDirectoryMaxIterationsContinueOnMaxTokensUseStreamingAutoCompactionSubAgentsPresetsMcpServersCliToolDirs,CliTools,SkillDirs, andSkillProvider
Model resolution
Section titled “Model resolution”Model accepts either:
- a live
ILanguageModel - a string model ID such as
claude-sonnet-4-5 - an explicit provider-prefixed string like
anthropic:claude-sonnet-4-5
Samples usually create a provider first and call provider.CreateLanguageModel(...).
Presets and sub-agents
Section titled “Presets and sub-agents”Full child agents can be assigned via SubAgents. Lightweight named delegation configs can be assigned via Presets.
Presets can define:
AllowedToolsModelMaxIterationsTemperatureThinking
The parent agent materializes them on demand during delegation.
Working directory
Section titled “Working directory”Set WorkingDirectory when built-in file tools, memory, or other local operations need a concrete workspace boundary.
Thread-safety
Section titled “Thread-safety”Agent instances are not thread-safe. Use one active invocation per instance.