Skip to content

test: verify cache-aware LLM request costs - #1519

Open
YaoSong808 wants to merge 2 commits into
RailtownAI:mainfrom
YaoSong808:feature/1433/cache-aware-request-cost
Open

test: verify cache-aware LLM request costs#1519
YaoSong808 wants to merge 2 commits into
RailtownAI:mainfrom
YaoSong808:feature/1433/cache-aware-request-cost

Conversation

@YaoSong808

Copy link
Copy Markdown

Summary

  • verify that provider-normalized cached input token details reach LiteLLM cost calculation
  • cover buffered and streamed responses
  • cover OpenAI-compatible prompt token details and Anthropic cache-read token fields
  • clarify that the usage-based fallback preserves discounted cache pricing

The usage-based pricing path added on main now makes cache-aware pricing work without duplicating LiteLLM pricing tables. These tests lock in that behavior for both supported response paths.

Closes #1433

Type of change

  • Bug fix
  • Feature
  • Breaking change
  • Docs
  • Refactor / chore / build / tests
  • Tests

Checklist

  • Lint & format pass (ruff check and ruff format)
  • Tests added/updated and pass locally
  • Docs updated if user-facing behavior changed (not applicable)
  • Breaking changes include migration notes (not applicable)

Notes

Validation: 2255 core and integration tests passed; 8 skipped. Dependency ordering and the basic framework smoke test also passed.

Comment thread packages/railtracks/tests/unit_tests/llm/models/test_litellm_wrapper.py Outdated

@Aryan-Railtown Aryan-Railtown 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.

just one minor thing and we should be good to merge

# A streamed response carries no cost. Price it from the usage chunk.
# A streamed response carries no cost. Price it from the complete usage
# object so provider-normalized details such as cached input tokens retain
# their discounted rate.

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.

could you shorten this inline comment please

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.

Precise request cost with cache hit info

2 participants