mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-05-18 23:45:49 +00:00
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.
This commit is contained in:
parent
1e271be83e
commit
b48e31bead
3 changed files with 19 additions and 2 deletions
|
|
@ -21,6 +21,8 @@ and retry.
|
|||
## Arguments
|
||||
- `runtime`: one of `terminal`, `python`, `nodejs`, `output`, `reset`
|
||||
- `session`: integer session id (default `0`)
|
||||
- `reset`: optional boolean for `terminal`, `python`, or `nodejs`; when true,
|
||||
the CLI resets the session before running the supplied code
|
||||
|
||||
Runtime-specific fields:
|
||||
- `terminal`, `python`, `nodejs`: require `code`
|
||||
|
|
@ -28,7 +30,9 @@ Runtime-specific fields:
|
|||
|
||||
## Notes
|
||||
- Reuse `session` when continuing a workflow.
|
||||
- Use `output` to poll a running session and `reset` for a stuck session.
|
||||
- Use `output` to poll a running session and `runtime=reset` for a stuck session.
|
||||
Use `reset: true` on a new command when you need a clean session and want to
|
||||
run the replacement command immediately.
|
||||
- Paths and shell syntax are evaluated on the CLI host, not inside Agent Zero.
|
||||
- When the user gives a relative path like `tmp/file.txt`, keep it relative to
|
||||
the CLI host terminal. Do not prepend or `cd` to `/a0/usr/workdir`; that is the
|
||||
|
|
|
|||
|
|
@ -24,7 +24,8 @@ Browser boundary: do not use shell launchers such as `xdg-open`, `sensible-brows
|
|||
- Use `runtime=terminal` for shell commands, `runtime=python` for Python snippets, and `runtime=nodejs` for Node.js snippets.
|
||||
- Reuse the same integer `session` while continuing a workflow; session state is local to the CLI frontend.
|
||||
- Use `runtime=output` when a previous command is still running or returned before the shell reached a prompt.
|
||||
- Use `runtime=reset` when a session is stuck or a clean shell is safer.
|
||||
- Use `runtime=reset` when a session is stuck and no replacement command needs to run yet.
|
||||
- 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.
|
||||
- Match the remote host shell syntax. A Windows CLI may need PowerShell syntax even when Agent Zero runs on Linux.
|
||||
|
||||
## Failure Handling
|
||||
|
|
|
|||
|
|
@ -30,6 +30,16 @@ class CodeExecutionRemote(Tool):
|
|||
def _runtime_requires_write_access(runtime: str) -> bool:
|
||||
return runtime in {"terminal", "python", "nodejs", "input"}
|
||||
|
||||
@staticmethod
|
||||
def _coerce_bool(value: Any) -> bool:
|
||||
if isinstance(value, bool):
|
||||
return value
|
||||
if isinstance(value, (int, float)):
|
||||
return bool(value)
|
||||
if isinstance(value, str):
|
||||
return value.strip().lower() in {"1", "true", "yes", "on"}
|
||||
return False
|
||||
|
||||
def get_log_object(self):
|
||||
import uuid
|
||||
|
||||
|
|
@ -118,6 +128,8 @@ class CodeExecutionRemote(Tool):
|
|||
"session": session,
|
||||
"context_id": context_id,
|
||||
}
|
||||
if runtime != "reset" and self._coerce_bool(self.args.get("reset")):
|
||||
payload["reset"] = True
|
||||
|
||||
if runtime in {"terminal", "python", "nodejs"}:
|
||||
code = self.args.get("code")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue