We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent df910f2 commit ee1e288Copy full SHA for ee1e288
camel/agents/chat_agent.py
@@ -1175,8 +1175,13 @@ def _truncate_tool_result(
1175
- A boolean indicating whether truncation occurred
1176
"""
1177
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)
+ # Use summarize_threshold if set, otherwise default to 90%
+ 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)
1185
result_tokens = self._get_token_count(serialized)
1186
1187
if result_tokens <= max_tokens:
0 commit comments