Skip to content

[BUG] claude_code.tool_decision OTLP event not emitted in headless (-p) mode #26059

@mrmaxsteel

Description

@mrmaxsteel

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

When running Claude Code in headless mode (claude -p), the claude_code.tool_decision OTLP log event is never emitted. Only claude_code.tool_result is emitted. In interactive mode, both events are emitted as documented.

What Should Happen?

Per the monitoring docs, claude_code.tool_decision should be emitted when a tool permission decision is made, regardless of execution mode.

Error Messages/Logs

Steps to Reproduce

Reproduction steps

  1. Start an OTLP collector on port 4318 (any receiver that accepts /v1/logs)
  2. Run interactive session:
    CLAUDE_CODE_ENABLE_TELEMETRY=1 OTEL_METRICS_EXPORTER=otlp OTEL_LOGS_EXPORTER=otlp \
      OTEL_EXPORTER_OTLP_PROTOCOL=http/json OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 \
      claude
    Trigger a tool call (e.g. "Search the web for 'hello'"). Observe OTLP events received.
  3. Run headless session with identical env vars:
    CLAUDE_CODE_ENABLE_TELEMETRY=1 OTEL_METRICS_EXPORTER=otlp OTEL_LOGS_EXPORTER=otlp \
      OTEL_EXPORTER_OTLP_PROTOCOL=http/json OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 \
      claude -p "Search the web for 'hello'"
    Observe OTLP events received.

Observed results

Interactive mode emits both events:

{
    "claude_code.tool_decision": 1,
    "claude_code.tool_result": 2,
    "claude_code.api_request": 7
}

Headless (-p) mode only emits tool_result:

{
    "claude_code.tool_result": 1,
    "claude_code.api_request": 3
}

claude_code.tool_decision is completely absent from headless output.

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

v2.1.42

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

Environment

  • Claude Code v2.1.42
  • macOS Darwin 25.2.0
  • OTLP protocol: http/json

Impact

Low — tool_result is a superset of tool_decision data (includes decision + source fields plus duration_ms, success, tool_parameters). Monitoring pipelines that only consume tool_result are unaffected. Pipelines that depend on tool_decision for pre-execution permission auditing will miss events from headless sessions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingplatform:macosIssue specifically occurs on macOS

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions