gloss

Claude Code's Code Mode Won't Start With OpenTelemetry On

Claude Code 2.1.323, published 12 November, adds Code Mode, an experimental opt-in in which Claude writes JavaScript to call its tools.

A brass padlock secures a red protective cover over a black rotary switch mounted on a gray metal electrical cabinet.
  • Claude Code 2.1.323, published on 12 November, adds Code Mode: an experimental opt-in in which Claude writes JavaScript to call its tools. You switch it on with CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1. The binary also carries 23 messages explaining why it stays off, and the docs page the changelog links to returned a 404 when I checked on 13 November.
  • The refusals show what Code Mode can't do yet. With OpenTelemetry on, it stays off because Code Mode "doesn't yet send it an event for each tool call". It is also off in claude -p, in Claude Desktop's Code tab, on Bedrock and Vertex, behind an API key helper or ANTHROPIC_AUTH_TOKEN, for HIPAA and zero-retention organizations, with agent teams, and with any plugin whose JavaScript hooks check tool calls.
  • I started the real CLI 12 times in a pseudo-terminal and got six different refusals without sending a prompt. My own setup failed on agent teams first, then on a plugin. Haiku 5.5 passed the model check, though the message only names Opus 5.5 and Sonnet 5.5.

The first line of the 2.1.323 changelog reads: "Added Code Mode, an experimental opt-in in which Claude writes JavaScript to call its tools." It points to code.claude.com/docs/en/code-mode for how to turn it on, or how to turn it off for an organization. That page answered with a 404 both times I tried it on the morning of 13 November, the last time at 09:30 Central European Time, and the docs index doesn't list it.

I went to the binary instead. Version 2.1.323 is 344 MB on disk, and much of its JavaScript is readable with a byte search. The opt-in logic sits in one module, and next to it is a list of messages that each finish the sentence "Code Mode (experimental) isn't available: ...".

How the opt-in works

The switch is an environment variable, CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1, set in your shell or in the env block of ~/.claude/settings.json. A value like 0 or false keeps it off, and anything that isn't a yes or no value is rejected. If managed settings or ~/.claude.json also set it, Claude Code wants it turned on in ~/.claude/settings.json instead.

After that, Claude Code asks you to accept two caveats, one general and one about auto mode. It stores them in ~/.claude.json as codeModeCaveatsAcceptedV1 and codeModeAutoModeCaveatAcceptedV1, then restarts itself into the new mode. In Code Mode the model gets a REPL tool that runs scripts, and those scripts make the tool calls.

I never saw that dialog, because every launch was refused before it.

What I ran

A short Python script started claude in a pseudo-terminal with the variable set, read the startup screen for 25 seconds, and killed the process. It sent no keystrokes, no prompt and no answer to any dialog. Each run started from a clean environment (home, path, shell, locale) in a project folder the CLI already trusted. I changed one condition per run with --settings, --model, --disallowedTools or an extra variable.

Condition What Claude Code printed after "isn't available:"
Started with Claude Desktop's environment for now it only works in the interactive terminal
claude -p for now it only works in the interactive terminal
My normal settings it can't be used together with agent teams yet
Agent teams off it doesn't yet work with an installed mod (a plugin with JavaScript hooks) that checks tool calls
+ CLAUDE_CODE_ENABLE_TELEMETRY=1 OpenTelemetry is on (...), and Code Mode doesn't yet send it an event for each tool call
+ DISABLE_TELEMETRY=1 it needs settings that Claude Code downloads from Anthropic, and this session doesn't download them
+ --model claude-haiku-4-5 for now it only works with Opus 5.5, Sonnet 5.5 and later models
+ --model claude-sonnet-4-6 same model message
+ --model claude-haiku-5-5 the plugin message again, so Haiku 5.5 passed

The first row caught me out. My first launch inherited the environment of the Claude Desktop session I was working in, which sets CLAUDE_CODE_ENTRYPOINT=claude-desktop. Even inside a real pseudo-terminal, that was enough to make Claude Code treat it as a non-terminal launch. Desktop's Code tab and -p scripts run with Code Mode off, and by the same check so do Agent SDK hosts.

The OpenTelemetry rule

This refusal will matter most to companies. A team that rolled Claude Code out properly probably set CLAUDE_CODE_ENABLE_TELEMETRY=1 in managed settings and ships the events to a collector. Those events are how a security team sees which tools ran, whether they succeeded, and on whose machine.

In Code Mode, one model turn can be a script that reads twenty files and runs four commands. The refusal text admits that those inner calls don't each produce an event yet. The source checks the variable in the shell and in settings env blocks, and the message names ENABLE_BETA_TRACING_DETAILED as well. If either is on, Code Mode stays off.

Anthropic could have shipped it with a gap in the audit trail and a note in the docs. It refuses to start instead and names the reason on screen. I think that's the right default, and it means organizations with proper telemetry will be the last to get Code Mode.

The plugin rule follows the same logic. If you installed a mod with a JavaScript hooks module that inspects tool calls, Code Mode stays off rather than find out how the two interact. On my machine, a plugin of mine with a hooks module was the last refusal I hit.

The rest of the list

The other refusals, as they appear in the binary:

  • Provider. "For now it only works with the Anthropic API." Bedrock, Vertex and Foundry users are out.
  • Credentials. No API key helper, no ANTHROPIC_AUTH_TOKEN, no custom auth headers. Many LLM gateway setups use one of these.
  • Compliance. "It isn't offered yet to organizations under HIPAA or zero data retention."
  • Unattended. Not in background jobs, teammates' panes or Remote Control sessions.
  • Feature flags. It needs the settings Claude Code downloads from Anthropic, so DISABLE_TELEMETRY, DO_NOT_TRACK or CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC turns it off. Beyond that, "it isn't open to your account yet" covers a staged rollout.
  • Tools. If --restricted, --tools, --disallowedTools or a deny rule removes the tool it runs on, it's off. Disallowing WebFetch or Bash did not trigger this in my runs.
  • Windows. It needs Git for Windows for Bash.
  • Admin. Organization settings can forbid it, and an unreadable policy counts as forbidden.

The model rule in the source is slightly wider than its message. It requires version 5.5 or later for most model families and 5.2 or later for Fable, which is why Haiku 5.5 got through.

What changes once it's on

I couldn't run Code Mode itself, but the binary contains three messages it returns to the model, and they show where Anthropic drew the line for scripts.

With auto mode on, a script is not run if a hook changed its call from what Claude wrote, and that also applies when a hook changed an earlier tool call in the same response. A script containing a \uXXXX escape is not run either, because "auto mode could not check it". The model is told to write the character another way, such as \x1b, and send it again.

The third concerns MCP connectors. Once Code Mode has been on at any point since Claude Code started, it stops sending local files to connectors for the rest of that process. To upload a file again, you quit and restart with Code Mode off.

If you want to try it

You need a plain terminal session (not -p, not Desktop, not the SDK), the Anthropic API directly, and Opus 5.5, Sonnet 5.5, Haiku 5.5 or Fable 5.2. Agent teams and OpenTelemetry must be off, and so must any plugin that hooks tool calls. Set the variable, start claude and read the first warning line. It tells you which condition you failed.

If your organization depends on OpenTelemetry tool events, wait. The refusal says "yet", and per-call events are probably what has to land before Code Mode makes sense for teams that audit their agents. That's the release note to watch for.