Thread-Safe Agent State
PraisonAI Agents v0.5.0+ includes thread-safe management of chat history and caches, enabling safe concurrent access from multiple threads.Thread-Safe Components
Chat History
Thechat_history list is protected by a threading.Lock:
Caches
Internal caches usethreading.RLock for reentrant locking:
_system_prompt_cache- Cached system prompts_formatted_tools_cache- Cached tool definitions
LiteAgent Thread Safety
The lite package also provides thread-safe operations:Implementation Details
Lock Types
| Component | Lock Type | Reason |
|---|---|---|
| chat_history | Lock | Simple mutual exclusion |
| caches | RLock | Allows reentrant access |

