Skip to main content
The problem: You need more than one agent in the same process — different system prompts or roles. The solution: Create one NewAgent per role, each with its own distinct WithName.
Use the same options on NewAgent and NewAgentWorker for a given agent so client and worker pair correctly.

Restate

Same process: set a distinct Endpoint.ListenAddress per agent.
See Restate runtime and the Multiple Agents example. Register specialists on the main agent with WithSubAgents. Sub-agent names must differ from the root agent name.

Same process, concurrent runs

Single agent, multiple requests

A single Agent instance handles concurrent Run and Stream calls from different goroutines. Each call gets its own unique Temporal workflow (or in-process goroutine) — no serialisation, no queuing.
Use this when one agent definition serves many parallel requests — a single Agent object is all you need. Example: Concurrent Runs.

Multiple agents, concurrent runs

Example: Multiple Agents.

Shared vs separate resources

Distributed execution with multiple agents

When splitting client and worker:
  1. Create one NewAgentWorker per agent
  2. Pass matching options to each worker and its corresponding NewAgent
  3. Use Redis conversation when any agent uses remote workers
See Distributed Execution.

In-process runtime

Multiple in-process agents (no Temporal/Restate) are also supported — omit Temporal and Restate options on each NewAgent. Each agent runs its loop inside your Go process. Use this for development and single-process deployments. See In-Process runtime.

Examples

Concurrent Runs

Fan-out on a single Agent instance

Multiple Agents

Several agents in one process

Sub-agents

Orchestrator + specialist pattern

Distributed Execution

Client and worker pairing