Agent instance is independent. Give distinct agents unique task queues; give scaled instances of the same agent a shared base queue plus a unique WithInstanceId. This page covers patterns for co-locating agents in one process and scaling them across pods.
One agent per task queue
Each agent needs a uniqueTaskQueue in Temporal. Sub-agents also require separate queues. This prevents workflow and activity routing collisions:
WithSubAgents rather than sharing a task queue.
WithInstanceId
When multiple agents share a base task queue name — for example scaled pods running the same agent definition — useWithInstanceId so each instance gets a unique derived queue: {TaskQueue}-{InstanceId}.
TaskQueue and InstanceId on NewAgent and NewAgentWorker for a given agent so client and worker pair correctly.
Same process, concurrent runs
Single agent, multiple requests
A singleAgent instance handles concurrent Run, RunAsync, and Stream calls from different goroutines. Each call gets its own unique Temporal workflow (or in-process goroutine) — no serialisation, no queuing.
Agent object is all you need.
Example: Concurrent Runs.
Multiple agents, concurrent runs
MultipleNewAgent instances in one process each start their own embedded worker (unless DisableLocalWorker is set). Use separate instances when the agents have different configurations, system prompts, or task queues:
Shared vs separate resources
| Resource | Per agent or shared |
|---|---|
| LLM client | Can share one client across agents — use WithLLMSampling for per-agent overrides |
| Task queue | Unique per agent (or per instance via WithInstanceId) |
| Conversation store | Shared backend OK — isolate by conversation ID |
| Memory store | Shared backend OK — isolate by scope (user, tenant, agent name) |
| Tool registries | Per agent — each Agent has its own registries |
Worker separation with multiple agents
When splitting client and worker:- Create one
NewAgentWorkerper task queue (main agent and each sub-agent queue) - Pass matching options to each worker and its corresponding
NewAgent - Use Redis conversation when any agent uses remote workers
In-process runtime
Multiple in-process agents (no Temporal) are also supported — omit Temporal options on eachNewAgent. Each agent runs its loop inside your Go process with no task queue requirement. Use this for development and single-process deployments.
See In-Process runtime.
Examples
Concurrent Runs
Fan-out on a single Agent instance
Multiple Agents
Instance IDs and task queue patterns
Related
Sub-agents
Orchestrator + specialist pattern
Worker Separation
One worker per task queue
Temporal Runtime
Task queues and child workflows
Configuration
WithInstanceId and WithTemporalConfig