Skip to content

feat(harness): Droid Phase 3 — thinking/cacheWrite tokens + cache-read cost - #59

Open
joshau wants to merge 2 commits into
mainfrom
worktree-phase3-droid-tokens
Open

feat(harness): Droid Phase 3 — thinking/cacheWrite tokens + cache-read cost#59
joshau wants to merge 2 commits into
mainfrom
worktree-phase3-droid-tokens

Conversation

@joshau

@joshau joshau commented May 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Thinking & cache-write tokens: Parse [Session] Saving session settings log lines to extract cumulative thinkingTokens and cacheCreationTokens. Delta-track per sessionId so each watcher scan emits only the incremental count as droid.tokens.thinking and droid.tokens.cache_write hook events, mapping to the new thinking and cacheWrite direction values.
  • Cache-read cost: Add a 0.1× cache-read multiplier to estimate_cost_usd and wire cacheReadInputTokens from [Agent] Streaming result lines into the call, closing the ~10% cost underestimate.
  • Domain sync: direction closed-enum updated in both validate.rs (Rust) and validate.ts (TS); two new default HookRule entries added to defaults.rs.

Test plan

  • cargo clippy --all-targets -- -D warnings passes
  • cargo test --lib — 695 tests pass (9 new: session delta parsing, multi-session tracking, payload emission, cache-read cost contribution)
  • pnpm run build (Vite/TS) passes clean

🤖 Generated with Claude Code

joshau and others added 2 commits May 28, 2026 11:17
…d cost

Parse `[Session] Saving session settings` lines to extract cumulative
thinkingTokens and cacheCreationTokens; delta-track per sessionId so
each scan emits only the incremental count as new `thinking` and
`cacheWrite` direction hook events.

Add 0.1× cache-read multiplier to estimate_cost_usd and wire
cacheReadInputTokens from `[Agent] Streaming result` into the call,
closing the ~10% cost underestimate.

Keep direction closed-enum in sync across Rust validate.rs and TS
validate.ts; add two new default HookRules to defaults.rs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…her tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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