Skip to content

Fix model usage attribution for cached SAM2/SAM3 requests - #2751

Open
hansent wants to merge 1 commit into
mainfrom
hansent/inf-512-model-usage-attribution
Open

Fix model usage attribution for cached SAM2/SAM3 requests#2751
hansent wants to merge 1 commit into
mainfrom
hansent/inf-512-model-usage-attribution

Conversation

@hansent

@hansent hansent commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • attribute category=model usage to the current request model ID instead of a cached model instance
  • use the current caller API key for model usage while preserving an explicit usage API key
  • propagate query API keys into SAM3 request objects before model dispatch

Why

The inference-models SAM2/SAM3 adapters decorate infer_from_request(self, request). The model usage extractor did not inspect the request, so resource_id became unknown and API-key attribution could fall back to the caller that first loaded the cached model.

Linear: https://linear.app/roboflow/issue/INF-512/all-categorymodel-usage-rows-record-resource-idunknown-under-use

Testing

  • python -m pytest tests/inference/unit_tests/usage_tracking/test_decorator_helpers.py (8 passed)
  • python -m pytest tests/inference/unit_tests/usage_tracking/test_collector.py (53 passed)
  • python -m py_compile on all modified Python files
  • git diff --check

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

👋 Thanks for the pull request! Here is how automated Claude review works here, so you spend credits (and reviewer time) wisely.

🚦 This PR is marked Ready for review, so automated Claude review will run — and every pass spends real credits.

Warning

💸 The Claude reviewer bills in credits, not vibes

Automated review spins up a real agent that reads real code and spends real credits on every pass. It is glad to help — but it is not a rubber duck, a linter you poke in a loop, or a substitute for reading the contributing guide. Treat it like an expensive senior reviewer whose time you booked, and show up prepared.

Draft when unsure, Ready when you mean it:

  • 🌱 Not sure the PR is in good shape yet? Keep it (or set it back) as a draft — drafts pause review, so you can push and iterate without burning credits on a moving target.
  • 💪 Feel strong about the contents? Mark it Ready for review and the reviewer will take a look.

However you get there, arrive prepared:

  • 🧱 Bring a SOLID, thorough PR. Point your local agent at our skills/ to tune it to our guidelines first — or, if you are one of those fabled carbon-based contributors, read them yourself. A half-baked diff costs exactly the same to review as a finished one.
  • Resolve every comment before you re-request review. Re-requesting with threads still open means paying twice for the same conversation.
  • 🔁 Do not use CI review as an inner loop for a local agent. The reviewer is not a step-by-step debugger — do the unfolding locally and arrive with the answer, not the search.
  • 🙋 If something looks off, ask a human. One question to a maintainer is cheaper and faster than three rounds of agent re-review chasing a misread.

Reviews are not free. A draft costs nothing to review; a Ready PR is a promise that it is worth reviewing.

  • Prefer to skip automated review entirely? Add the skip-claude-review label.

@hansent
hansent marked this pull request as ready for review August 3, 2026 19:14
@hansent hansent added the claude-review Use to trigger AI review manually label Aug 3, 2026
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

🤖 Claude review started at commit ed7fabb15294268c34c631ffe6feda26f77c883e.

New commits are not auto-reviewed. Add the claude-review label (remove & re-add it to trigger again) when you want another review.

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

😎 PR passes the vibe-check and trust-me-bro verification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claude-review Use to trigger AI review manually

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant