mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-12-05 01:48:44 +00:00
fix(code-execution): reject non-string code before shell dispatch
This commit is contained in:
1 parent
ba9b67df0f
commit
5fb00bd909
4 files changed
+70
-1
No files matched your search
@@ -6,6 +6,7 @@ import shlex
|
||||
import time
|
||||
|
||||
from helpers.tool import Tool, Response, coerce_bool
|
||||
from helpers.errors import RepairableException
|
||||
from helpers import files, rfc_exchange, projects, runtime, secrets, settings
|
||||
from helpers.print_style import PrintStyle
|
||||
from helpers.strings import truncate_text as truncate_text_string
|
||||
@@ -68,6 +69,11 @@ class CodeExecution(Tool):
|
||||
await self.agent.handle_intervention() # wait for intervention and handle it, if paused
|
||||
|
||||
runtime_arg = self.args.get("runtime", "").lower().strip()
|
||||
if runtime_arg in {"terminal", "python", "nodejs"} and not isinstance(self.args.get("code"), str):
|
||||
received = type(self.args["code"]).__name__ if "code" in self.args else "missing"
|
||||
raise RepairableException(
|
||||
f"code_execution_tool requires code to be a string for runtime {runtime_arg}; received {received}"
|
||||
)
|
||||
session = int(self.args.get("session", 0))
|
||||
self.allow_running = coerce_bool(self.args.get("allow_running", False), False)
|
||||
reset = coerce_bool(self.args.get("reset", False), False) or runtime_arg == "reset"
|
||||
|
||||
Reference in new issue
Block a user