Skip to main content
Configure agents by passing functional options to NewAgent. The same options apply to NewAgentWorker when running a separate worker process. Key defaults: in-process runtime (no Temporal or Restate options), 5 max iterations, parallel tool execution, 5-minute timeout on interactive mode. All options can be overridden at construction time; per-run overrides use AgentRunOptions.
A durable runtime connection is optional. Omit Temporal and Restate options to use the in-process runtime; import pkg/agent/runtime/temporal or pkg/agent/runtime/restate and add the matching config option for durable execution. All other options work identically across runtimes.

Core options

Runtime options

See Runtimes, Temporal runtime, and Restate runtime for connection details.
Provide either Temporal options or restate.WithRestateConfig, not both.

TemporalConfig fields

RestateConfig fields

Restate embeds the SDK endpoint in NewAgent. When Restate runs in Docker and the agent on the host, set DeploymentURL to something Restate can reach (e.g. http://host.docker.internal:9080). See Restate runtime and restate-setup.md.

Execution options

Context deadlines always take precedence over WithTimeout. See Timeouts & Modes.

Tools and approval

Use the same WithAgentToolExecutionMode on NewAgent, NewAgentWorker, and all sub-agents in a deployment.

Features

Observability

See Tracing and Observability example.

Per-run options

Pass AgentRunOptions as the third argument to Run. For Stream, use AgentStreamOptions (same conversation fields):
When conversation is enabled, pass the same ID on every call in a session to share history across turns.

Runtime registries

After NewAgent, mutate registered capabilities without restarting. Each run picks up the current registry state: See Dynamic capabilities.

Agent and worker alignment

When splitting client and worker across processes, NewAgent and NewAgentWorker must share identical configuration — the SDK validates this with a fingerprint check at activity entry. See Distributed execution.

Token usage

There is no separate token usage option. Read LLMUsage from AgentRunResult after Run, or from AgentRunFinishedEvent.Result.LLMUsage after Stream.