mirror of
https://github.com/hanzoai/python-sdk.git
synced 2026-10-23 20:23:00 +00:00
The default surface was 34 tools, 61 KB, ~15,300 tokens of schema in every
prompt of every agent. The mode system already names what a session should
carry, but only the tools register_all_tools enumerates obeyed it: zsh,
curl, playwright and the helpers (ps, npx, uvx, jq, wget, cdp, open) stayed
on in every mode. A mode now decides every discovered tool, the `hanzo`
mode lists what a coding agent calls every few steps (18 tools, 32 KB,
~8,000 tokens), and the rest is a name away: HANZO_MCP_ENABLED_TOOLS=a,b
or =all, `tool enable`, or `mode`.
hanzo-tools-shell 0.6.6: run_shell kept every byte a foreground command
wrote until the command ended. `yes` for thirty seconds is gigabytes. It
keeps the first 16 MiB per stream and drains the rest.
The tests' session-wide patch of asyncio.create_subprocess_exec handed
every shell command a stream that never reached EOF; the first test to run
one read it in a loop until the machine was out of memory (22 GB, killed).
The patch is now opt-in and its process has exited.
bench/latency.py measures the cold start, the tools/list bill and the common
calls through a real MCP client over stdio. Interleaved rounds, wall and CPU
seconds, p50 over 6 cold starts:
cold wall cold CPU tools bytes ~tokens
installed 0.15.18 9.34 s 10.46 s 30 52,601 13,150
main 0.15.20 1.52 s 1.13 s 34 61,287 15,321
this 0.96 s 1.06 s 18 32,222 8,055
The installed environment's 9 s is its hanzoai 8.5.156, whose package init
imports the whole generated cloud client; hanzo-mcp >= 0.15.20 requires
hanzoai >= 8.5.624, which loads it lazily. Per-call latency is spawn-bound
(zsh 17.6 ms, git status 33 ms, fs.read 2.5 ms at p50) and moves with the
machine's load; no call path changed.
hanzo-tools-shell
Shell execution tools for Hanzo MCP with DAG support and Shellflow DSL.
Installation
pip install hanzo-tools-shell
Tools
dag - DAG Execution Engine
Execute commands with directed acyclic graph semantics.
# Serial execution (default)
dag(["ls", "pwd", "git status"])
# Parallel execution
dag(["npm install", "cargo build"], parallel=True)
# Mixed DAG with parallel blocks
dag([
"mkdir -p dist",
{"parallel": ["cp a.txt dist/", "cp b.txt dist/"]},
"zip -r out.zip dist/"
])
# Tool invocations
dag([{"tool": "search", "input": {"pattern": "TODO"}}])
# Named nodes with dependencies
dag([
{"id": "build", "run": "make build"},
{"id": "test", "run": "make test", "after": ["build"]},
])
zsh - Primary Shell with Shellflow DSL
Execute shell commands with optional Shellflow syntax.
# Simple command
zsh("ls -la")
# Shellflow DSL syntax
zsh("mkdir dist ; { cp a dist/ & cp b dist/ } ; zip out")
# With shell parameter
zsh("echo $BASH_VERSION", shell="bash")
Shellflow Syntax:
A ; B- Sequential execution{ A & B }- Parallel executionA ; { B & C } ; D- Mixed DAG
ps - Process Management
Monitor and control background processes.
ps() # List all processes
ps(id="abc123") # Get specific process
ps(kill="abc123") # Kill process (SIGTERM)
ps(logs="abc123", n=50) # Last 50 lines of output
Additional Tools
- shell - Smart shell (zsh > bash fallback)
- bash - Explicit bash execution
- npx - Node package execution with auto-backgrounding
- uvx - Python package execution with auto-backgrounding
- open - Open files/URLs in system apps
- curl - HTTP client without shell escaping issues
- jq - JSON processor
- wget - File/site downloads
Auto-Backgrounding
Commands that exceed the timeout (default 60s) are automatically backgrounded:
dag(["long-running-command"], timeout=30)
# If command exceeds 30s, it continues in background
# Use ps --logs <id> to view output
Performance
Shellflow DSL is optimized for high throughput:
- Simple commands: ~7M ops/sec
- Sequential: ~2.2M ops/sec
- Mixed DAG: ~100k ops/sec
License
MIT