Skip to main content
Clone agents to give each channel, tenant, or session its own isolated instance — without losing config or hitting RLock pickling errors.
The user deploys one base agent to several channels; each clone keeps the same instructions with isolated session state.

Quick Start

1

Single clone

2

Multiple clones for multi-channel deployment


How It Works

Agent cloning creates a fresh instance with the same configuration but isolated state.

What gets cloned vs. what’s reset


Common Patterns

Per-channel clone in a custom gateway

Per-tenant clone in a multi-tenant API

Use with copy.deepcopy


Best Practices

clone_for_channel() is the supported path for creating channel-safe clones. It’s optimized for multi-channel scenarios and properly handles handoffs. __deepcopy__ is provided for general Python compatibility but isn’t specifically designed for channel isolation.
Clone drops handoffs by design. Each channel should have independent routing logic. If you need cross-channel handoffs, implement them at the gateway level rather than the agent level.
If a tool holds mutable per-channel state, wrap it in a factory function or use instance-based tools. The clone shares tool instances with the original agent, which is usually fine for stateless tools.

Bot Gateway

Multi-channel gateway using agent cloning

Thread Safety

Agent thread safety and concurrency