Skip to content

Commit ee1e288

Browse files
committed
minor update
1 parent df910f2 commit ee1e288

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

camel/agents/chat_agent.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,8 +1175,13 @@ def _truncate_tool_result(
11751175
- A boolean indicating whether truncation occurred
11761176
"""
11771177
serialized = self._serialize_tool_result(result)
1178-
# Leave 10% room for system message, user input, and model response
1179-
max_tokens = int(self.token_limit * 0.9)
1178+
# Use summarize_threshold if set, otherwise default to 90%
1179+
threshold_ratio = (
1180+
min(0.9, self.summarize_threshold / 100)
1181+
if self.summarize_threshold is not None
1182+
else 0.9
1183+
)
1184+
max_tokens = int(self.token_limit * threshold_ratio)
11801185
result_tokens = self._get_token_count(serialized)
11811186

11821187
if result_tokens <= max_tokens:

0 commit comments

Comments
 (0)