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-botcbee4f8de16c
diff --git a/docs/mintlify/reference/camel.agents.chat_agent.mdx b/docs/mintlify/reference/camel.agents.chat_agent.mdx
index e167d0daa..e711261f2 100644
--- a/docs/mintlify/reference/camel.agents.chat_agent.mdx
+++ b/docs/mintlify/reference/camel.agents.chat_agent.mdx
@@ -322,6 +322,21 @@ def reset(self):
Resets the :obj:`ChatAgent` to its initial state.
+<a id="camel.agents.chat_agent.ChatAgent._update_token_cache"></a>
+
+### _update_token_cache
+
+```python
+def _update_token_cache(self, usage_dict: Dict[str, Any], message_count: int):
+```
+
+Update the token count cache from LLM response usage.
+
+**Parameters:**
+
+- **usage_dict** (Dict[str, Any]): Usage dictionary from LLM response.
+- **message_count** (int): Number of messages sent to the LLM.
+
<a id="camel.agents.chat_agent.ChatAgent._resolve_models"></a>
### _resolve_models
@@ -474,39 +489,6 @@ def _get_full_tool_schemas(self):
Returns a list of tool schemas of all tools, including internal
and external tools.
-<a id="camel.agents.chat_agent.ChatAgent._is_token_limit_error"></a>
-
-### _is_token_limit_error
-
-```python
-def _is_token_limit_error(error: Exception):
-```
-
-Return True when the exception message indicates a token limit.
-
-<a id="camel.agents.chat_agent.ChatAgent._is_tool_related_record"></a>
-
-### _is_tool_related_record
-
-```python
-def _is_tool_related_record(record: MemoryRecord):
-```
-
-Determine whether the given memory record
-belongs to a tool call.
-
-<a id="camel.agents.chat_agent.ChatAgent._find_indices_to_remove_for_last_tool_pair"></a>
-
-### _find_indices_to_remove_for_last_tool_pair
-
-```python
-def _find_indices_to_remove_for_last_tool_pair(self, recent_records: List[ContextRecord]):
-```
-
-**Returns:**
-
- List[int]: Indices to remove (may be non-contiguous).
-
<a id="camel.agents.chat_agent.ChatAgent._serialize_tool_args"></a>
### _serialize_tool_args
@@ -541,14 +523,6 @@ def _update_last_tool_call_state(self, record: Optional[ToolCallingRecord]):
Track the most recent tool call and its identifying signature.
-<a id="camel.agents.chat_agent.ChatAgent._format_tool_limit_notice"></a>
-
-### _format_tool_limit_notice
-
-```python
-def _format_tool_limit_notice(self):
-```
-
<a id="camel.agents.chat_agent.ChatAgent._append_user_messages_section"></a>
### _append_user_messages_section
@@ -565,6 +539,16 @@ def _append_user_messages_section(summary_content: str, user_messages: List[str]
def _reset_summary_state(self):
```
+<a id="camel.agents.chat_agent.ChatAgent._get_context_with_summarization"></a>
+
+### _get_context_with_summarization
+
+```python
+def _get_context_with_summarization(self):
+```
+
+Get context and trigger summarization if needed.
+
<a id="camel.agents.chat_agent.ChatAgent._calculate_next_summary_threshold"></a>
### _calculate_next_summary_threshold
@@ -959,12 +943,14 @@ regular messages.
### clear_memory
```python
-def clear_memory(self):
+def clear_memory(self, reset_summary_state: bool = True):
```
-**Returns:**
+Clear the agent's memory and reset to initial state.
- None
+**Parameters:**
+
+- **reset_summary_state** (bool): Whether to reset the summary token count. Set to False when preserving summary state during summarization. Defaults to True for full memory clearing.
<a id="camel.agents.chat_agent.ChatAgent._generate_system_message_for_output_language"></a>
@@ -1286,7 +1272,6 @@ Log final messages or warnings about multiple responses.
def _get_model_response(
self,
openai_messages: List[OpenAIMessage],
- num_tokens: int,
current_iteration: int = 0,
response_format: Optional[Type[BaseModel]] = None,
tool_schemas: Optional[List[Dict[str, Any]]] = None,
diff --git a/docs/mintlify/reference/camel.memories.context_creators.score_based.mdx b/docs/mintlify/reference/camel.memories.context_creators.score_based.mdx
index af210c169..7110d2963 100644
--- a/docs/mintlify/reference/camel.memories.context_creators.score_based.mdx
+++ b/docs/mintlify/reference/camel.memories.context_creators.score_based.mdx
@@ -10,6 +10,11 @@ class ScoreBasedContextCreator(BaseContextCreator):
A context creation strategy that orders records chronologically.
+This class supports token count estimation to reduce expensive repeated
+token counting. When a cached token count is available, it estimates
+new message tokens using character-based approximation instead of
+calling the token counter for every message.
+
**Parameters:**
- **token_counter** (BaseTokenCounter): Token counter instance used to compute the combined token count of the returned messages.
@@ -39,6 +44,52 @@ def token_counter(self):
def token_limit(self):
```
+<a id="camel.memories.context_creators.score_based.ScoreBasedContextCreator.set_cached_token_count"></a>
+
+### set_cached_token_count
+
+```python
+def set_cached_token_count(self, token_count: int, message_count: int):
+```
+
+Set the cached token count from LLM response usage.
+
+**Parameters:**
+
+- **token_count** (int): The total token count (prompt + completion) from LLM response usage.
+- **message_count** (int): The number of messages including the assistant response that will be added to memory.
+
+<a id="camel.memories.context_creators.score_based.ScoreBasedContextCreator.clear_cache"></a>
+
+### clear_cache
+
+```python
+def clear_cache(self):
+```
+
+Clear the cached token count.
+
+<a id="camel.memories.context_creators.score_based.ScoreBasedContextCreator._estimate_message_tokens"></a>
+
+### _estimate_message_tokens
+
+```python
+def _estimate_message_tokens(self, message: OpenAIMessage):
+```
+
+Estimate token count for a single message.
+
+Uses ~2 chars/token as a conservative approximation to handle both
+ASCII (~4 chars/token) and CJK text (~1-2 chars/token).
+
+**Parameters:**
+
+- **message**: The OpenAI message to estimate.
+
+**Returns:**
+
+ Estimated token count (intentionally conservative).
+
<a id="camel.memories.context_creators.score_based.ScoreBasedContextCreator.create_context"></a>
### create_context
diff --git a/docs/mintlify/reference/camel.types.unified_model_type.mdx b/docs/mintlify/reference/camel.types.unified_model_type.mdx
index 159ffc6d0..5500a2a0e 100644
--- a/docs/mintlify/reference/camel.types.unified_model_type.mdx
+++ b/docs/mintlify/reference/camel.types.unified_model_type.mdx
@@ -66,8 +66,10 @@ Returns the model name for TikToken.
def token_limit(self):
```
-Returns the token limit for the model. Here we set the default
-value as `999_999_999` if it's not provided from `model_config_dict`
+Returns the context window size for the model.
+
+For unknown model types not defined in ModelType enum, this returns
+a default value of 999_999_999 tokens.
<a id="camel.types.unified_model_type.UnifiedModelType.is_openai"></a>