Skip to content

Test dict-style and zero-fallback branches of get_tokens_counts_from_response - #19

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1789677932-test-token-counts
Open

devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1789677932-test-token-counts

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Summary

Code scan finding: only the object-attribute branch of TrackAPIPricingMixin.get_tokens_counts_from_response was exercised, so a provider returning dict-style usage (or no usable usage at all) could silently yield 0, 0 tokens and zero cost without any test catching it.

Adds two parametrized unit tests in tests/llm/test_tracking.py calling the method directly on a bare TrackAPIPricingMixin():

  • parsing for usage.input_tokens/output_tokens, usage.prompt_tokens/completion_tokens, {"usage": {"input_tokens", "output_tokens"}} and {"usage": {"prompt_tokens", "completion_tokens"}}
  • the fallback path returning (0, 0) and logging a warning when usage is missing or has no recognized fields

No production code changes.

Devin-Org: engineering

Link to Devin session: https://app.devin.ai/sessions/fdc03943209f453880727c8bf2f12fc0
Open in Devin Desktop: https://app.devin.ai/desktop/session/fdc03943209f453880727c8bf2f12fc0?variant=devin

@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

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.

0 participants