fix: correct Anthropic provider inputOther token counting#2
Closed
hobostay wants to merge 1 commit into
Closed
Conversation
inputOther was set to raw input_tokens which already includes cache tokens, causing double-counting. Subtract cache_read_input_tokens and cache_creation_input_tokens to get the actual non-cache input count, matching the OpenAI provider's calculation pattern. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Collaborator
|
Thank you for your interest in contributing to kimi-code. |
sailist
added a commit
that referenced
this pull request
Jun 5, 2026
…imentalDecorators (P2.1) Smoke test for Phase 2 @ifoo migration: switch `services.set(IConnectionRegistry, new ConnectionRegistry())` to `services.set(IConnectionRegistry, new SyncDescriptor(ConnectionRegistry))` so the container drives construction through `_createAndCacheServiceInstance` and the @ifoo auto-injection path. ConnectionRegistry has 0 service deps so the auto-inject step is a no-op — this is the minimum viable proof that the new path replaces ad-hoc `new C()` registrations cleanly. Logger stays as an externally-built `PinoLogger` instance (its ctor takes the pino DaemonLogger, not a DI dependency). Also enable `experimentalDecorators: true` in `packages/{daemon,services}/tsconfig.json` — required prerequisite for `@IFoo`-style parameter decorators landing in P2.2 onwards. The root tsconfig stays untouched; only the two packages migrating to @ifoo opt in. esbuild (vitest transpiler) and tsdown (rolldown bundler) both honor this flag for legacy parameter-decorator emit. Per phase-1 reviewer handoff #1: this is the smoke test confirming a single descriptor-based registration migrates cleanly before fan-out. agent-core/src/di/ untouched (sealed for Phase 2). Daemon test green (241 pass after one flake-rerun on fs-watch.e2e.test.ts AC #2 burst window — known flake per phase-1 reviewer handoff #5). VERDICT: PASS — start.ts:296 descriptor swap + tsconfig experimentalDecorators=true; 241/241 daemon tests green.
sailist
added a commit
to sailist/kimi-code
that referenced
this pull request
Jun 8, 2026
…er-domain move Cleanup tail of the per-domain restructure. Step B.1's atomic move deleted 8 positive-service interfaces and impls but left the 3 broker interfaces (approval/question/event) and 2 broker adapters in the old layout while their new domain copies (approval/, question/, event/) were already wired into the barrel — making the old files dead orphans. Drop them and let the empty parent directories vanish. The barrel src/index.ts already points exclusively at the new per-domain folders; nothing in packages/services or packages/daemon imports the old paths. Quality gates match the Phase A baseline exactly: services tsc 13 pre-existing errors, daemon tsc 30, services tests 140/140, daemon tests 261/262 (the known fs-watch.e2e.test.ts AC MoonshotAI#2 flake).
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.
Summary
inputOtherwas set to rawinput_tokenswhich already includes cache tokens, causing double-counting of non-cache input tokenscache_read_input_tokensandcache_creation_input_tokensfrom the total, matching the OpenAI provider's calculation pattern (promptTokens - cached)Root Cause
In
packages/kosong/src/providers/anthropic.ts,_extractUsageassignedusage.input_tokensdirectly toinputOther. Per the Anthropic API,input_tokensis the total billed input tokens which already includes cache-read and cache-creation tokens. This inflated the reported non-cache input count.Test plan
inputOther + inputCacheRead + inputCacheCreationnow sums correctly toinput_tokens🤖 Generated with Claude Code