[KongchangAI]
Concept代码模式

Code Mode

An agent tool-calling optimization pattern in which the model writes a small program that invokes multiple tools consecutively inside a sandbox, returning only the final result to the model context, thereby reducing round-trip token costs and preventing intermediate data from polluting the context.

Core Facts

Timeline (last 90 days)

Dec 1

v2.1.334 fixes the issue in Code Mode where script tool calls counted toward context size, causing premature compaction.

Unverified50%
Nov 27

When evaluating Code Mode-type capabilities, the focus should be on: whether the execution environment is isolated, whether tool permission granularity is configurable, whether the generated code is auditable, and whether there are rollback and timeout protections on failure.

Unverified50%
Nov 27

Completing 11 calls in 6 seconds is a specific case, and one cannot directly infer the time performance of all tasks from it.

Unverified50%
Nov 27

Executing JavaScript locally means the composition logic of tool calls is generated by the model, and reviewing the generated code remains necessary in actual use.

Unverified50%
Nov 27

The article's material does not explain Code Mode's scope of applicability or the details of its permission controls, nor does it provide comparison data with other modes.

Unverified50%
Nov 27

When using Code Mode, the debugging approach changes: the problem may lie in the generated JavaScript logic, and troubleshooting requires examining both the code and the execution results.

Unverified50%
Nov 27

The second source of token savings in Code Mode is the reduction of repeated reasoning overhead: one-time orchestration eliminates the repeated descriptions the model needs to confirm progress across multiple rounds of calls.

Unverified50%
Nov 27

The first source of token savings in Code Mode is that intermediate results are digested within the code execution environment and no longer all enter the context; the model only sees the filtered results.

Unverified50%
Nov 27

In a real run log of Code Mode, 11 tool calls were completed within a single 6-second step.

Unverified50%
Nov 25

Code Mode fixed an issue where tool calls were silently skipped when the tool input contained a list of more than 4,096 items; inputs with oversized typed arrays are now rejected instead of freezing.

Unverified50%

40 more timeline events

All Facts (20)

Verified

Claude Code v2.1.323 released the experimental feature Code Mode, which must be enabled manually; once enabled, Claude writes JavaScript code to call tools rather than calling them directly.

75%
Unverified

Code Mode is more valuable for complex refactoring, multi-file modifications, and automation tasks that require conditional logic, scenarios that are naturally suited to being expressed as scripts.

60%
Unverified

v2.1.334 fixes the issue in Code Mode where script tool calls counted toward context size, causing premature compaction.

50%
Unverified

The second source of token savings in Code Mode is the reduction of repeated reasoning overhead: one-time orchestration eliminates the repeated descriptions the model needs to confirm progress across multiple rounds of calls.

50%
Unverified

In a real run log of Code Mode, 11 tool calls were completed within a single 6-second step.

50%
Unverified

The article's material does not explain Code Mode's scope of applicability or the details of its permission controls, nor does it provide comparison data with other modes.

50%
Unverified

When evaluating Code Mode-type capabilities, the focus should be on: whether the execution environment is isolated, whether tool permission granularity is configurable, whether the generated code is auditable, and whether there are rollback and timeout protections on failure.

50%
Unverified

When using Code Mode, the debugging approach changes: the problem may lie in the generated JavaScript logic, and troubleshooting requires examining both the code and the execution results.

50%
Unverified

The first source of token savings in Code Mode is that intermediate results are digested within the code execution environment and no longer all enter the context; the model only sees the filtered results.

50%
Unverified

Completing 11 calls in 6 seconds is a specific case, and one cannot directly infer the time performance of all tasks from it.

50%
Unverified

Executing JavaScript locally means the composition logic of tool calls is generated by the model, and reviewing the generated code remains necessary in actual use.

50%
Unverified

Code Mode fixed an issue where tool calls were silently skipped when the tool input contained a list of more than 4,096 items; inputs with oversized typed arrays are now rejected instead of freezing.

50%
Unverified

Code Mode sessions previously lost thinking content and prompt cache when resumed with --resume or --continue in a different permission mode, which has now been fixed

50%
Unverified

v2.1.330 improves Code Mode: Claude now knows how to view images and PDFs; commands stopped by pressing Esc show 'Interrupted' below them instead of a red error; and terminal freeze time after subagent scripts make thousands of tool calls is greatly reduced.

50%
Unverified

The new version of Code Mode rejects script reads of line ranges exceeding 256 MiB, because such reads may consume several GB of memory.

50%
Unverified

In practice, a safer approach is to try Code Mode in an isolated branch or container, whitelist the set of tools the script can reach, and keep a version-controlled state that can be rolled back.

50%
Unverified

Code Mode's scripting approach is in the same lineage as "programmatic tool calling."

50%
Unverified

The essence of Code Mode is to move the tool-call loop down from the model layer to the code layer: the model reasons only once to generate a script, and the script triggers multiple tools sequentially or concurrently within the runtime, thereby compressing N rounds of model round trips into 1.

50%
Unverified

v2.1.326 allows Code Mode to be enabled when teams are enabled; multi-agent team sessions that previously enabled Code Mode now start in Code Mode by default.

50%
Unverified

Background sub-agents launched in Code Mode no longer fail when preloading skills that contain inline `!` commands.

50%

Source Articles