test: add provider usage-normalization, compaction-telemetry, prompt-prefix coverage - #962
Merged
agentforce314 merged 1 commit intoOct 4, 2026
Conversation
…prefix coverage Three test modules written against existing behaviour but never committed, so they have not been running in CI. All pass on Python 3.10 and 3.11. - `tests/providers/test_usage_normalization.py` (30 tests) pins `normalizeUsage()` across every provider against the Anthropic convention: input_tokens for cache MISS, cache_read_input_tokens for HIT, and cache_creation_input_tokens for WRITE. This is the audit that catches an OpenAI-wire-format provider folding `prompt_tokens_details.cached_tokens` back into `prompt_tokens`, which silently overstates cache-miss spend. - `tests/test_compaction_telemetry.py` (17 tests) covers cache-hostile compaction detection. - `tests/prompt/test_prefix_stability.py` (15 tests) covers prompt-prefix stability. Marks `TestOpenAICompatibleProvider` with `__test__ = False`. It is a helper base rather than a test class, and pytest collects by the `Test`` prefix, so it emitted a PytestCollectionWarning on every run. Nothing subclasses it, so this suppresses no real tests.
Test Results 5 files 1 021 suites 21m 3s ⏱️ Results for commit 26f7737. |
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
Three test modules that were written against existing behaviour but never committed — so they have not been running in CI. All pass on Python 3.10 and 3.11.
tests/providers/test_usage_normalization.pynormalizeUsage()across every providertests/test_compaction_telemetry.pytests/prompt/test_prefix_stability.pyWhy the usage-normalization matrix matters
The tests pin each provider's
normalizeUsage()to the Anthropic wire convention:input_tokens— cache MISS, priced at the input ratecache_read_input_tokens— cache HIT, priced at the cache-read ratecache_creation_input_tokens— cache WRITE, priced at the cache-write rateThis is the audit that catches an OpenAI-wire-format provider folding
prompt_tokens_details.cached_tokensback intoprompt_tokens. That mistake is silent — the request still succeeds and token totals still look plausible — but it overstates cache-miss spend, which is precisely the number prompt-caching economics depend on.One fix beyond adding files
TestOpenAICompatibleProvideris a helper base class, not a test class. pytest collects by theTestprefix, so it emitted aPytestCollectionWarningon every run (it also inherits an__init__fromMockMessage).Marked it
__test__ = False. Nothing subclasses it, so this suppresses no real tests — verified by confirming zero subclasses before applying.Verification
The 4 full-suite failures are pre-existing, not from this PR
Confirmed by running the same tests on an untouched
fork/maincheckout.Three failures in the full-suite run, all in
test_init_integration.py, are the SIGINT/SIGTERM startup race that #961 fixes:TestSigtermPathRunsCleanups::test_sigterm_triggers_drainTestSigintDuringPrefetch::test_sigint_during_prefetch_clean_exitTestSigintBeforePrefetchStarted::test_sigint_before_any_prefetch(The third passes in some runs — the race is timing-dependent, so it appears when that file is run on its own more reliably than in a full-suite run. Same root cause.)
Two further failures reproduce on pristine
fork/mainwith none of my changes applied, and are unrelated to this branch:workflow/test_agent_concurrency.py::test_concurrent_agents_run_in_parallel9.76s < 1.0s)bridge/test_bridge_main.py::test_spawn_worktree_creates_isolated_dir_and_cleans_upassert 0 == 1)Note
No production code is touched here — this is tests only, all passing against current behaviour on a clean checkout.