@@ -355,9 +355,7 @@ def get_attached_files(self) -> list[str]:
355
355
List of file paths that will be available in the sandbox filesystem
356
356
"""
357
357
return [
358
- op .path
359
- for op in self ._filesystem_operations
360
- if op .operation == "write"
358
+ op .path for op in self ._filesystem_operations if op .operation == "write"
361
359
]
362
360
363
361
def clear_filesystem_operations (self ) -> None :
@@ -421,9 +419,7 @@ def _build_command(
421
419
if self ._filesystem_operations or self .enable_filesystem :
422
420
if self ._filesystem_operations :
423
421
fs_ops = [op .to_dict () for op in self ._filesystem_operations ]
424
- fs_json = json .dumps (
425
- fs_ops , ensure_ascii = True , separators = ("," , ":" )
426
- )
422
+ fs_json = json .dumps (fs_ops , ensure_ascii = True , separators = ("," , ":" ))
427
423
cmd .extend (["-x" , fs_json ])
428
424
logger .debug ("Filesystem enabled with %d operations" , len (fs_ops ))
429
425
else :
@@ -983,20 +979,14 @@ def as_structured_tool(self) -> StructuredTool:
983
979
self ._structured_tool = StructuredTool .from_function (
984
980
name = self .name ,
985
981
description = self ._build_description (),
986
- func = (
987
- self ._run_sync
988
- if not self .stateful
989
- else self ._run_stateful_sync
990
- ),
982
+ func = (self ._run_sync if not self .stateful else self ._run_stateful_sync ),
991
983
args_schema = self .args_schema ,
992
984
)
993
985
return self ._structured_tool
994
986
995
987
def _run_sync (self , code : str ) -> str :
996
988
"""Synchronous execution function for non-stateful mode."""
997
- result = self ._sync_sandbox .execute (
998
- code , timeout_seconds = self .timeout_seconds
999
- )
989
+ result = self ._sync_sandbox .execute (code , timeout_seconds = self .timeout_seconds )
1000
990
1001
991
if result .status == "error" :
1002
992
error_msg = (
@@ -1025,8 +1015,7 @@ def _run_stateful_sync(
1025
1015
actual_keys = set (state ) if isinstance (state , dict ) else set (state .__dict__ )
1026
1016
if missing_keys := required_keys - actual_keys :
1027
1017
error_msg = (
1028
- "Input state is missing "
1029
- f"the following required keys: { missing_keys } "
1018
+ f"Input state is missing the following required keys: { missing_keys } "
1030
1019
)
1031
1020
raise ValueError (error_msg )
1032
1021
0 commit comments