Optimize your agent

Query instead of paging

Let the agent run code over results

When a task chains many tool calls, the agent can write a short program that calls the tools and returns only the final result, so intermediate results stay out of context. Anthropic and OpenAI call it programmatic tool calling; Pi runs it by default, OpenCode runs its MCP tools through it by default, and Claude Code and Codex have an experimental code mode.

Anthropic reported 37% fewer tokens, and no gain on flows of one or two calls. Vendor-reported

Checked on the vendor's pages 30 Nov 2026

Where it fits

Building my own agent Fits

Programmatic tool calling on the Claude and OpenAI APIs; Pi codemode.

Using a coding agent Partly

Experimental in Claude Code and Codex, on by default in OpenCode.

Using an enterprise assistant Not available

Not offered in enterprise assistants.

Using a workflow tool Not available

Use a code step instead.

The setting in each harness

Read on each vendor's own page, linked next to the setting.

HarnessSetting
Claude API and Agent SDK

code_execution_20260120 with allowed_callers on your tools

platform.claude.com, read 30 Nov 2026
OpenAI Responses and Agents SDK

The programmatic_tool_calling tool, with allowed_callers: ["programmatic"] on your tools

developers.openai.com, read 30 Nov 2026
Pi
On by default

MCP tools default to codemode exposure: the model calls them from one script instead of one call per tool

github.com, read 30 Nov 2026
Claude Code
Experimental

CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 (v2.1.323 or later, interactive terminal)

code.claude.com, read 30 Nov 2026
Codex
Experimental

[features.code_mode] enabled = true in config.toml

learn.chatgpt.com, read 30 Nov 2026
OpenCode
On by default

MCP servers run through Code Mode by default in OpenCode 2; "codemode": false on a server exposes its tools directly

opencode.ai, read 30 Nov 2026

Not offered