Skip to content

Claude provider: handle plain-string message content (current Claude Code logs collect zero records) - #2

Open
wrg32786 wants to merge 1 commit into
sequilade:mainfrom
wrg32786:fix/claude-string-content
Open

Claude provider: handle plain-string message content (current Claude Code logs collect zero records)#2
wrg32786 wants to merge 1 commit into
sequilade:mainfrom
wrg32786:fix/claude-string-content

Conversation

@wrg32786

@wrg32786 wrg32786 commented Aug 8, 2026

Copy link
Copy Markdown

Current Claude Code session logs write message.content as a plain string for simple turns and as a list of content blocks otherwise. Some records also carry non-dict blocks, and a few carry non-dict message fields.

The Claude collector assumes list-of-dicts everywhere, so the first plain-string content aborts the entire walk with 'str' object has no attribute 'get' and the report shows zero Claude usage. On a machine with heavy current-version Claude Code use, the tool reports $0.00 and 0 calls across the board.

This PR guards the three sites:

  • _extract_text returns string content directly and skips non-dict blocks;
  • the tool-name pass only iterates list content and dict blocks;
  • the usage pass only reads usage from dict messages.

Verified on real logs: before the patch, 0 records and an all-zero report with the warning above; after the patch, the same corpus collects tens of thousands of calls with per-project and per-day breakdowns populated. No behavior change for logs that already parse.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NSjPuP4TH9zLbBXk4Z3FZf

Current Claude Code writes message.content as a plain string for simple
turns and as a list of blocks otherwise; some records also carry non-dict
blocks and non-dict message fields. The collector assumed list-of-dicts
everywhere, so the first string aborted the whole Claude walk with
"'str' object has no attribute 'get'" and the report showed zero Claude
usage. Guard all three sites: _extract_text accepts str content, the
tool-name walk only iterates list content with dict blocks, and the usage
pass only reads dict messages.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NSjPuP4TH9zLbBXk4Z3FZf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants