Skip to content

armgit / camel

Public Imported from GitHub
0

🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

Auto-update documentation after merge [skip ci]

camel-docs-bota4765fc3ea0a
diff --git a/docs/mintlify/reference/camel.agents.chat_agent.mdx b/docs/mintlify/reference/camel.agents.chat_agent.mdx
index 55a18f303..9bc3c37a0 100644
--- a/docs/mintlify/reference/camel.agents.chat_agent.mdx
+++ b/docs/mintlify/reference/camel.agents.chat_agent.mdx
@@ -8,6 +8,45 @@
def _cleanup_temp_files():
```
+<a id="camel.agents.chat_agent._ToolOutputCacheManager"></a>
+
+## _ToolOutputCacheManager
+
+```python
+class _ToolOutputCacheManager:
+```
+
+Minimal persistent store for caching verbose tool outputs.
+
+<a id="camel.agents.chat_agent._ToolOutputCacheManager.__init__"></a>
+
+### __init__
+
+```python
+def __init__(self, base_dir: Union[str, Path]):
+```
+
+<a id="camel.agents.chat_agent._ToolOutputCacheManager.save"></a>
+
+### save
+
+```python
+def save(
+ self,
+ tool_name: str,
+ tool_call_id: str,
+ content: str
+):
+```
+
+<a id="camel.agents.chat_agent._ToolOutputCacheManager.load"></a>
+
+### load
+
+```python
+def load(self, cache_id: str):
+```
+
<a id="camel.agents.chat_agent.StreamContentAccumulator"></a>
## StreamContentAccumulator
@@ -249,6 +288,9 @@ Class for managing conversations of CAMEL Chat Agents.
- **mask_tool_output** (Optional[bool]): Whether to return a sanitized placeholder instead of the raw tool output. (default: :obj:`False`)
- **pause_event** (Optional[Union[threading.Event, asyncio.Event]]): Event to signal pause of the agent's operation. When clear, the agent will pause its execution. Use threading.Event for sync operations or asyncio.Event for async operations. (default: :obj:`None`)
- **prune_tool_calls_from_memory** (bool): Whether to clean tool call messages from memory after response generation to save token usage. When enabled, removes FUNCTION/TOOL role messages and ASSISTANT messages with tool_calls after each step. (default: :obj:`False`)
+- **enable_tool_output_cache** (bool, optional): Whether to offload verbose historical tool outputs to a local cache and replace them with lightweight references in memory. Only older tool results whose payload length exceeds `__INLINE_CODE_0____INLINE_CODE_1__True`)
+- **tool_output_cache_threshold** (int, optional): Minimum character length of a tool result before it becomes eligible for caching. Values below or equal to zero disable caching regardless of the toggle. (default: :obj:`2000`)
+- **tool_output_cache_dir** (Optional[Union[str, Path]], optional): Target directory for cached tool outputs. When omitted, a `__INLINE_CODE_0____INLINE_CODE_1__None`)
- **retry_attempts** (int, optional): Maximum number of retry attempts for rate limit errors. (default: :obj:`3`)
- **retry_delay** (float, optional): Initial delay in seconds between retries. Uses exponential backoff. (default: :obj:`1.0`)
- **step_timeout** (Optional[float], optional): Timeout in seconds for the entire step operation. If None, no timeout is applied. (default: :obj:`None`)
@@ -279,6 +321,9 @@ def __init__(
mask_tool_output: bool = False,
pause_event: Optional[Union[threading.Event, asyncio.Event]] = None,
prune_tool_calls_from_memory: bool = False,
+ enable_tool_output_cache: bool = True,
+ tool_output_cache_threshold: int = 2000,
+ tool_output_cache_dir: Optional[Union[str, Path]] = None,
retry_attempts: int = 3,
retry_delay: float = 1.0,
step_timeout: Optional[float] = None,
@@ -468,6 +513,86 @@ def add_tools(self, tools: List[Union[FunctionTool, Callable]]):
Add a list of tools to the agent.
+<a id="camel.agents.chat_agent.ChatAgent.retrieve_cached_tool_output"></a>
+
+### retrieve_cached_tool_output
+
+```python
+def retrieve_cached_tool_output(self, cache_id: str):
+```
+
+Load a cached tool output by its cache identifier.
+
+**Parameters:**
+
+- **cache_id** (str): Identifier provided in cached tool messages.
+
+**Returns:**
+
+ str: The cached content or an explanatory error message.
+
+<a id="camel.agents.chat_agent.ChatAgent._ensure_tool_cache_lookup_tool"></a>
+
+### _ensure_tool_cache_lookup_tool
+
+```python
+def _ensure_tool_cache_lookup_tool(self):
+```
+
+<a id="camel.agents.chat_agent.ChatAgent._serialize_tool_result"></a>
+
+### _serialize_tool_result
+
+```python
+def _serialize_tool_result(self, result: Any):
+```
+
+<a id="camel.agents.chat_agent.ChatAgent._summarize_tool_result"></a>
+
+### _summarize_tool_result
+
+```python
+def _summarize_tool_result(self, text: str, limit: int = 160):
+```
+
+<a id="camel.agents.chat_agent.ChatAgent._register_tool_output_for_cache"></a>
+
+### _register_tool_output_for_cache
+
+```python
+def _register_tool_output_for_cache(
+ self,
+ func_name: str,
+ tool_call_id: str,
+ result_text: str,
+ records: List[MemoryRecord]
+):
+```
+
+<a id="camel.agents.chat_agent.ChatAgent._process_tool_output_cache"></a>
+
+### _process_tool_output_cache
+
+```python
+def _process_tool_output_cache(self):
+```
+
+<a id="camel.agents.chat_agent.ChatAgent._cache_tool_output_entry"></a>
+
+### _cache_tool_output_entry
+
+```python
+def _cache_tool_output_entry(self, entry: _ToolOutputHistoryEntry):
+```
+
+<a id="camel.agents.chat_agent.ChatAgent._build_cache_reference_text"></a>
+
+### _build_cache_reference_text
+
+```python
+def _build_cache_reference_text(self, entry: _ToolOutputHistoryEntry, cache_id: str):
+```
+
<a id="camel.agents.chat_agent.ChatAgent.add_external_tool"></a>
### add_external_tool
@@ -531,7 +656,8 @@ def update_memory(
self,
message: BaseMessage,
role: OpenAIBackendRole,
- timestamp: Optional[float] = None
+ timestamp: Optional[float] = None,
+ return_records: bool = False
):
```
@@ -551,7 +677,13 @@ a `FunctionCallingMessage`).
- **message** (BaseMessage): The new message to add to the stored messages.
- **role** (OpenAIBackendRole): The backend role type.
-- **timestamp** (Optional[float], optional): Custom timestamp for the memory record. If `None`, the current time will be used. (default: :obj:`None`) (default: obj:`None`)
+- **timestamp** (Optional[float], optional): Custom timestamp for the memory record. If `None`, the current time will be used. (default: :obj:`None`)
+- **return_records** (bool, optional): When `__INLINE_CODE_0____INLINE_CODE_1__MemoryRecord__INLINE_CODE_2__False`)
+
+**Returns:**
+
+ Optional[List[MemoryRecord]]: The records that were written when
+`__INLINE_CODE_0____INLINE_CODE_1____INLINE_CODE_2____INLINE_CODE_3____INLINE_CODE_4__`.
<a id="camel.agents.chat_agent.ChatAgent.load_memory"></a>