Skip to main content
The render function runs on every turn, before every model step. It returns the instruction string for that step; hooks called during the render declare the step’s capabilities.

Hooks

All hooks throw HOOK_OUTSIDE_RENDER when called outside a render.

Per-render capability rebuild

Capabilities (tools, MCP servers, subagents) rebuild from empty on each render, so conditional hooks work naturally:

Render guards

Render is strictly synchronous and free of I/O. During render:
  • fetch, setTimeout, setInterval, queueMicrotask, and process.env reads throw AGENT_RENDER_IO.
  • Returning a thenable throws AGENT_RENDER_ASYNC.
  • Non-string returns throw AGENT_RENDER_TYPE; a render that selects no model throws AGENT_NO_MODEL.
Side effects belong in tools, and tools that do CPU work run through sandbox.exec in the VM.

Determinism

zap agent render --agent <id> --input "..." --json executes a render with no model call and no spend. Identical input produces identical bytes — the exact instructions, model id, tool list, and referenced secret names (never values). Use it in CI to snapshot agent behavior.