Forward remote exec reset flag

Forward reset=true from code_execution_remote replacement commands to the connected CLI and document when to use it versus runtime=reset. This lets the CLI tear down stuck host sessions before running the next command. Tests from /home/eclypso/a0/a0-connector: PYTHONPATH=src conda run -n a0 pytest tests/test_plugin_backend.py::test_code_execution_remote_forwards_reset_true_with_replacement_command -v; ./.venv/bin/python -m pytest tests/test_plugin_backend.py -k 'code_execution_remote or select_remote_exec or ws_connector_exec_result' -v. Mirrored to live container 07e0288dc04f and health check returned HTTP 200.

Alessandro committed May 15, 2026 at 00:28 UTC b48e31bead5437d3b5eea752d63d07db8a331a68
3 files changed +19 -2
plugins/_a0_connector/prompts/agent.system.tool.code_execution_remote.md
+5 -1
@@ -21,6 +21,8 @@ and retry.
21 ## Arguments
22 - `runtime`: one of `terminal`, `python`, `nodejs`, `output`, `reset`
23 - `session`: integer session id (default `0`)
24 +- `reset`: optional boolean for `terminal`, `python`, or `nodejs`; when true,
25 + the CLI resets the session before running the supplied code
26
27 Runtime-specific fields:
28 - `terminal`, `python`, `nodejs`: require `code`
@@ -28,7 +30,9 @@ Runtime-specific fields:
30
31 ## Notes
32 - Reuse `session` when continuing a workflow.
31 -- Use `output` to poll a running session and `reset` for a stuck session.
33 +- Use `output` to poll a running session and `runtime=reset` for a stuck session.
34 + Use `reset: true` on a new command when you need a clean session and want to
35 + run the replacement command immediately.
36 - Paths and shell syntax are evaluated on the CLI host, not inside Agent Zero.
37 - When the user gives a relative path like `tmp/file.txt`, keep it relative to
38 the CLI host terminal. Do not prepend or `cd` to `/a0/usr/workdir`; that is the
plugins/_a0_connector/skills/host-code-execution/SKILL.md
+2 -1
@@ -24,7 +24,8 @@ Browser boundary: do not use shell launchers such as `xdg-open`, `sensible-brows
24 - Use `runtime=terminal` for shell commands, `runtime=python` for Python snippets, and `runtime=nodejs` for Node.js snippets.
25 - Reuse the same integer `session` while continuing a workflow; session state is local to the CLI frontend.
26 - Use `runtime=output` when a previous command is still running or returned before the shell reached a prompt.
27 -- Use `runtime=reset` when a session is stuck or a clean shell is safer.
27 +- Use `runtime=reset` when a session is stuck and no replacement command needs to run yet.
28 +- Use `reset: true` with `runtime=terminal`, `python`, or `nodejs` when a session is stuck and the next command should run immediately in a clean shell.
29 - Match the remote host shell syntax. A Windows CLI may need PowerShell syntax even when Agent Zero runs on Linux.
30
31 ## Failure Handling
plugins/_a0_connector/tools/code_execution_remote.py
+12
@@ -30,6 +30,16 @@ class CodeExecutionRemote(Tool):
30 def _runtime_requires_write_access(runtime: str) -> bool:
31 return runtime in {"terminal", "python", "nodejs", "input"}
32
33 + @staticmethod
34 + def _coerce_bool(value: Any) -> bool:
35 + if isinstance(value, bool):
36 + return value
37 + if isinstance(value, (int, float)):
38 + return bool(value)
39 + if isinstance(value, str):
40 + return value.strip().lower() in {"1", "true", "yes", "on"}
41 + return False
42 +
43 def get_log_object(self):
44 import uuid
45
@@ -118,6 +128,8 @@ class CodeExecutionRemote(Tool):
128 "session": session,
129 "context_id": context_id,
130 }
131 + if runtime != "reset" and self._coerce_bool(self.args.get("reset")):
132 + payload["reset"] = True
133
134 if runtime in {"terminal", "python", "nodejs"}:
135 code = self.args.get("code")