Skip to content

LCORE-2859: Source code named quota.py in utils coincides with quota package name - confuses tools, including some agents - #2077

Merged
tisnik merged 2 commits into
lightspeed-core:mainfrom
tisnik:lcore-2859
Jul 7, 2026
Merged

tisnik merged 2 commits into
lightspeed-core:mainfrom
tisnik:lcore-2859

Conversation

@tisnik

@tisnik tisnik commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Description

LCORE-2859: Source code named quota.py in utils coincides with quota package name - confuses tools, including some agents

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up service version
  • Bump-up dependent library
  • Bump-up library or tool used for development (does not change the final image)
  • CI configuration change
  • Konflux configuration change
  • Unit tests improvement
  • Integration tests improvement
  • End to end tests improvement
  • Benchmarks improvement

Tools used to create PR

  • Assisted-by: N/A
  • Generated by: N/A

Related Tickets & Documents

  • Related Issue #LCORE-2859

Summary by CodeRabbit

  • Refactor
    • Updated internal quota/token utility usage to consistently rely on the centralized quota utilities across query, streaming, and response handling.
    • No visible behavior changes are expected for end users.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: dd0de6bf-4c78-41e3-a0c3-72ef64063648

📥 Commits

Reviewing files that changed from the base of the PR and between 191b99c and 6045df0.

📒 Files selected for processing (7)
  • src/app/endpoints/query.py
  • src/app/endpoints/responses.py
  • src/app/endpoints/rlsapi_v1.py
  • src/app/endpoints/streaming_query.py
  • src/utils/agents/streaming.py
  • src/utils/query.py
  • src/utils/quota_utils.py
📜 Recent review details
⏰ Context from checks skipped due to timeout. (18)
  • GitHub Check: Pyright
  • GitHub Check: unit_tests (3.12)
  • GitHub Check: list_outdated_dependencies
  • GitHub Check: integration_tests (3.12)
  • GitHub Check: unit_tests (3.13)
  • GitHub Check: integration_tests (3.13)
  • GitHub Check: spectral
  • GitHub Check: build-pr
  • GitHub Check: Pylinter
  • GitHub Check: E2E Tests for Lightspeed Evaluation job
  • GitHub Check: E2E: library mode / ci / group 2
  • GitHub Check: E2E: library mode / ci / group 1
  • GitHub Check: E2E: server mode / ci / group 1
  • GitHub Check: E2E: server mode / ci / group 2
  • GitHub Check: E2E: library mode / ci / group 3
  • GitHub Check: E2E: server mode / ci / group 3
  • GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-0-6-on-pull-request
  • GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-on-pull-request
🧰 Additional context used
📓 Path-based instructions (2)
src/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

src/**/*.py: Use absolute imports for internal modules: from authentication import get_auth_dependency
Llama Stack imports: Use from llama_stack_client import AsyncLlamaStackClient
Check constants.py for shared constants before defining new ones
All modules must start with descriptive docstrings explaining purpose
Use logger = get_logger(__name__) from log.py for module logging
All functions must have complete type annotations for parameters and return types, use modern syntax (str | int), and include descriptive docstrings
Use snake_case with descriptive, action-oriented names for functions (get_, validate_, check_)
Avoid in-place parameter modification anti-patterns; return new data structures instead of modifying function parameters
Use async def for I/O operations and external API calls
Use standard log levels with clear purposes: debug() for diagnostic info, info() for program execution, warning() for unexpected events, error() for serious problems
All classes must have descriptive docstrings explaining purpose and use PascalCase with standard suffixes: Configuration, Error/Exception, Resolver, Interface
Abstract classes must use ABC with @abstractmethod decorators
Follow Google Python docstring conventions with required sections: Parameters, Returns, Raises, and Attributes for classes

Files:

  • src/utils/agents/streaming.py
  • src/utils/query.py
  • src/app/endpoints/streaming_query.py
  • src/app/endpoints/rlsapi_v1.py
  • src/app/endpoints/query.py
  • src/app/endpoints/responses.py
src/app/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

src/app/**/*.py: FastAPI dependencies: Import from fastapi module for APIRouter, HTTPException, Request, status, Depends
Use FastAPI HTTPException with appropriate status codes for API endpoints and handle APIConnectionError from Llama Stack

Files:

  • src/app/endpoints/streaming_query.py
  • src/app/endpoints/rlsapi_v1.py
  • src/app/endpoints/query.py
  • src/app/endpoints/responses.py
