changing a field name from `code` to `input`. Reduces the problem of the model constantly trying to write code rather than calling tools
Browse files
Modules/Agent_Terminal.py
CHANGED
|
@@ -124,7 +124,7 @@ TOOL_SUMMARY = (
|
|
| 124 |
@autodoc(
|
| 125 |
summary=TOOL_SUMMARY,
|
| 126 |
)
|
| 127 |
-
def Agent_Terminal(
|
| 128 |
"Python source code to run; stdout is captured and returned. "
|
| 129 |
"Execute these commands: "
|
| 130 |
"`search_tools('query')` to search for tools by name or capability; "
|
|
@@ -132,8 +132,8 @@ def Agent_Terminal(code: Annotated[str, (
|
|
| 132 |
"`usage('ToolName')` to inspect a tool’s expected input parameters; "
|
| 133 |
"`search_packages('query')` to search for installed Python libraries."
|
| 134 |
)]) -> str:
|
| 135 |
-
_log_call_start("Agent_Terminal",
|
| 136 |
-
if
|
| 137 |
result = "No code provided."
|
| 138 |
_log_call_end("Agent_Terminal", result)
|
| 139 |
return result
|
|
@@ -168,7 +168,7 @@ def Agent_Terminal(code: Annotated[str, (
|
|
| 168 |
os.chdir(ROOT_DIR)
|
| 169 |
|
| 170 |
# Parse code to check if the last statement is an expression
|
| 171 |
-
tree = ast.parse(
|
| 172 |
if tree.body and isinstance(tree.body[-1], ast.Expr):
|
| 173 |
last_node = tree.body.pop()
|
| 174 |
|
|
@@ -182,7 +182,7 @@ def Agent_Terminal(code: Annotated[str, (
|
|
| 182 |
if result_val is not None:
|
| 183 |
print(result_val)
|
| 184 |
else:
|
| 185 |
-
exec(
|
| 186 |
|
| 187 |
result = redirected_output.getvalue()
|
| 188 |
except Exception as exc: # pylint: disable=broad-except
|
|
|
|
| 124 |
@autodoc(
|
| 125 |
summary=TOOL_SUMMARY,
|
| 126 |
)
|
| 127 |
+
def Agent_Terminal(input: Annotated[str, (
|
| 128 |
"Python source code to run; stdout is captured and returned. "
|
| 129 |
"Execute these commands: "
|
| 130 |
"`search_tools('query')` to search for tools by name or capability; "
|
|
|
|
| 132 |
"`usage('ToolName')` to inspect a tool’s expected input parameters; "
|
| 133 |
"`search_packages('query')` to search for installed Python libraries."
|
| 134 |
)]) -> str:
|
| 135 |
+
_log_call_start("Agent_Terminal", input=_truncate_for_log(input or "", 300))
|
| 136 |
+
if input is None:
|
| 137 |
result = "No code provided."
|
| 138 |
_log_call_end("Agent_Terminal", result)
|
| 139 |
return result
|
|
|
|
| 168 |
os.chdir(ROOT_DIR)
|
| 169 |
|
| 170 |
# Parse code to check if the last statement is an expression
|
| 171 |
+
tree = ast.parse(input)
|
| 172 |
if tree.body and isinstance(tree.body[-1], ast.Expr):
|
| 173 |
last_node = tree.body.pop()
|
| 174 |
|
|
|
|
| 182 |
if result_val is not None:
|
| 183 |
print(result_val)
|
| 184 |
else:
|
| 185 |
+
exec(input, tools_env)
|
| 186 |
|
| 187 |
result = redirected_output.getvalue()
|
| 188 |
except Exception as exc: # pylint: disable=broad-except
|