Code mode
Code mode is on by default. When the agent has a tool that a program can call, the run adds the built-inrun_program tool, which lets the model write one JavaScript program that calls several tools. Only the program’s result is added to the model’s context.
Programs run in a QuickJS sandbox without network or file system access. Their tool calls go through the same guardrails and approvals as direct calls, and count toward the agent’s maxToolCalls.
To limit which tools a program can call, add a programTool from @restatedev/harness/program. It replaces the built-in run_program. Set codeMode: false to turn code mode off:
run_program to a run, no other tool can have that name: run throws a TypeError when it starts, and Restate retries the invocation.
Tool search
Tool search is on by default. A tool withdeferred: true isn’t listed in the model request until the model finds it with the built-in search_tools tool.
Tools from an MCP server are deferred by default.
To list deferred tools from the start, set toolSearch: false:
search_tools to a run, which it does when a tool is deferred, no other tool can have that name: run throws a TypeError when it starts, and Restate retries the invocation.