Repository navigation
fix(tokens): preserve concurrent pricing cache snapshots - #6260
Open
Elon-Jiang wants to merge 1 commit into
Open
Elon-Jiang wants to merge 1 commit into
Elon-Jiang wants to merge 1 commit into
Conversation
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
Contributor
There was a problem hiding this comment.
No issues found across 2 files
Heads up: you’re close to your flex budget. Increase your flex budget so reviews don’t pause.
View guided diff | Re-trigger cubic
This branch has not been deployed
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.
Problem
Concurrent
TokenCostrefreshes share a cache directory, but cache filenames only contain a seconds-resolution timestamp. Differentpricing_urlsources fetched within the same second overwrite each other's JSON files. Both instances initially have valid in-memory data, while a subsequent instance cannot find the missing source's disk cache and must fetch again. This defeats the existing source-aware cache isolation and loses offline pricing availability.Change
Add a UUID suffix to each timestamped pricing snapshot. Existing JSON contents, source matching, expiry, glob-based discovery and retention logic stay compatible. Add a regression using eight real local HTTP endpoints: concurrent refreshes must retain every source, and fresh instances must reload their own data without further HTTP responses.
Reproduction and validation
uv run --no-sync pytest tests/ci/test_token_cost_cache_files.py tests/ci/test_openrouter_token_cost.py -q -o addopts='' --tb=short— 6 passed.tests/cirun on macOS/Python 3.12: 1263 passed, 35 skipped, 5 failed. The failures were the custom-Python Bash test (missinglibpython3.12.dylibin its created venv) and four cloud-hint logging assertions. All five also failed during the unmodified-base full-suite comparison. That comparison was interrupted to stop desktop browser interference: 1173 passed, 32 skipped, 7 failed before interruption, including two additional beta-agent failures. This is not a claim of a fully green suite. The cloud-hint module separately passed all 10 tests on the base.AI assistance: Codex helped investigate, implement and validate this fix.
Summary by cubic
Fixes concurrent
TokenCostrefreshes overwriting each other's cache files when fetched within the same second, causing later instances to refetch and lose offline pricing availability.Bug Fixes
Written for commit 56c10c8. Summary will update on new commits.