feat: display token usage and duration after job execution#35
Open
mtibbits wants to merge 1 commit into
Open
Conversation
1217a67 to
a4e5417
Compare
After each job completes during `claude-queue start`, print duration and token usage (input + output) extracted from Claude Code's JSONL conversation logs. Detailed cache breakdowns are persisted in the prompt's execution log. Uses the existing JSONL files under ~/.claude/projects/ rather than switching to --output-format json, preserving text-mode stdout, Fix 2 rate-limit detection, and all existing tests unchanged. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Matthew Tibbits <mtibbits@users.noreply.github.com>
a4e5417 to
69cb187
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When running
claude-queue startwith a batch of jobs, there's no visibilityinto how many tokens each job consumed or how long it took. This makes it hard
to identify which jobs are burning through the token budget, estimate costs,
or diagnose unexpectedly slow executions.
Solution
After each job execution, print duration and token usage to the console.
Token counts are extracted from Claude Code's existing JSONL conversation logs
(
~/.claude/projects/), so this requires no changes to the subprocessinvocation —
claude_interface.pyis untouched.Console output
Execution log (persisted in .md file)
Stats are best-effort — if the JSONL can't be found (e.g., older CLI version,
killed process), only duration is shown. Extraction failures never break the
execution-result pipeline.
Test plan
tests/test_session_stats.pytest_claude_interface.py)🤖 Generated with Claude Code