> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agenticenv.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Multiple Agents

> Run two root agents concurrently in one process

Runs two independent root agents concurrently in the same process.

Source: [`examples/multiple_agents/`](https://github.com/agenticenv/agent-sdk-go/tree/main/examples/multiple_agents)

## What it demonstrates

* Two `NewAgent` instances in one process
* Concurrent `Run` calls on separate agents
* Restate: a separate `ListenAddress` per agent when co-located

## Run

From `examples/` with Temporal:

```bash theme={null}
task infra:temporal:up && task infra:temporal:wait
AGENT_RUNTIME=temporal go run ./multiple_agents
```

With Restate:

```bash theme={null}
task infra:restate:up && task infra:restate:wait
AGENT_RUNTIME=restate go run ./multiple_agents
```

## Key code

```go theme={null}
agent1, err := agent.NewAgent(
    agent.WithName("math-agent"),
    agent.WithLLMClient(llmClient),
    // plus Temporal or Restate runtime options for this agent
)

agent2, err := agent.NewAgent(
    agent.WithName("writing-agent"),
    agent.WithLLMClient(llmClient),
    // plus Temporal or Restate runtime options for this agent
)
```

See [Multiple agents](/advanced/multiple-agents).

## Expected output

```
--- Agent 1 (math) ---
Agent 1 (math): Hello from the math assistant! I'm ready to help.
--- Agent 2 (creative) ---
Agent 2 (creative): Hello from the creative writing assistant!
```

## Learn more

<CardGroup cols={2}>
  <Card title="Multiple Agents" icon="layer-group" href="/advanced/multiple-agents" horizontal>
    Several agents in one process
  </Card>

  <Card title="Sub-agents" icon="sitemap" href="/examples/subagents" horizontal>
    Delegation vs separate root agents
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.