Skip to content

Agents

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."
};

Important runtime knobs on Agent include:

  • Model as either an ILanguageModel instance or a string model ID
  • SystemPrompt
  • ContextBuilder
  • Temperature
  • MaxTokens
  • Thinking
  • ProviderOptions
  • Tools
  • ToolTimeout
  • WorkingDirectory
  • MaxIterations
  • ContinueOnMaxTokens
  • UseStreaming
  • AutoCompaction
  • SubAgents
  • Presets
  • McpServers
  • CliToolDirs, CliTools, SkillDirs, and SkillProvider

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(...).

Full child agents can be assigned via SubAgents. Lightweight named delegation configs can be assigned via Presets.

Presets can define:

  • AllowedTools
  • Model
  • MaxIterations
  • Temperature
  • Thinking

The parent agent materializes them on demand during delegation.

Set WorkingDirectory when built-in file tools, memory, or other local operations need a concrete workspace boundary.

Agent instances are not thread-safe. Use one active invocation per instance.