Skip to content

fix(tokens): delete all matching pricing caches when keep_count=0 - #6331

Open
Brohammad wants to merge 1 commit into
browser-use:mainfrom
Brohammad:fix/6235-clean-old-caches-keep-count-zero
Open

Brohammad wants to merge 1 commit into
browser-use:mainfrom
Brohammad:fix/6235-clean-old-caches-keep-count-zero

Conversation

@Brohammad

@Brohammad Brohammad commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Fixes TokenCost.clean_old_caches(keep_count=0) so it removes all pricing cache files for the current source URL instead of keeping them (own_files[:-0] is empty in Python).
  • Skips the early return when keep_count is 0 so purge semantics run even when files exist.
  • Adds focused CI tests for keep counts 0 and 1, including isolation of other sources and malformed cache files.

Closes #6235

Test plan

  • uv run pytest -vxs tests/ci/test_token_cost_clean_old_caches.py

Summary by cubic

Fixes TokenCost.clean_old_caches(keep_count=0) so it now deletes all pricing cache files for the current source URL, instead of keeping them all because own_files[:-0] evaluates to an empty list in Python. Also skips the early return when keep_count is 0 so purge semantics run correctly.

Adds CI regression tests for keep counts 0 and 1, verifying that other sources and malformed cache files are left untouched. Closes #6235.

Written for commit 37f505d. Summary will update on new commits.

View guided diff

keep_count=0 previously used own_files[:-0], which removes nothing. Treat
zero as purge-all for the current pricing source and add regression tests.

Fixes browser-use#6235
Copilot AI balanced review requested due to automatic review settings November 7, 2026 14:34
@mintlify

mintlify Bot commented Nov 7, 2026

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 37f505d.

Approve preview

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-07T14:35:02.586230Z
We couldn’t complete this review. Comment @codex review to try again.
37f505d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed 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

Comment thread browser_use/tokens/service.py Resolved

This branch has not been deployed

No deployments
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.

Bug: clean_old_caches(keep_count=0) retains every pricing cache

2 participants