Skip to content

Commit a4765fc

Browse files
author
camel-docs-bot
committed
Auto-update documentation after merge [skip ci]
1 parent 5a7c335 commit a4765fc

File tree

1 file changed

+134
-2
lines changed

1 file changed

+134
-2
lines changed

docs/mintlify/reference/camel.agents.chat_agent.mdx

Lines changed: 134 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,45 @@
88
def _cleanup_temp_files():
99
```
1010

11+
<a id="camel.agents.chat_agent._ToolOutputCacheManager"></a>
12+
13+
## _ToolOutputCacheManager
14+
15+
```python
16+
class _ToolOutputCacheManager:
17+
```
18+
19+
Minimal persistent store for caching verbose tool outputs.
20+
21+
<a id="camel.agents.chat_agent._ToolOutputCacheManager.__init__"></a>
22+
23+
### __init__
24+
25+
```python
26+
def __init__(self, base_dir: Union[str, Path]):
27+
```
28+
29+
<a id="camel.agents.chat_agent._ToolOutputCacheManager.save"></a>
30+
31+
### save
32+
33+
```python
34+
def save(
35+
self,
36+
tool_name: str,
37+
tool_call_id: str,
38+
content: str
39+
):
40+
```
41+
42+
<a id="camel.agents.chat_agent._ToolOutputCacheManager.load"></a>
43+
44+
### load
45+
46+
```python
47+
def load(self, cache_id: str):
48+
```
49+
1150
<a id="camel.agents.chat_agent.StreamContentAccumulator"></a>
1251

1352
## StreamContentAccumulator
@@ -249,6 +288,9 @@ Class for managing conversations of CAMEL Chat Agents.
249288
- **mask_tool_output** (Optional[bool]): Whether to return a sanitized placeholder instead of the raw tool output. (default: :obj:`False`)
250289
- **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`)
251290
- **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`)
291+
- **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`)
292+
- **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`)
293+
- **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`)
252294
- **retry_attempts** (int, optional): Maximum number of retry attempts for rate limit errors. (default: :obj:`3`)
253295
- **retry_delay** (float, optional): Initial delay in seconds between retries. Uses exponential backoff. (default: :obj:`1.0`)
254296
- **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__(
279321
mask_tool_output: bool = False,
280322
pause_event: Optional[Union[threading.Event, asyncio.Event]] = None,
281323
prune_tool_calls_from_memory: bool = False,
324+
enable_tool_output_cache: bool = True,
325+
tool_output_cache_threshold: int = 2000,
326+
tool_output_cache_dir: Optional[Union[str, Path]] = None,
282327
retry_attempts: int = 3,
283328
retry_delay: float = 1.0,
284329
step_timeout: Optional[float] = None,
@@ -468,6 +513,86 @@ def add_tools(self, tools: List[Union[FunctionTool, Callable]]):
468513

469514
Add a list of tools to the agent.
470515

516+
<a id="camel.agents.chat_agent.ChatAgent.retrieve_cached_tool_output"></a>
517+
518+
### retrieve_cached_tool_output
519+
520+
```python
521+
def retrieve_cached_tool_output(self, cache_id: str):
522+
```
523+
524+
Load a cached tool output by its cache identifier.
525+
526+
**Parameters:**
527+
528+
- **cache_id** (str): Identifier provided in cached tool messages.
529+
530+
**Returns:**
531+
532+
str: The cached content or an explanatory error message.
533+
534+
<a id="camel.agents.chat_agent.ChatAgent._ensure_tool_cache_lookup_tool"></a>
535+
536+
### _ensure_tool_cache_lookup_tool
537+
538+
```python
539+
def _ensure_tool_cache_lookup_tool(self):
540+
```
541+
542+
<a id="camel.agents.chat_agent.ChatAgent._serialize_tool_result"></a>
543+
544+
### _serialize_tool_result
545+
546+
```python
547+
def _serialize_tool_result(self, result: Any):
548+
```
549+
550+
<a id="camel.agents.chat_agent.ChatAgent._summarize_tool_result"></a>
551+
552+
### _summarize_tool_result
553+
554+
```python
555+
def _summarize_tool_result(self, text: str, limit: int = 160):
556+
```
557+
558+
<a id="camel.agents.chat_agent.ChatAgent._register_tool_output_for_cache"></a>
559+
560+
### _register_tool_output_for_cache
561+
562+
```python
563+
def _register_tool_output_for_cache(
564+
self,
565+
func_name: str,
566+
tool_call_id: str,
567+
result_text: str,
568+
records: List[MemoryRecord]
569+
):
570+
```
571+
572+
<a id="camel.agents.chat_agent.ChatAgent._process_tool_output_cache"></a>
573+
574+
### _process_tool_output_cache
575+
576+
```python
577+
def _process_tool_output_cache(self):
578+
```
579+
580+
<a id="camel.agents.chat_agent.ChatAgent._cache_tool_output_entry"></a>
581+
582+
### _cache_tool_output_entry
583+
584+
```python
585+
def _cache_tool_output_entry(self, entry: _ToolOutputHistoryEntry):
586+
```
587+
588+
<a id="camel.agents.chat_agent.ChatAgent._build_cache_reference_text"></a>
589+
590+
### _build_cache_reference_text
591+
592+
```python
593+
def _build_cache_reference_text(self, entry: _ToolOutputHistoryEntry, cache_id: str):
594+
```
595+
471596
<a id="camel.agents.chat_agent.ChatAgent.add_external_tool"></a>
472597

473598
### add_external_tool
@@ -531,7 +656,8 @@ def update_memory(
531656
self,
532657
message: BaseMessage,
533658
role: OpenAIBackendRole,
534-
timestamp: Optional[float] = None
659+
timestamp: Optional[float] = None,
660+
return_records: bool = False
535661
):
536662
```
537663

@@ -551,7 +677,13 @@ a `FunctionCallingMessage`).
551677

552678
- **message** (BaseMessage): The new message to add to the stored messages.
553679
- **role** (OpenAIBackendRole): The backend role type.
554-
- **timestamp** (Optional[float], optional): Custom timestamp for the memory record. If `None`, the current time will be used. (default: :obj:`None`) (default: obj:`None`)
680+
- **timestamp** (Optional[float], optional): Custom timestamp for the memory record. If `None`, the current time will be used. (default: :obj:`None`)
681+
- **return_records** (bool, optional): When `__INLINE_CODE_0____INLINE_CODE_1__MemoryRecord__INLINE_CODE_2__False`)
682+
683+
**Returns:**
684+
685+
Optional[List[MemoryRecord]]: The records that were written when
686+
`__INLINE_CODE_0____INLINE_CODE_1____INLINE_CODE_2____INLINE_CODE_3____INLINE_CODE_4__`.
555687

556688
<a id="camel.agents.chat_agent.ChatAgent.load_memory"></a>
557689

0 commit comments

Comments
 (0)