Skip to content

Commit 35f66cf

Browse files
Refactor content truncation: replace hardcoded value with MAX_LENGTH_TRUNCATE_CONTENT constant
1 parent 54ec743 commit 35f66cf

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

src/smolagents/agents.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
from .bp_tools import get_file_size, force_directories, remove_after_markers
3434
from .bp_utils import bp_parse_code_blobs, fix_nested_tags
3535
from .bp_utils import is_valid_python_code
36+
from. utils import MAX_LENGTH_TRUNCATE_CONTENT
3637

3738
import yaml
3839
from huggingface_hub import create_repo, metadata_update, snapshot_download, upload_folder
@@ -1986,7 +1987,7 @@ def _step_stream(
19861987
observation = ''
19871988
try:
19881989
code_output = self.python_executor(code_action)
1989-
code_output.logs = truncate_content(code_output.logs, 20000) # execution log is truncated to 20K
1990+
code_output.logs = truncate_content(code_output.logs, MAX_LENGTH_TRUNCATE_CONTENT) # execution log is truncated to 20K
19901991
execution_outputs_console = []
19911992
if len(code_output.logs) > 0:
19921993
execution_outputs_console += [

src/smolagents/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
from .monitoring import TokenUsage
2828
from .tools import Tool
29-
from .utils import RateLimiter, _is_package_available, encode_image_base64, make_image_url, parse_json_blob
29+
from .utils import RateLimiter, _is_package_available, encode_image_base64, make_image_url, parse_json_blob, MAX_LENGTH_TRUNCATE_CONTENT
3030

3131

3232
if TYPE_CHECKING:
@@ -433,7 +433,7 @@ def __init__(
433433
self.kwargs = kwargs
434434
self.model_id: str | None = model_id
435435
self.postpend_string = ''
436-
self.max_len_truncate_content = 20000
436+
self.max_len_truncate_content = MAX_LENGTH_TRUNCATE_CONTENT
437437

438438
def _prepare_completion_kwargs(
439439
self,

0 commit comments

Comments
 (0)