[BUG] event log tool_decision.tool_parameters.bash_command - bash_command captures leading variable assignment instead of the actual command

Resolved 💬 1 comment Opened Jun 2, 2026 by konradodwrot Closed Jul 6, 2026

Preflight Checklist

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

What's Wrong?

In the tool_decision log event (with OTEL_LOG_TOOL_DETAILS=1), the tool_parameters.bash_command attribute is meant to capture the command being run. When the command is prepended by one or more shell variable assignments, bash_command is parsed incorrectly: it captures the start of the first variable assignment and breaks on the first whitespace, rather than the actual command being invoked.

The full command is preserved correctly in full_command, so the parsing that derives bash_command is the issue.

bash_command contains the truncated leading token (a partial variable assignment, broken on the first space).

What Should Happen?

bash_command should reflect the actual command invoked. For the examples below, meaningful values would be ffmpeg, python3, and rg respectively (skipping leading VAR=... assignments).

{"bash_command":"src=\"/Users/ko/ScreenCapture/Screen","full_command":"src=\"/Users/ko/ScreenCapture/Screen Recording 2026-06-02 at 17.34.23.mov\"\nout=\"/Users/ko/projects/configs/docs/recordings/screen_recording_2026-06-02_2.gif\"\npal=\"/tmp/palette2.png\"\nfps=15; scale=1280\nffmpeg -y -v error -i \"$src\" -vf \"fps=$fps,scale=$scale:-1:flags=lanczos,palettegen=stats_mode=diff\" \"$pal\"\nffmpeg -y -v error -i \"$src\" -i \"$pal\" -lavfi \"fps=$fps,scale=$scale:-1:flags=lanczos[x];[x][1:v]paletteuse=dither=sierra2_4a:diff_mode=rectangle\" \"$out\"\nls -la \"$out\"","description":"Convert second-last recording to high-quality GIF"}
{"bash_command":"f=\"/Users/ko/projects/configs/root/etc/grafana/provisioning/dashboards/json/claude-code.json\";","full_command":"f=\"/Users/ko/projects/configs/root/etc/grafana/provisioning/dashboards/json/claude-code.json\"; python3 -m json.tool \"$f\" >/dev/null && echo \"JSON valid\"; echo \"--- bash panel transform key lines ---\"; rg -n '\"event_sequence\"|\"session_id\"|\"trace_id 1\"|\"trace_id 2\"|\"full_command\": \"Command\"|\"event_sequence\": \"Logs\"' \"$f\" | rg -v '^([1-9][0-9]?[0-9]?) ' | tail -20","description":"Validate JSON and show transform field mappings"}
{"bash_command":"grafana_dir=$(brew","full_command":"grafana_dir=$(brew --prefix grafana); rg -o '\"(palette-classic[a-z-]*|continuous-[A-Za-z]+|fixed|shades|thresholds)\"' \"$grafana_dir/share/grafana/public/build/grafanaUI\"*.js 2>/dev/null | sort -u | head -40","description":"Enumerate supported color modes in grafana-ui bundle"}

Error Messages/Logs

Steps to Reproduce

Ask claude to prepend command with a variable assignment

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.160

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

cc=$(command -v claude 2>/dev/null); echo \"claude: $cc\"; claude --version 2>/dev/null
"claude: /Users/ko/.local/bin/claude"
2.1.160 (Claude Code)

"env": {
"CLAUDE_CODE_ENABLE_TELEMETRY": "1",
"OTEL_METRICS_EXPORTER": "otlp",
"OTEL_LOGS_EXPORTER": "otlp",
"OTEL_TRACES_EXPORTER": "otlp",
"OTEL_EXPORTER_OTLP_PROTOCOL": "grpc",
"OTEL_EXPORTER_OTLP_ENDPOINT": "http://localhost:4317",
"OTEL_METRIC_EXPORT_INTERVAL": "10000",
"OTEL_LOGS_EXPORT_INTERVAL": "5000",
"OTEL_TRACES_EXPORT_INTERVAL": "5000",
"OTEL_LOG_TOOL_DETAILS": "1",
"OTEL_LOG_TOOL_CONTENT": "1",
"OTEL_LOG_RAW_API_BODIES": "1",
"OTEL_LOG_USER_PROMPTS": "1",
"OTEL_METRICS_INCLUDE_VERSION": "1",
"OTEL_METRICS_INCLUDE_ENTRYPOINT": "1",
"CLAUDE_CODE_ENHANCED_TELEMETRY_BETA": "1"
},

{service_name="claude-code"} | json | event_name="tool_decision" | line_format `{{.tool_parameters}}` | json |
  bash_command=~`^[A-Za-z_][A-Za-z0-9_]*=.*`

<img width="1662" height="738" alt="Image" src="https://github.com/user-attachments/assets/7a8f2313-c9e1-4059-9094-eb7fe495b647" />

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