Reference: [AgentDef]

July 28, 2026 · View on GitHub

Declarative agent definition on a host object. See ../concepts/agents.md for usage.

Attribute properties

PropertyTypeNotes
NamestringAgent name. Must match ^[a-zA-Z_][a-zA-Z0-9_-]*$.
Modelstring"provider/model". May be left unset and assigned after resolution.
InstructionsstringStatic system prompt.
Toolsstring[]["*"] = all [Tool] methods on the host, [] = none, or explicit tool names.
Guardrailsstring[]Same filtering semantics as Tools.
Agentsstring[]Sub-agent names, resolved from other [AgentDef] methods on the same host.
StrategyStrategyRequired when Agents is non-empty.
MaxTurnsint
MaxTokensint
Temperaturedouble

Return types

The method's return type determines how much the attribute has to specify:

Return typeMeaning
voidDefined entirely by the attribute.
stringA no-arg method becomes InstructionsFn — dynamic instructions re-evaluated on every submit.
AgentA full factory; the returned agent is used as-is.

Resolution

  • Agent.FromInstance(object host)List<Agent> — every [AgentDef] method.
  • Agent.FromInstance(object host, string name)Agent — a single one by name.

Sub-agent references in Agents are resolved against the same host, so a coordinator and its children can be declared side by side in one class.

Interaction with [Tool] and [Guardrail]

[Tool] and [Guardrail] methods on the host are attached automatically unless the Tools / Guardrails filters narrow them. This is why an [AgentDef] with Tools = new string[0] is meaningful — it opts out of the host's tools rather than merely leaving them unset.