Direct Tools

session.tool(name, args) (and the typed helpers like glob, grep, readFile) run a host tool directly, with no model call in the loop. Use them for tests, migrations, and host-driven workflows where you want deterministic results instead of an agent turn.

Direct calls are host control-plane calls. Apply your own product authorization before invoking them; permissionPolicy gates model-selected tool calls inside an agent turn, not whether your application code is allowed to call an SDK helper.

Node.js
Python

Direct tools execute under the session workspace and should be treated as privileged host operations. Most calls (read, glob, grep) are purely deterministic; generate_object is the exception — it still calls the model to fill a schema-validated JSON object, but you drive it explicitly rather than through a free-form agent turn.

A runnable version ships at crates/code/sdk/node/examples/basic/test_generate_object.ts (Python: crates/code/sdk/python/examples/test_generate_object.py).