What it does
When enabled, the Navigator exposesexecute_tools_in_code alongside its standard discovery and execution tools. The agent can use it to coordinate tool calls, process large or paginated responses, and perform calculations before returning an answer. Intermediate tool outputs stay inside the sandbox, so only the program’s printed result enters the model’s context.
How to enable
1
Open the Navigator Instance
In the Caylex dashboard, open a project, select its navigator, and go to Caylex Capabilities.
2
Enable Code Mode
Turn on Code Mode for the Navigator Instance.
How it works
When the agent decides to use Code Mode, the following steps occur:-
Program generation — the agent generates a fresh Python program and passes it to
execute_tools_in_code. -
Sandbox execution — the Navigator runs the program in a restricted sandbox with access to the async
invoke_toolsfunction.- Whenever
invoke_toolsis called, the Navigator executes the requested connected tools and returns their responses to the program.
- Whenever
- Result delivery — the Navigator returns only the program’s printed output to the model.
The execute_tools_in_code interface
Your agent calls execute_tools_in_code with a generated Python program:
- code — the Python source to run in the restricted sandbox
output string with everything the program printed to standard output. Inside the program, the agent can use invoke_tools to call connected tools.
The invoke_tools function
Code Mode exposes an async invoke_tools function inside the sandbox. The generated program calls it with a list of tool calls:
- server_name — the connected server to use
- tool_name — the tool to invoke
- intent — a short description of why the tool is being called
- tool_params — the parameters defined by the tool’s input schema
list[str] containing each tool’s raw response. JSON responses remain encoded as strings and can be parsed with json.loads.
Processing large results
Code Mode can transform tool responses before they enter the model’s context. Suppose a user asks for the total value of every invoice from a paginated billing endpoint. The generated program could retrieve each page and return only the final sum:Important notes
- Tool output discovery — Before writing code, the agent should check each tool’s output schema. If the shape is still unclear, it should make a representative tool call and inspect the response first.
- Failure handling — Code Mode stops the program when a tool call fails. The error identifies the failed line, the tool calls in submission order, and the error message for each failed tool, so the agent can avoid repeating successful state-changing tool calls.
- Restricted Python environment — Code runs in Monty, a restricted Python interpreter that supports common Python syntax and a limited standard library. It cannot directly access the network, filesystem, environment variables, subprocesses, or third-party packages.