fix: session resume loses cache tokens; unknown tools auto-allow in DEFAULT mode#7
Merged
MukundaKatta merged 3 commits intomainfrom Apr 23, 2026
Merged
fix: session resume loses cache tokens; unknown tools auto-allow in DEFAULT mode#7MukundaKatta merged 3 commits intomainfrom
MukundaKatta merged 3 commits intomainfrom
Conversation
Cache token fields (cache_creation_input_tokens, cache_read_input_tokens) were dropped when saving a session. On resume, Usage(**data["usage"]) would reconstruct those fields as zero, silently losing accumulated cache token counts across sessions.
…o-allowing In DEFAULT mode, tools not in ALWAYS_ALLOW or ALWAYS_ASK_DEFAULT fell through to an unconditional ALLOW. Any future tool (e.g. MCP tools not yet prefixed with mcp__) would silently execute without confirmation, violating the intent of DEFAULT mode.
The [tool.pytest.ini_options] section with norecursedirs = ["reference"] was accidentally dropped in the previous commit, causing pytest to collect tests from reference/claw-code-main/tests/ which import a local `src` module not on the Python path.
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.
Issues fixed
1. Session resume silently discards cache token counts (
session/storage.py)SessionStorage.save()only serializedinput_tokensandoutput_tokensfrom theUsagedataclass, omittingcache_creation_input_tokensandcache_read_input_tokens. On resume,Usage(**data["usage"])reconstructed those fields as zero, so any cache token usage accumulated before saving was permanently lost. Fixed by persisting all four fields.2. Unknown tools auto-allow in DEFAULT permission mode (
permissions/checker.py)In
DEFAULTmode, the permission checker checked membership inALWAYS_ALLOWandALWAYS_ASK_DEFAULT, but fell through to an unconditionalALLOWfor anything else. A tool not in either set (e.g. a custom tool registered at runtime) would execute without user confirmation, violating the principle of least privilege for DEFAULT mode. Fixed by returningASKfor unrecognised tools in DEFAULT mode.All existing tests pass.