mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-12-04 12:08:11 +00:00
Centralize boolean argument coercion in helpers.tool and route the promoted and core tools through it. This removes the duplicated private coercion helpers, including one in the remote code execution tool, along with the repairable-error messages and prompt files that only the strict boolean validation used. Strict boolean argument validation gives way to the shared coercion, which maps common true/false strings and falls back to truthiness, so invalid reset and dedicated_context values stop returning repairable errors. Browser regression tests now import the real modules before installing their stubs. Validation: pytest tests/test_tool_action_contracts.py tests/test_browser_agent_regressions.py
Code Execution
Run terminal commands and execute Python or Node.js code through Agent Zero using persistent shell sessions.
What It Does
This plugin provides the code execution tool used by agents for development tasks. It supports:
- Terminal commands in interactive shell sessions
- Python execution through
ipython -c - Node.js execution through
node /exe/node_eval.js - Persistent sessions keyed by session number
- Session reset and output retrieval
- Local or SSH-backed execution depending on plugin configuration
Main Behavior
- Persistent shells
- Maintains per-session shell state in agent data so subsequent calls can reuse the same terminal session.
- Groups multi-line terminal input in the current shell so only the final prompt marks the command complete.
- Multiple runtimes
- Dispatches requests based on
runtime:terminal,python,nodejs,output, orreset.
- Dispatches requests based on
- Remote execution support
- Can open SSH interactive sessions instead of local shells when configured.
- Streaming output
- Continuously reads shell output, updates the current log item, and detects progress while commands are running.
- Detects local shell exit and SSH channel termination when strict mode,
exit, or a lost connection prevents a final prompt from appearing.
- Long-running work
- Keeps normal command execution responsive while giving the
outputruntime longer polling windows for builds, installs, servers, tests, and training jobs.
- Keeps normal command execution responsive while giving the
- Safety around running sessions
- Tracks whether a shell is currently busy and can prevent overlapping commands unless explicitly allowed.
Key Files
- Tool
tools/code_execution_tool.pycontains runtime dispatch, session lifecycle, and streaming output logic.
- Helpers
helpers/shell_local.pyprovides the local interactive shell implementation.helpers/shell_ssh.pyprovides the SSH-backed interactive shell implementation.
- Configuration
default_config.yamldefines execution, prompt, and timeout settings.
- Prompts
prompts/contains the response templates shown to the agent.
Configuration Scope
- Settings section:
agent - Per-project config:
true - Per-agent config:
true - Always enabled:
false
Plugin Metadata
- Name:
_code_execution - Title:
Code Execution - Description: Code execution tool supporting terminal, Python, and Node.js runtimes via local TTY or SSH.