A client lets the model write a short script that calls several MCP tools inside a sandbox, and only the script's final output returns to the model. What is this pattern called, and what does it improve?
Select an answer to reveal the explanation.
Short Explanation
Instead of the model making ten phone calls itself, you let it write one errand list for a sandbox to run. Only the final answer comes back. That's code mode, and it saves you tokens and round trips.
Full Explanation
The client best practices describe programmatic tool calling, sometimes called code mode. The host converts MCP tool schemas into a typed API inside a sandbox, the model writes code against that API, and the sandbox executes it; function calls are intercepted and dispatched by the host as tools/call requests, and only the script's output, such as a summary line, returns to the model. This avoids a model round trip for every call and keeps large intermediate results, like thousands of log entries, out of the context window. Progressive tool discovery is a different pattern that controls when tool definitions enter context; it complements code mode but does not execute model-written scripts. Sampling with tools is a deprecated feature in which a server asks the client's model for completions; it does not run scripts on the server. Multi round-trip requests let a server request client input inside a result before the client retries; they are not a batching mechanism, and each tool call remains its own request. Exam caveat: code mode requires a properly isolated sandbox with no direct network access, with credentials held by the host and the same human-in-the-loop policy applied to calls the script makes. Operational check: run a multi-step task and confirm the sandbox issues the tools/call requests while the model receives only the final output.