Clone agents to give each channel, tenant, or session its own isolated instance — without losing config or hittingDocumentation Index
Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
Use this file to discover all available pages before exploring further.
RLock pickling errors.
Quick Start
How It Works
Agent cloning creates a fresh instance with the same configuration but isolated state.What gets cloned vs. what’s reset
| Attribute | Behaviour in clone |
|---|---|
name, role, goal, backstory, instructions | Copied as-is |
llm, base_url, api_key, auth | Copied as-is |
tools | Shallow-copied (list(self.tools)) |
handoffs | Reset to None (channels should not share handoffs) |
All feature configs: memory, knowledge, planning, reflection, guardrails, web, context, autonomy, output, execution, templates, caching, hooks, skills, approval, learn, sandbox | Forwarded from the stored _<name>_config attributes |
tool_timeout, parallel_tool_calls, cli_backend | Forwarded |
interrupt_controller | Fresh instance (no cross-channel interference) |
__cache_lock (threading.RLock) | Fresh instance |
_cost_lock (threading.Lock) | Fresh instance |
Common Patterns
Per-channel clone in a custom gateway
Per-tenant clone in a multi-tenant API
Use with copy.deepcopy
Best Practices
Prefer clone_for_channel() over copy.deepcopy() for channels
Prefer clone_for_channel() over copy.deepcopy() for channels
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.Don't share handoffs across channels
Don't share handoffs across channels
Tools are shallow-copied
Tools are shallow-copied
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.
Related
Bot Gateway
Multi-channel gateway using agent cloning
Thread Safety
Agent thread safety and concurrency

