Skip to content

fix: session resume loses cache tokens; unknown tools auto-allow in DEFAULT mode#7

Merged
MukundaKatta merged 3 commits intomainfrom
fix/issues-pass
Apr 23, 2026
Merged

fix: session resume loses cache tokens; unknown tools auto-allow in DEFAULT mode#7
MukundaKatta merged 3 commits intomainfrom
fix/issues-pass

Conversation

@MukundaKatta
Copy link
Copy Markdown
Owner

Issues fixed

1. Session resume silently discards cache token counts (session/storage.py)

SessionStorage.save() only serialized input_tokens and output_tokens from the Usage dataclass, omitting cache_creation_input_tokens and cache_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 DEFAULT mode, the permission checker checked membership in ALWAYS_ALLOW and ALWAYS_ASK_DEFAULT, but fell through to an unconditional ALLOW for 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 returning ASK for unrecognised tools in DEFAULT mode.

All existing tests pass.

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.
@MukundaKatta MukundaKatta merged commit dfd62bf into main Apr 23, 2026
4 checks passed
@MukundaKatta MukundaKatta deleted the fix/issues-pass branch April 23, 2026 14:56
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.

1 participant