Agent definition fields

July 29, 2026 · View on GitHub

new Agent(options: AgentOptions)

Key AgentOptions fields:

FieldTypeNotes
namestringRequired. /^[a-zA-Z][a-zA-Z0-9_-]*$/.
modelstring | ClaudeCodee.g. 'anthropic/claude-sonnet-4-6'.
baseUrlstringOverride LLM provider base URL.
instructionsstring | PromptTemplate | (() => string)Static / template / dynamic.
toolsunknown[]tool() wrappers, built-in tool defs, framework tools.
agentsAgent[]Sub-agents (multi-agent).
strategyStrategy'sequential' | 'parallel' | 'handoff' | 'router' | 'round_robin' | 'random' | 'swarm' | 'manual' | 'plan_execute'.
routerAgent | (() => string)Required for strategy: 'router'.
outputTypeZod schema or JSON SchemaStructured output.
guardrailsunknown[]Guardrail defs / instances.
handoffsHandoffCondition[]OnTextMention / OnToolResult / OnCondition.
allowedTransitionsRecord<string, string[]>Constrain agent transitions.
terminationTerminationConditionStop condition.
gateGateConditionTextGate / gate().
callbacksCallbackHandler[]Lifecycle hooks.
memoryConversationMemoryConversation history.
maxTurnsnumberDefault 25.
maxTokens / temperature / timeoutSecondsnumberLLM + execution tuning.
credentialsstring[]Secret names to resolve.
statefulbooleanPer-execution worker isolation + shared state.
planner / fallbackAgentPLAN_EXECUTE named slots.
plannerContext(string | Context | object)[]PLAN_EXECUTE reference docs.
enablePlanningbooleanPlan-first preamble.
prefillToolsPrefillToolCall[]Tools run before the first LLM turn.
cliCommands / cliAllowedCommands / cliConfigEnable CLI command execution.
codeExecutionConfigCodeExecutionConfigCode execution.
introduction / metadataAgent metadata.

Methods: agent.pipe(other) builds a sequential pipeline (flattens chains). Getters: isClaudeCode, claudeCodeConfig.

Helpers:

  • agent(fn, options) — functional form; fn is the dynamic-instructions callable.
  • scatterGather({ name, workers, model?, instructions?, retryCount?, retryDelaySeconds?, failFast?, timeoutSeconds? }) — coordinator that fans out to worker agents in parallel.
  • AgentDec(options) + agentsFrom(instance) — define agents as decorated class methods.
  • PromptTemplate(name, variables?, version?) — server-managed prompt reference.

Names must match ^[a-zA-Z][a-zA-Z0-9_-]*$. An omitted model is valid only for inherited-model or external-agent (external: true) designs. The complete constructor and serialization semantics are maintained in agent.ts and serializer.ts; use those sources when adding a newly supported field, and update the agent schema alongside.

Next steps

See agents for authoring patterns, the agent schema for the wire contract this maps to, and the API reference for everything else in the public surface.