🧠 Learnings (4)
📚 Learning: 2026-06-24T13:45:37.249Z
Learnt from: Jdubrick
Repo: lightspeed-core/lightspeed-stack PR: 1971
File: src/utils/markdown_repair.py:31-36
Timestamp: 2026-06-24T13:45:37.249Z
Learning: In the lightspeed-stack repository, docstrings must use the section header name "Parameters:" (not "Args:") for function arguments, even if the project references Google Python docstring conventions. Ensure docstrings follow the project’s established "Parameters:" header format for any documented function parameters.

Applied to files:

  • src/utils/agents/streaming.py
  • src/utils/query.py
  • src/app/endpoints/streaming_query.py
  • src/app/endpoints/rlsapi_v1.py
  • src/app/endpoints/query.py
  • src/app/endpoints/responses.py
📚 Learning: 2026-07-06T15:26:18.398Z
Learnt from: Jdubrick
Repo: lightspeed-core/lightspeed-stack PR: 2071
File: src/models/config.py:2416-2422
Timestamp: 2026-07-06T15:26:18.398Z
Learning: In this repo’s Python code under src/**, don’t treat differences in string concatenation style as a style inconsistency when Black has effectively forced (or made clearer) use of explicit `+` string concatenation in multi-line logger/string expressions. If adjacent-literal implicit concatenation is avoided/changed specifically to accommodate Black’s formatting in these call sites, accept the `+` usage and don’t recommend converting it solely for consistency with nearby blocks that use implicit concatenation.

Applied to files:

  • src/utils/agents/streaming.py
  • src/utils/query.py
  • src/app/endpoints/streaming_query.py
  • src/app/endpoints/rlsapi_v1.py
  • src/app/endpoints/query.py
  • src/app/endpoints/responses.py
📚 Learning: 2026-04-06T20:18:07.852Z
Learnt from: major
Repo: lightspeed-core/lightspeed-stack PR: 1463
File: src/app/endpoints/rlsapi_v1.py:266-271
Timestamp: 2026-04-06T20:18:07.852Z
Learning: In the lightspeed-stack codebase, within `src/app/endpoints/` inference/MCP endpoints, treat `tools: Optional[list[Any]]` in MCP tool definitions as an intentional, consistent typing pattern (used across `query`, `responses`, `streaming_query`, `rlsapi_v1`). Do not raise or suggest this as a typing issue during code review; changing it in isolation could break endpoint typing consistency across the codebase.

Applied to files:

  • src/app/endpoints/streaming_query.py
  • src/app/endpoints/rlsapi_v1.py
  • src/app/endpoints/query.py
  • src/app/endpoints/responses.py
📚 Learning: 2026-01-14T09:37:51.612Z
Learnt from: asimurka
Repo: lightspeed-core/lightspeed-stack PR: 988
File: src/app/endpoints/query.py:319-339
Timestamp: 2026-01-14T09:37:51.612Z
Learning: In the lightspeed-stack repository, when provider_id == "azure", the Azure provider with provider_type "remote::azure" is guaranteed to be present in the providers list. Therefore, avoid defensive StopIteration handling for next() when locating the Azure provider in providers within src/app/endpoints/query.py. This change applies specifically to this file (or nearby provider lookup code) and relies on the invariant that the Azure provider exists; if the invariant could be violated, keep the existing StopIteration handling.

Applied to files:

  • src/app/endpoints/query.py
🔇 Additional comments (7)
src/app/endpoints/query.py (2)

68-68: LGTM!


68-68: 🗄️ Data Integrity & Integration

Remove this comment. No utils.quota imports remain; the code now uses utils.quota_utils throughout.

			> Likely an incorrect or invalid review comment.
src/app/endpoints/responses.py (1)

88-88: LGTM!

src/app/endpoints/rlsapi_v1.py (1)

55-55: LGTM!

src/app/endpoints/streaming_query.py (1)

106-106: LGTM!

src/utils/agents/streaming.py (1)

62-62: LGTM!

src/utils/query.py (1)

36-36: LGTM!


Walkthrough

This PR updates quota-related imports in six modules to source helper functions from utils.quota_utils instead of utils.quota. No runtime logic changes are included.

Changes

Quota import migration

Layer / File(s) Summary
Update quota helper import sources
src/app/endpoints/query.py, src/app/endpoints/responses.py, src/app/endpoints/rlsapi_v1.py, src/app/endpoints/streaming_query.py, src/utils/agents/streaming.py, src/utils/query.py
Import statements for check_tokens_available, get_available_quotas, and consume_tokens are switched from utils.quota to utils.quota_utils across all six files, preserving existing function usage.

Estimated code review effort: 1 (Trivial) | ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main refactor: renaming the conflicting utils quota source and updating related imports.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@tisnik
tisnik merged commit 0bb0f62 into lightspeed-core:main Jul 7, 2026
38 of 39 checks passed
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.

1 participant