Repository navigation
trace: leave Claude Code's local commands out of the prompt count - #333
Open
Saksham Uboweja (SakshamUboweja) wants to merge 2 commits into
Open
Saksham Uboweja (SakshamUboweja) wants to merge 2 commits into
Saksham Uboweja (SakshamUboweja) wants to merge 2 commits into
Conversation
Claude Code runs a local command (/context, /usage, /clear, ...) itself and writes it as three user entries: a meta <local-command-caveat>, the <command-name> entry as its child, and the command's output. `_is_prompt` skips the first and the last but accepts the command, so a session that only ran /context folded as one prompt with no model request, and tool pruning counted every catalog tool as unused through it. `claude_prompt_count` now skips an entry whose parent is such a caveat. A prompt-type slash command (/tokeneconomizer:status) has no caveat and still counts; `claude_prompt_turns` is unchanged.
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.
Claude Code's local commands (
/context,/usage,/clear, ...) were counted as prompts, even though the model never sees them./contextfolded as 1 prompt with 0 model requests, and tool pruning counted every tool as unused in it./tokeneconomizer:status) still count. Turn counting is untouched.Test:
tests/test_trace.py::test_a_claude_local_command_is_no_promptfails on main and passes with this change. Full suite passes.