Skip to content

LCORE-1880: Replaced successful responses and common models#1676

Merged
tisnik merged 1 commit into
lightspeed-core:mainfrom
asimurka:move_error_responses
May 5, 2026
Merged

LCORE-1880: Replaced successful responses and common models#1676
tisnik merged 1 commit into
lightspeed-core:mainfrom
asimurka:move_error_responses

Conversation

@asimurka
Copy link
Copy Markdown
Contributor

@asimurka asimurka commented May 4, 2026

Description

Replaces successful responses from monolithic responses.py into multiple shorter files. Unifies documentation. Updates imports. No functional changes,

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

Identify any AI code assistants used in this PR (for transparency and review context)

  • Assisted-by: Cursor

Related Tickets & Documents

Checklist before requesting a review

  • I have performed a self-review of my code.
  • PR has passed all pre-merge test jobs.
  • If it is a core feature, I have added thorough tests.

Testing

  • Please provide detailed steps to perform tests related to this code change.
  • How were the fix/results from this change verified? Please provide relevant screenshots or results.

Summary by CodeRabbit

  • Documentation

    • OpenAPI documentation updated: expanded response model descriptions with clearer "Attributes" details and adjusted examples; streaming/event-stream schema simplified.
  • Chores

    • Internal reorganization of API response and shared model packaging for cleaner, more modular public schemas and imports (no runtime behavior changes).

@asimurka asimurka changed the title Replaced successful responses and common models LCORE-1880: Replaced successful responses and common models May 4, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 4, 2026

Warning

Rate limit exceeded

@asimurka has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 18 minutes and 31 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: e0848724-c4d8-4c80-81da-44a2f9267e50

📥 Commits

Reviewing files that changed from the base of the PR and between ad420c2 and 53ff338.

📒 Files selected for processing (118)
  • docs/openapi.json
  • src/app/endpoints/authorized.py
  • src/app/endpoints/config.py
  • src/app/endpoints/conversations_v1.py
  • src/app/endpoints/conversations_v2.py
  • src/app/endpoints/feedback.py
  • src/app/endpoints/health.py
  • src/app/endpoints/info.py
  • src/app/endpoints/mcp_auth.py
  • src/app/endpoints/mcp_servers.py
  • src/app/endpoints/metrics.py
  • src/app/endpoints/models.py
  • src/app/endpoints/prompts.py
  • src/app/endpoints/providers.py
  • src/app/endpoints/query.py
  • src/app/endpoints/rags.py
  • src/app/endpoints/responses.py
  • src/app/endpoints/rlsapi_v1.py
  • src/app/endpoints/root.py
  • src/app/endpoints/shields.py
  • src/app/endpoints/stream_interrupt.py
  • src/app/endpoints/streaming_query.py
  • src/app/endpoints/tools.py
  • src/app/endpoints/vector_stores.py
  • src/app/main.py
  • src/authentication/jwk_token.py
  • src/authentication/k8s.py
  • src/authentication/utils.py
  • src/authorization/middleware.py
  • src/cache/cache.py
  • src/cache/in_memory_cache.py
  • src/cache/noop_cache.py
  • src/cache/postgres_cache.py
  • src/cache/sqlite_cache.py
  • src/client.py
  • src/metrics/utils.py
  • src/models/api/README.md
  • src/models/api/responses/README.md
  • src/models/api/responses/__init__.py
  • src/models/api/responses/error/README.md
  • src/models/api/responses/successful/README.md
  • src/models/api/responses/successful/__init__.py
  • src/models/api/responses/successful/bases.py
  • src/models/api/responses/successful/catalog.py
  • src/models/api/responses/successful/configuration.py
  • src/models/api/responses/successful/conversations.py
  • src/models/api/responses/successful/feedback.py
  • src/models/api/responses/successful/mcp_servers.py
  • src/models/api/responses/successful/probes.py
  • src/models/api/responses/successful/prompts.py
  • src/models/api/responses/successful/query.py
  • src/models/api/responses/successful/responses_openai.py
  • src/models/api/responses/successful/vector_stores.py
  • src/models/cache_entry.py
  • src/models/common/__init__.py
  • src/models/common/conversation.py
  • src/models/common/health.py
  • src/models/common/mcp.py
  • src/models/common/moderation.py
  • src/models/common/responses/__init__.py
  • src/models/common/responses/responses_api_params.py
  • src/models/common/responses/responses_context.py
  • src/models/common/responses/responses_conversation_context.py
  • src/models/common/responses/types.py
  • src/models/common/transcripts.py
  • src/models/common/turn_summary.py
  • src/models/context.py
  • src/models/requests.py
  • src/models/responses.py
  • src/models/rlsapi/responses.py
  • src/utils/conversations.py
  • src/utils/endpoints.py
  • src/utils/mcp_oauth_probe.py
  • src/utils/prompts.py
  • src/utils/query.py
  • src/utils/quota.py
  • src/utils/responses.py
  • src/utils/shields.py
  • src/utils/transcripts.py
  • src/utils/types.py
  • src/utils/vector_search.py
  • tests/integration/endpoints/test_query_byok_integration.py
  • tests/integration/endpoints/test_rlsapi_v1_integration.py
  • tests/integration/test_middleware_integration.py
  • tests/unit/app/endpoints/test_a2a.py
  • tests/unit/app/endpoints/test_config.py
  • tests/unit/app/endpoints/test_conversations.py
  • tests/unit/app/endpoints/test_conversations_v2.py
  • tests/unit/app/endpoints/test_health.py
  • tests/unit/app/endpoints/test_mcp_auth.py
  • tests/unit/app/endpoints/test_mcp_servers.py
  • tests/unit/app/endpoints/test_prompts.py
  • tests/unit/app/endpoints/test_query.py
  • tests/unit/app/endpoints/test_responses.py
  • tests/unit/app/endpoints/test_responses_splunk.py
  • tests/unit/app/endpoints/test_rlsapi_v1.py
  • tests/unit/app/endpoints/test_shields.py
  • tests/unit/app/endpoints/test_stream_interrupt.py
  • tests/unit/app/endpoints/test_streaming_query.py
  • tests/unit/app/endpoints/test_tools.py
  • tests/unit/app/test_main_middleware.py
  • tests/unit/cache/test_postgres_cache.py
  • tests/unit/cache/test_sqlite_cache.py
  • tests/unit/models/responses/test_authorized_response.py
  • tests/unit/models/responses/test_error_responses.py
  • tests/unit/models/responses/test_query_response.py
  • tests/unit/models/responses/test_rag_chunk.py
  • tests/unit/models/responses/test_response_types.py
  • tests/unit/models/responses/test_successful_responses.py
  • tests/unit/models/responses/test_types.py
  • tests/unit/models/rlsapi/test_responses.py
  • tests/unit/utils/test_conversations.py
  • tests/unit/utils/test_endpoints.py
  • tests/unit/utils/test_query.py
  • tests/unit/utils/test_shields.py
  • tests/unit/utils/test_transcripts.py
  • tests/unit/utils/test_types.py
  • tests/unit/utils/test_vector_search.py

Walkthrough

Reorganized response and shared Pydantic models into src/models/api/responses/... and src/models/common/..., removed the monolithic src/models/responses.py, added new base response classes with OpenAPI helpers, updated OpenAPI schema text in docs/openapi.json, and refactored imports across application code and tests to use the new module layout.

Changes

Model reorganization, OpenAPI bases, import rewiring

Layer / File(s) Summary
Data Shape (new/removed models)
src/models/common/*.py (conversation.py, health.py, mcp.py, moderation.py, turn_summary.py, transcripts.py), src/models/common/responses/types.py, src/models/common/responses/responses_conversation_context.py, src/models/api/responses/successful/*.py (catalog, configuration, conversations, feedback, mcp_servers, probes, prompts, query, responses_openai, vector_stores)
Added many new domain-specific Pydantic models and type aliases (conversation types, provider health, MCP metadata, moderation discriminated union, RAG/turn/tool summaries, transcripts, Responses API types) and numerous successful response models previously defined in the removed monolithic file.
Core Implementation / Helpers
src/models/api/responses/successful/bases.py
Added AbstractSuccessfulResponse and AbstractDeleteResponse base classes with openapi_response() implementations, computed delete fields, and example-driven OpenAPI construction logic.
Package Init & Exports
src/models/common/__init__.py, src/models/common/responses/__init__.py, src/models/api/responses/__init__.py, src/models/api/responses/successful/__init__.py
New package initializers that aggregate and re-export model symbols and submodules; models.api.responses.__init__ now exposes error, successful, and constants submodules instead of many individual names.
Legacy Removal & Simplification
src/models/responses.py (removed), src/utils/types.py (reduced)
Deleted the large legacy models/responses.py and stripped utils/types.py to minimal utilities, moving its prior Pydantic/type contents into models.common and models.api.responses.successful modules.
OpenAPI Schema Edits
docs/openapi.json
Expanded many response schema description values into multi-line "Attributes:" sections, removed several inline Example blocks, adjusted Truncated description formatting, and simplified the text/event-stream media schema to type: "string" (removed format).
Wiring / Import Updates
src/app/endpoints/*.py, src/app/main.py, src/authentication/*.py, src/authorization/*.py, src/cache/*.py, src/client.py, src/metrics/*.py, src/models/*.py, src/utils/*.py (25+ files)
Refactored import statements across application code to reference models.api.responses.constants, models.api.responses.error, models.api.responses.successful, and models.common.* instead of the previous models.responses / utils.types aggregated locations; unchanged runtime logic.
Tests
tests/unit/**, tests/integration/** (30+ files)
Updated test imports to the new model locations; one test removed an assertion on schema["format"] == "text/event-stream" and another refactored access to an exception detail dict. No substantive test logic changes.
Documentation
src/models/api/README.md, src/models/api/responses/README.md, src/models/api/responses/error/README.md, src/models/api/responses/successful/README.md
Added/expanded README entries documenting the new package layout and the error/successful response groupings and files.

Sequence Diagram(s)

(omitted — changes are structural refactoring; no new multi-component control flow introduced)

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

Comment thread src/models/api/responses/successful/configuration.py Dismissed
Comment thread src/models/api/responses/successful/configuration.py Dismissed
Comment thread src/models/api/responses/successful/configuration.py Dismissed
if self.tools is not None:
tool_dicts: list[dict[str, Any]] = []
for t in self.tools:
for t in list(self.tools):
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Pyright complaining

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 12

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/openapi.json`:
- Line 16505: The PromptDeleteResponse description is out of sync with its
schema—update the "description" for the PromptDeleteResponse schema to list all
actual payload properties (at minimum include "success" as a required boolean
and "prompt_id" and any other fields shown in the example), and ensure the text
matches the example and required fields in the schema; locate the
PromptDeleteResponse entry in the OpenAPI JSON and revise the description string
to enumerate each attribute and its type/meaning so consumers see an accurate
payload doc.

In `@src/models/api/README.md`:
- Around line 6-7: The heading "## [responses/](responses/README.md)" in
src/models/api/README.md is immediately followed by content on the next line;
insert a single blank line after that heading so the file has one empty line
between the heading and the paragraph to satisfy markdownlint rule MD022 (i.e.,
update the README so "## [responses/](responses/README.md)" is followed by one
blank line before the descriptive text).

In `@src/models/api/responses/README.md`:
- Around line 3-13: Add blank lines before and after each section heading so
markdownlint rule MD022 is satisfied: insert one empty line above and one empty
line below each "## [__init__.py](__init__.py)", "##
[constants.py](constants.py)", "## [error/](error/README.md)", and "##
[successful/](successful/README.md)" heading in README.md so headings are
separated from surrounding text.

In `@src/models/api/responses/successful/bases.py`:
- Around line 34-35: AbstractDeleteResponse should inherit from
AbstractSuccessfulResponse so delete responses share the successful-response
polymorphic contract; update the class definition of AbstractDeleteResponse to
inherit from AbstractSuccessfulResponse instead of BaseModel and ensure
AbstractSuccessfulResponse is imported in the module (replace or add the import
as needed), leaving other fields/annotations unchanged.

In `@src/models/api/responses/successful/feedback.py`:
- Around line 33-56: Replace the open-ended status: dict on
FeedbackStatusUpdateResponse with a small nested Pydantic model (e.g. class
FeedbackStatus(BaseModel)) that declares the four keys shown in the example:
previous_status: bool, updated_status: bool, updated_by: str, timestamp: str (or
datetime if you prefer stricter typing), then change the
FeedbackStatusUpdateResponse.status annotation to use that FeedbackStatus type
and keep the existing model_config example; also add any needed import for
BaseModel/typing so validation and schema generation enforce the exact shape.

In `@src/models/api/responses/successful/query.py`:
- Around line 143-160: Summary: The OpenAPI JSON Schema in openapi_response
currently includes the SSE MIME type in the "format" field, which is redundant
and noisy. Fix: In the classmethod openapi_response, remove the "format":
MEDIA_TYPE_EVENT_STREAM entry from the schema construction (keep "schema":
{"type": "string"}), leaving the SSE media type represented only by the
top-level content key; locate openapi_response, model_json_schema(), and
MEDIA_TYPE_EVENT_STREAM in the method and update the returned content
accordingly, preserving the example_value and raising SchemaError as before.

In `@src/models/api/responses/successful/README.md`:
- Around line 1-37: Update the README.md headings to satisfy MD022 by inserting
a single blank line immediately before and after each heading line (both the
level-1 title and every level-2 item such as "## [__init__.py](__init__.py)",
"## [bases.py](bases.py)", etc.); ensure there is exactly one blank line
separating headings from surrounding text so all section headers have one empty
line above and one empty line below.

In `@src/models/api/responses/successful/vector_stores.py`:
- Line 37: The usage_bytes attribute should be required instead of defaulting to
0: remove the default=0 and declare usage_bytes as a required Field (e.g.,
Field(...) or otherwise omit a default) so Pydantic will raise if upstream value
is missing; update the declaration of usage_bytes (the Field import usage) in
the vector store response model to eliminate the silent zero fallback and ensure
real upstream values are enforced.

In `@src/models/common/health.py`:
- Around line 8-28: The status field on ProviderHealthStatus currently accepts
any string; constrain it to the documented values by replacing the free-form
status annotation with a closed type: either use typing.Literal["ok",
"unhealthy", "not_implemented"] as the type for status or define an Enum (e.g.,
class ProviderStatus(Enum) with OK/UNHEALTHY/NOT_IMPLEMENTED members) and set
status: ProviderStatus; update imports (typing.Literal or enum.Enum) and keep
the Field metadata and examples in sync so Pydantic validation and the generated
schema only allow the three documented states.

In `@src/models/common/mcp.py`:
- Around line 16-33: The MCPServerInfo model's source field is currently an
unconstrained str; change it to a constrained type (e.g., Literal["config",
"api"] or a small Enum) so invalid values are rejected and the OpenAPI schema
documents only those options; update the Field type annotation for source in the
MCPServerInfo class to use typing.Literal (or an Enum class) and adjust any
imports (typing or typing_extensions) and examples/description as needed to
reflect the two allowed values ("config", "api").

In `@src/models/common/moderation.py`:
- Around line 13-17: Add an "Attributes" section to the docstrings of the
ShieldModerationPassed and ShieldModerationBlocked Pydantic models documenting
their fields (e.g., the decision field and its literal value) so they follow the
repo's docstring standard; update the docstrings for classes
ShieldModerationPassed and ShieldModerationBlocked to include an Attributes
bullet (or section) that describes each Pydantic attribute and its type/value.

In `@src/models/common/transcripts.py`:
- Around line 8-31: Update the class docstrings for TranscriptMetadata and
Transcript to include Google-style "Attributes" sections that list each Pydantic
field, its type, and a one-line description (include which fields are optional
or have defaults); specifically document provider, model, query_provider,
query_model, user_id, conversation_id, timestamp for TranscriptMetadata and
metadata, redacted_query, query_is_valid, llm_response, rag_chunks, truncated,
attachments, tool_calls, tool_results for Transcript (note the default_factory
lists and optional fields where applicable) so the model docs follow the
repository's docstring guidelines.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: d81a4bf7-aad1-435a-931c-044b7339b10f

📥 Commits

Reviewing files that changed from the base of the PR and between 774964a and 242ed91.

📒 Files selected for processing (117)
  • docs/openapi.json
  • src/app/endpoints/authorized.py
  • src/app/endpoints/config.py
  • src/app/endpoints/conversations_v1.py
  • src/app/endpoints/conversations_v2.py
  • src/app/endpoints/feedback.py
  • src/app/endpoints/health.py
  • src/app/endpoints/info.py
  • src/app/endpoints/mcp_auth.py
  • src/app/endpoints/mcp_servers.py
  • src/app/endpoints/metrics.py
  • src/app/endpoints/models.py
  • src/app/endpoints/prompts.py
  • src/app/endpoints/providers.py
  • src/app/endpoints/query.py
  • src/app/endpoints/rags.py
  • src/app/endpoints/responses.py
  • src/app/endpoints/rlsapi_v1.py
  • src/app/endpoints/root.py
  • src/app/endpoints/shields.py
  • src/app/endpoints/stream_interrupt.py
  • src/app/endpoints/streaming_query.py
  • src/app/endpoints/tools.py
  • src/app/endpoints/vector_stores.py
  • src/app/main.py
  • src/authentication/jwk_token.py
  • src/authentication/k8s.py
  • src/authentication/utils.py
  • src/authorization/middleware.py
  • src/cache/cache.py
  • src/cache/in_memory_cache.py
  • src/cache/noop_cache.py
  • src/cache/postgres_cache.py
  • src/cache/sqlite_cache.py
  • src/client.py
  • src/metrics/utils.py
  • src/models/api/README.md
  • src/models/api/responses/README.md
  • src/models/api/responses/__init__.py
  • src/models/api/responses/error/README.md
  • src/models/api/responses/successful/README.md
  • src/models/api/responses/successful/__init__.py
  • src/models/api/responses/successful/bases.py
  • src/models/api/responses/successful/catalog.py
  • src/models/api/responses/successful/configuration.py
  • src/models/api/responses/successful/conversations.py
  • src/models/api/responses/successful/feedback.py
  • src/models/api/responses/successful/mcp_servers.py
  • src/models/api/responses/successful/probes.py
  • src/models/api/responses/successful/prompts.py
  • src/models/api/responses/successful/query.py
  • src/models/api/responses/successful/responses_openai.py
  • src/models/api/responses/successful/vector_stores.py
  • src/models/cache_entry.py
  • src/models/common/__init__.py
  • src/models/common/conversation.py
  • src/models/common/health.py
  • src/models/common/mcp.py
  • src/models/common/moderation.py
  • src/models/common/responses/__init__.py
  • src/models/common/responses/responses_api_params.py
  • src/models/common/responses/responses_context.py
  • src/models/common/responses/types.py
  • src/models/common/transcripts.py
  • src/models/common/turn_summary.py
  • src/models/context.py
  • src/models/requests.py
  • src/models/responses.py
  • src/models/rlsapi/responses.py
  • src/utils/conversations.py
  • src/utils/endpoints.py
  • src/utils/mcp_oauth_probe.py
  • src/utils/prompts.py
  • src/utils/query.py
  • src/utils/quota.py
  • src/utils/responses.py
  • src/utils/shields.py
  • src/utils/transcripts.py
  • src/utils/types.py
  • src/utils/vector_search.py
  • tests/integration/endpoints/test_query_byok_integration.py
  • tests/integration/endpoints/test_rlsapi_v1_integration.py
  • tests/integration/test_middleware_integration.py
  • tests/unit/app/endpoints/test_a2a.py
  • tests/unit/app/endpoints/test_config.py
  • tests/unit/app/endpoints/test_conversations.py
  • tests/unit/app/endpoints/test_conversations_v2.py
  • tests/unit/app/endpoints/test_health.py
  • tests/unit/app/endpoints/test_mcp_auth.py
  • tests/unit/app/endpoints/test_mcp_servers.py
  • tests/unit/app/endpoints/test_prompts.py
  • tests/unit/app/endpoints/test_query.py
  • tests/unit/app/endpoints/test_responses.py
  • tests/unit/app/endpoints/test_responses_splunk.py
  • tests/unit/app/endpoints/test_rlsapi_v1.py
  • tests/unit/app/endpoints/test_shields.py
  • tests/unit/app/endpoints/test_stream_interrupt.py
  • tests/unit/app/endpoints/test_streaming_query.py
  • tests/unit/app/endpoints/test_tools.py
  • tests/unit/app/test_main_middleware.py
  • tests/unit/cache/test_postgres_cache.py
  • tests/unit/cache/test_sqlite_cache.py
  • tests/unit/models/responses/test_authorized_response.py
  • tests/unit/models/responses/test_error_responses.py
  • tests/unit/models/responses/test_query_response.py
  • tests/unit/models/responses/test_rag_chunk.py
  • tests/unit/models/responses/test_response_types.py
  • tests/unit/models/responses/test_successful_responses.py
  • tests/unit/models/responses/test_types.py
  • tests/unit/models/rlsapi/test_responses.py
  • tests/unit/utils/test_conversations.py
  • tests/unit/utils/test_endpoints.py
  • tests/unit/utils/test_query.py
  • tests/unit/utils/test_shields.py
  • tests/unit/utils/test_transcripts.py
  • tests/unit/utils/test_types.py
  • tests/unit/utils/test_vector_search.py
💤 Files with no reviewable changes (2)
  • src/models/api/responses/error/README.md
  • src/models/responses.py
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
  • GitHub Check: unit_tests (3.12)
  • GitHub Check: bandit
  • GitHub Check: spectral
  • GitHub Check: build-pr
  • GitHub Check: Pyright
  • GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-on-pull-request
  • GitHub Check: E2E: library mode / ci / group 3
  • GitHub Check: E2E: server mode / ci / group 3
  • GitHub Check: E2E: library mode / ci / group 2
  • GitHub Check: E2E: server mode / ci / group 2
  • GitHub Check: E2E: server mode / ci / group 1
  • GitHub Check: E2E: library mode / ci / group 1
  • GitHub Check: E2E Tests for Lightspeed Evaluation job
🧰 Additional context used
📓 Path-based instructions (7)
src/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

src/**/*.py: Use absolute imports for internal modules: from authentication import get_auth_dependency
All modules start with descriptive docstrings explaining purpose
Use logger = get_logger(__name__) from log.py for module logging
Type aliases defined at module level for clarity
Use Final[type] as type hint for all constants
All functions require docstrings with brief descriptions
Complete type annotations for function parameters and return types
Use Union types with modern syntax: str | int
Use Optional[Type] for optional type hints
Use snake_case with descriptive, action-oriented function names (get_, validate_, check_)
Avoid in-place parameter modification anti-patterns: return new data structures instead of modifying parameters
Use async def for I/O operations and external API calls
Use logger.debug() for detailed diagnostic information
Use logger.info() for general information about program execution
Use logger.warning() for unexpected events or potential problems
Use logger.error() for serious problems that prevented function execution
All classes require descriptive docstrings explaining purpose
Use PascalCase for class names with descriptive names and standard suffixes: Configuration, Error/Exception, Resolver, Interface
Abstract classes use ABC with @abstractmethod decorators
Complete type annotations for all class attributes, use specific types, not Any
Follow Google Python docstring conventions for all modules, classes, and functions
Docstring Parameters section documents function parameters
Docstring Returns section documents function return values
Docstring Raises section documents exceptions that may be raised
Use black for code formatting
Use pylint for static analysis with source-roots configuration set to "src"
Use pyright for type checking
Use ruff for fast linting
Use pydocstyle for docstring style validation
Use mypy for additional type checking
Use bandit for security issue detection

Files:

  • src/cache/cache.py
  • src/authentication/utils.py
  • src/models/common/responses/types.py
  • src/models/cache_entry.py
  • src/models/rlsapi/responses.py
  • src/authentication/jwk_token.py
  • src/app/endpoints/rags.py
  • src/app/endpoints/shields.py
  • src/utils/prompts.py
  • src/authentication/k8s.py
  • src/client.py
  • src/models/common/mcp.py
  • src/models/common/health.py
  • src/models/api/responses/successful/bases.py
  • src/models/api/responses/successful/configuration.py
  • src/models/common/responses/responses_context.py
  • src/models/api/responses/successful/feedback.py
  • src/authorization/middleware.py
  • src/app/endpoints/authorized.py
  • src/utils/quota.py
  • src/utils/mcp_oauth_probe.py
  • src/models/common/moderation.py
  • src/models/api/responses/successful/query.py
  • src/cache/noop_cache.py
  • src/app/endpoints/providers.py
  • src/models/api/responses/successful/conversations.py
  • src/app/main.py
  • src/models/common/responses/__init__.py
  • src/models/api/responses/successful/prompts.py
  • src/app/endpoints/info.py
  • src/models/common/responses/responses_api_params.py
  • src/cache/sqlite_cache.py
  • src/app/endpoints/conversations_v1.py
  • src/app/endpoints/tools.py
  • src/app/endpoints/mcp_auth.py
  • src/cache/in_memory_cache.py
  • src/models/common/__init__.py
  • src/models/common/conversation.py
  • src/models/api/responses/successful/vector_stores.py
  • src/app/endpoints/conversations_v2.py
  • src/app/endpoints/responses.py
  • src/utils/query.py
  • src/app/endpoints/vector_stores.py
  • src/app/endpoints/config.py
  • src/models/api/responses/__init__.py
  • src/app/endpoints/stream_interrupt.py
  • src/models/context.py
  • src/models/api/responses/successful/probes.py
  • src/app/endpoints/feedback.py
  • src/models/common/turn_summary.py
  • src/utils/shields.py
  • src/models/api/responses/successful/__init__.py
  • src/models/api/responses/successful/mcp_servers.py
  • src/models/requests.py
  • src/app/endpoints/root.py
  • src/models/common/transcripts.py
  • src/app/endpoints/rlsapi_v1.py
  • src/utils/responses.py
  • src/app/endpoints/health.py
  • src/app/endpoints/prompts.py
  • src/app/endpoints/mcp_servers.py
  • src/utils/types.py
  • src/utils/conversations.py
  • src/models/api/responses/successful/responses_openai.py
  • src/app/endpoints/query.py
  • src/app/endpoints/streaming_query.py
  • src/utils/vector_search.py
  • src/models/api/responses/successful/catalog.py
  • src/cache/postgres_cache.py
  • src/utils/transcripts.py
  • src/utils/endpoints.py
  • src/metrics/utils.py
  • src/app/endpoints/metrics.py
  • src/app/endpoints/models.py
tests/unit/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

tests/unit/**/*.py: Use pytest for all unit and integration tests
Use pytest-mock for AsyncMock objects in unit tests
Use marker pytest.mark.asyncio for async tests

Files:

  • tests/unit/models/responses/test_types.py
  • tests/unit/app/endpoints/test_stream_interrupt.py
  • tests/unit/models/responses/test_response_types.py
  • tests/unit/app/endpoints/test_shields.py
  • tests/unit/app/endpoints/test_mcp_servers.py
  • tests/unit/cache/test_sqlite_cache.py
  • tests/unit/app/endpoints/test_config.py
  • tests/unit/utils/test_shields.py
  • tests/unit/utils/test_endpoints.py
  • tests/unit/models/responses/test_query_response.py
  • tests/unit/utils/test_vector_search.py
  • tests/unit/app/endpoints/test_query.py
  • tests/unit/models/rlsapi/test_responses.py
  • tests/unit/utils/test_conversations.py
  • tests/unit/models/responses/test_rag_chunk.py
  • tests/unit/app/endpoints/test_responses.py
  • tests/unit/utils/test_types.py
  • tests/unit/app/endpoints/test_responses_splunk.py
  • tests/unit/cache/test_postgres_cache.py
  • tests/unit/models/responses/test_authorized_response.py
  • tests/unit/app/endpoints/test_health.py
  • tests/unit/app/endpoints/test_mcp_auth.py
  • tests/unit/app/endpoints/test_tools.py
  • tests/unit/app/endpoints/test_streaming_query.py
  • tests/unit/models/responses/test_successful_responses.py
  • tests/unit/utils/test_query.py
  • tests/unit/app/endpoints/test_conversations_v2.py
  • tests/unit/app/test_main_middleware.py
  • tests/unit/app/endpoints/test_prompts.py
  • tests/unit/app/endpoints/test_conversations.py
  • tests/unit/app/endpoints/test_rlsapi_v1.py
  • tests/unit/app/endpoints/test_a2a.py
  • tests/unit/models/responses/test_error_responses.py
  • tests/unit/utils/test_transcripts.py
tests/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Do not use unittest - pytest is the standard testing framework for this project

Files:

  • tests/unit/models/responses/test_types.py
  • tests/unit/app/endpoints/test_stream_interrupt.py
  • tests/unit/models/responses/test_response_types.py
  • tests/unit/app/endpoints/test_shields.py
  • tests/unit/app/endpoints/test_mcp_servers.py
  • tests/integration/test_middleware_integration.py
  • tests/unit/cache/test_sqlite_cache.py
  • tests/unit/app/endpoints/test_config.py
  • tests/unit/utils/test_shields.py
  • tests/integration/endpoints/test_rlsapi_v1_integration.py
  • tests/unit/utils/test_endpoints.py
  • tests/unit/models/responses/test_query_response.py
  • tests/unit/utils/test_vector_search.py
  • tests/unit/app/endpoints/test_query.py
  • tests/unit/models/rlsapi/test_responses.py
  • tests/unit/utils/test_conversations.py
  • tests/unit/models/responses/test_rag_chunk.py
  • tests/unit/app/endpoints/test_responses.py
  • tests/unit/utils/test_types.py
  • tests/unit/app/endpoints/test_responses_splunk.py
  • tests/unit/cache/test_postgres_cache.py
  • tests/unit/models/responses/test_authorized_response.py
  • tests/unit/app/endpoints/test_health.py
  • tests/integration/endpoints/test_query_byok_integration.py
  • tests/unit/app/endpoints/test_mcp_auth.py
  • tests/unit/app/endpoints/test_tools.py
  • tests/unit/app/endpoints/test_streaming_query.py
  • tests/unit/models/responses/test_successful_responses.py
  • tests/unit/utils/test_query.py
  • tests/unit/app/endpoints/test_conversations_v2.py
  • tests/unit/app/test_main_middleware.py
  • tests/unit/app/endpoints/test_prompts.py
  • tests/unit/app/endpoints/test_conversations.py
  • tests/unit/app/endpoints/test_rlsapi_v1.py
  • tests/unit/app/endpoints/test_a2a.py
  • tests/unit/models/responses/test_error_responses.py
  • tests/unit/utils/test_transcripts.py
src/models/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

src/models/**/*.py: Use @field_validator and @model_validator for custom validation in Pydantic models
Type hints for Pydantic models: Optional[FilePath], PositiveInt, SecretStr
Use typing_extensions.Self for model validators in Pydantic models
Pydantic config classes extend ConfigurationBase, data models extend BaseModel
Use @model_validator and @field_validator for validation in Pydantic models
Docstring Attributes section documents Pydantic model attributes

Files:

  • src/models/common/responses/types.py
  • src/models/cache_entry.py
  • src/models/rlsapi/responses.py
  • src/models/common/mcp.py
  • src/models/common/health.py
  • src/models/api/responses/successful/bases.py
  • src/models/api/responses/successful/configuration.py
  • src/models/common/responses/responses_context.py
  • src/models/api/responses/successful/feedback.py
  • src/models/common/moderation.py
  • src/models/api/responses/successful/query.py
  • src/models/api/responses/successful/conversations.py
  • src/models/common/responses/__init__.py
  • src/models/api/responses/successful/prompts.py
  • src/models/common/responses/responses_api_params.py
  • src/models/common/__init__.py
  • src/models/common/conversation.py
  • src/models/api/responses/successful/vector_stores.py
  • src/models/api/responses/__init__.py
  • src/models/context.py
  • src/models/api/responses/successful/probes.py
  • src/models/common/turn_summary.py
  • src/models/api/responses/successful/__init__.py
  • src/models/api/responses/successful/mcp_servers.py
  • src/models/requests.py
  • src/models/common/transcripts.py
  • src/models/api/responses/successful/responses_openai.py
  • src/models/api/responses/successful/catalog.py
src/app/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Use FastAPI dependencies: from fastapi import APIRouter, HTTPException, Request, status, Depends

Files:

  • src/app/endpoints/rags.py
  • src/app/endpoints/shields.py
  • src/app/endpoints/authorized.py
  • src/app/endpoints/providers.py
  • src/app/main.py
  • src/app/endpoints/info.py
  • src/app/endpoints/conversations_v1.py
  • src/app/endpoints/tools.py
  • src/app/endpoints/mcp_auth.py
  • src/app/endpoints/conversations_v2.py
  • src/app/endpoints/responses.py
  • src/app/endpoints/vector_stores.py
  • src/app/endpoints/config.py
  • src/app/endpoints/stream_interrupt.py
  • src/app/endpoints/feedback.py
  • src/app/endpoints/root.py
  • src/app/endpoints/rlsapi_v1.py
  • src/app/endpoints/health.py
  • src/app/endpoints/prompts.py
  • src/app/endpoints/mcp_servers.py
  • src/app/endpoints/query.py
  • src/app/endpoints/streaming_query.py
  • src/app/endpoints/metrics.py
  • src/app/endpoints/models.py
src/app/endpoints/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Use FastAPI HTTPException with appropriate status codes for API endpoint error handling

Files:

  • src/app/endpoints/rags.py
  • src/app/endpoints/shields.py
  • src/app/endpoints/authorized.py
  • src/app/endpoints/providers.py
  • src/app/endpoints/info.py
  • src/app/endpoints/conversations_v1.py
  • src/app/endpoints/tools.py
  • src/app/endpoints/mcp_auth.py
  • src/app/endpoints/conversations_v2.py
  • src/app/endpoints/responses.py
  • src/app/endpoints/vector_stores.py
  • src/app/endpoints/config.py
  • src/app/endpoints/stream_interrupt.py
  • src/app/endpoints/feedback.py
  • src/app/endpoints/root.py
  • src/app/endpoints/rlsapi_v1.py
  • src/app/endpoints/health.py
  • src/app/endpoints/prompts.py
  • src/app/endpoints/mcp_servers.py
  • src/app/endpoints/query.py
  • src/app/endpoints/streaming_query.py
  • src/app/endpoints/metrics.py
  • src/app/endpoints/models.py
src/**/__init__.py

📄 CodeRabbit inference engine (AGENTS.md)

Package __init__.py files contain brief package descriptions

Files:

  • src/models/common/responses/__init__.py
  • src/models/common/__init__.py
  • src/models/api/responses/__init__.py
  • src/models/api/responses/successful/__init__.py
🧠 Learnings (6)
📚 Learning: 2026-01-12T10:58:40.230Z
Learnt from: blublinsky
Repo: lightspeed-core/lightspeed-stack PR: 972
File: src/models/config.py:459-513
Timestamp: 2026-01-12T10:58:40.230Z
Learning: In lightspeed-core/lightspeed-stack, for Python files under src/models, when a user claims a fix is done but the issue persists, verify the current code state before accepting the fix. Steps: review the diff, fetch the latest changes, run relevant tests, reproduce the issue, search the codebase for lingering references to the original problem, confirm the fix is applied and not undone by subsequent commits, and validate with local checks to ensure the issue is resolved.

Applied to files:

  • src/models/common/responses/types.py
  • src/models/cache_entry.py
  • src/models/rlsapi/responses.py
  • src/models/common/mcp.py
  • src/models/common/health.py
  • src/models/api/responses/successful/bases.py
  • src/models/api/responses/successful/configuration.py
  • src/models/common/responses/responses_context.py
  • src/models/api/responses/successful/feedback.py
  • src/models/common/moderation.py
  • src/models/api/responses/successful/query.py
  • src/models/api/responses/successful/conversations.py
  • src/models/common/responses/__init__.py
  • src/models/api/responses/successful/prompts.py
  • src/models/common/responses/responses_api_params.py
  • src/models/common/__init__.py
  • src/models/common/conversation.py
  • src/models/api/responses/successful/vector_stores.py
  • src/models/api/responses/__init__.py
  • src/models/context.py
  • src/models/api/responses/successful/probes.py
  • src/models/common/turn_summary.py
  • src/models/api/responses/successful/__init__.py
  • src/models/api/responses/successful/mcp_servers.py
  • src/models/requests.py
  • src/models/common/transcripts.py
  • src/models/api/responses/successful/responses_openai.py
  • src/models/api/responses/successful/catalog.py
📚 Learning: 2026-02-25T07:46:33.545Z
Learnt from: asimurka
Repo: lightspeed-core/lightspeed-stack PR: 1211
File: src/models/responses.py:8-16
Timestamp: 2026-02-25T07:46:33.545Z
Learning: In the Python codebase, requests.py should use OpenAIResponseInputTool as Tool while responses.py uses OpenAIResponseTool as Tool. This difference is intentional due to differing schemas for input vs output tools in llama-stack-api. Apply this distinction consistently to other models under src/models (e.g., ensure request-related tools use the InputTool variant and response-related tools use the ResponseTool variant). If adding new tools, choose the corresponding InputTool or Tool class based on whether the tool represents input or output, and document the rationale in code comments.

Applied to files:

  • src/models/common/responses/types.py
  • src/models/cache_entry.py
  • src/models/rlsapi/responses.py
  • src/models/common/mcp.py
  • src/models/common/health.py
  • src/models/api/responses/successful/bases.py
  • src/models/api/responses/successful/configuration.py
  • src/models/common/responses/responses_context.py
  • src/models/api/responses/successful/feedback.py
  • src/models/common/moderation.py
  • src/models/api/responses/successful/query.py
  • src/models/api/responses/successful/conversations.py
  • src/models/common/responses/__init__.py
  • src/models/api/responses/successful/prompts.py
  • src/models/common/responses/responses_api_params.py
  • src/models/common/__init__.py
  • src/models/common/conversation.py
  • src/models/api/responses/successful/vector_stores.py
  • src/models/api/responses/__init__.py
  • src/models/context.py
  • src/models/api/responses/successful/probes.py
  • src/models/common/turn_summary.py
  • src/models/api/responses/successful/__init__.py
  • src/models/api/responses/successful/mcp_servers.py
  • src/models/requests.py
  • src/models/common/transcripts.py
  • src/models/api/responses/successful/responses_openai.py
  • src/models/api/responses/successful/catalog.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/rags.py
  • src/app/endpoints/shields.py
  • src/app/endpoints/authorized.py
  • src/app/endpoints/providers.py
  • src/app/endpoints/info.py
  • src/app/endpoints/conversations_v1.py
  • src/app/endpoints/tools.py
  • src/app/endpoints/mcp_auth.py
  • src/app/endpoints/conversations_v2.py
  • src/app/endpoints/responses.py
  • src/app/endpoints/vector_stores.py
  • src/app/endpoints/config.py
  • src/app/endpoints/stream_interrupt.py
  • src/app/endpoints/feedback.py
  • src/app/endpoints/root.py
  • src/app/endpoints/rlsapi_v1.py
  • src/app/endpoints/health.py
  • src/app/endpoints/prompts.py
  • src/app/endpoints/mcp_servers.py
  • src/app/endpoints/query.py
  • src/app/endpoints/streaming_query.py
  • src/app/endpoints/metrics.py
  • src/app/endpoints/models.py
📚 Learning: 2026-04-15T18:54:07.540Z
Learnt from: Lifto
Repo: lightspeed-core/lightspeed-stack PR: 1510
File: src/models/requests.py:769-773
Timestamp: 2026-04-15T18:54:07.540Z
Learning: In lightspeed-core/lightspeed-stack request models, keep schema-level size limits defined as inline numeric literals (e.g., Pydantic Field max_length values used for validation) rather than extracting them into constants.py. Only extract values intended as configurable runtime defaults (e.g., DEFAULT_* settings like header/file upload sizes). Do not flag inline numeric literals used directly in Pydantic Field constraints or field validators as an extraction-to-constants issue.

Applied to files:

  • src/models/requests.py
📚 Learning: 2026-02-23T14:56:59.186Z
Learnt from: asimurka
Repo: lightspeed-core/lightspeed-stack PR: 1198
File: src/utils/responses.py:184-192
Timestamp: 2026-02-23T14:56:59.186Z
Learning: In the lightspeed-stack codebase (lightspeed-core/lightspeed-stack), do not enforce de-duplication of duplicate client.models.list() calls in model selection flows (e.g., in src/utils/responses.py prepare_responses_params). These calls are considered relatively cheap and removing duplicates could add unnecessary complexity to the flow. Apply this guideline specifically to this file/context unless similar performance characteristics and design decisions are documented elsewhere.

Applied to files:

  • src/utils/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
🪛 markdownlint-cli2 (0.22.1)
src/models/api/README.md

[warning] 6-6: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)

src/models/api/responses/README.md

[warning] 6-6: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


[warning] 9-9: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


[warning] 12-12: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)

src/models/api/responses/successful/README.md

[warning] 3-3: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


[warning] 6-6: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


[warning] 9-9: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


[warning] 12-12: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


[warning] 15-15: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


[warning] 18-18: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


[warning] 21-21: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


[warning] 24-24: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


[warning] 27-27: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


[warning] 30-30: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


[warning] 33-33: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


[warning] 36-36: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)

Comment thread docs/openapi.json Outdated
Comment thread src/models/api/README.md
Comment thread src/models/api/responses/README.md
Comment thread src/models/api/responses/successful/bases.py
Comment thread src/models/api/responses/successful/feedback.py
Comment thread src/models/api/responses/successful/vector_stores.py
Comment thread src/models/common/health.py
Comment thread src/models/common/mcp.py
Comment thread src/models/common/moderation.py
Comment thread src/models/common/transcripts.py
@asimurka asimurka force-pushed the move_error_responses branch 3 times, most recently from 794d9bc to ad420c2 Compare May 5, 2026 06:29
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 11

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
src/models/api/responses/successful/catalog.py (1)

10-259: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

All seven classes in this file are missing Attributes sections in their docstrings.

ModelsResponse, ToolsResponse, ShieldsResponse, RAGInfoResponse, RAGListResponse, ProvidersListResponse, and ProviderResponse each have a single-line docstring with no Attributes section documenting their Pydantic fields.

Example fix for RAGInfoResponse (apply the same pattern to the remaining six):

📝 Proposed fix (RAGInfoResponse example)
 class RAGInfoResponse(AbstractSuccessfulResponse):
-    """Model representing a response with information about RAG DB."""
+    """Model representing a response with information about RAG DB.
+
+    Attributes:
+        id: Vector DB unique ID.
+        name: Human readable vector DB name (optional).
+        created_at: Unix timestamp when the vector store was created.
+        last_active_at: Unix timestamp of last activity (optional).
+        usage_bytes: Storage bytes used by this vector DB.
+        expires_at: Unix timestamp when the vector store expires (optional).
+        object: Object type identifier.
+        status: Vector DB status string.
+    """

As per coding guidelines, "Docstring Attributes section documents Pydantic model attributes."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/models/api/responses/successful/catalog.py` around lines 10 - 259, Each
Pydantic response class (ModelsResponse, ToolsResponse, ShieldsResponse,
RAGInfoResponse, RAGListResponse, ProvidersListResponse, ProviderResponse) needs
an "Attributes" section added to its docstring listing each model field (name
and short type/description) to satisfy the project's docstring guideline; update
each class docstring to include an Attributes block that documents fields like
models (list[dict]), tools (list[dict]), shields (list[dict]),
id/name/created_at/last_active_at/usage_bytes/expires_at/object/status for
RAGInfoResponse, rags (list[str]) for RAGListResponse, providers (dict[str,
list[dict]]) for ProvidersListResponse, and
api/config/health/provider_id/provider_type for ProviderResponse — keep
descriptions concise and mirror the field descriptions already in the Field(...)
calls.
src/models/common/turn_summary.py (1)

13-105: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Add Attributes sections for the new Pydantic model docstrings.

Several class docstrings describe purpose but omit field-level Attributes documentation, which breaks the repo’s docstring standard for models.

As per coding guidelines: "Follow Google Python docstring conventions for all modules, classes, and functions" and "Docstring Attributes section documents Pydantic model attributes".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/models/common/turn_summary.py` around lines 13 - 105, The model classes
(RAGChunk, ReferencedDocument, RAGContext, ToolCallSummary, ToolResultSummary,
TurnSummary) have docstrings but lack the Google-style "Attributes" sections
required by our docstring standard; update each class docstring to include an
"Attributes" section that lists and briefly describes each Pydantic field (e.g.,
for RAGChunk: content, source, score, attributes; for ReferencedDocument:
doc_url, doc_title, source; for RAGContext: context_text, rag_chunks,
referenced_documents; for ToolCallSummary: id, name, args, type; for
ToolResultSummary: id, status, content, type, round; for TurnSummary: id,
llm_response, tool_calls, tool_results, rag_chunks, referenced_documents,
token_usage), using Google Python docstring formatting and matching the Field
descriptions already present.
docs/openapi.json (1)

6176-19470: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

CI blocker: docs/openapi.json must be regenerated, not hand-edited.

The Spectral pipeline fails with:

OpenAPI schema is out of date. diff -u docs/openapi.json /tmp/openapi-generated.json failed;
regenerate with: uv run python scripts/generate_openapi_schema.py docs/openapi.json

All the description expansions and the format: "text/event-stream" removal were applied directly to the JSON file. The correct workflow is to update the Pydantic model docstrings/class bodies and then let the generation script produce the JSON. Committing a manually-edited docs/openapi.json will keep failing CI on every run until regenerated.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/openapi.json` around lines 6176 - 19470, Manual edits to the generated
OpenAPI JSON caused CI to fail; revert the changes to docs/openapi.json and
regenerate it from the source Pydantic models by running the generation script
(use the project's command: uv run python scripts/generate_openapi_schema.py
docs/openapi.json), and if you intended to change descriptions or the SSE schema
update the Pydantic model docstrings / class attributes (models referenced by
ResponsesRequest/ResponsesResponse, RlsapiV1*, QueryRequest, etc.) then re-run
the generator so the JSON is produced deterministically rather than hand-editing
docs/openapi.json.
♻️ Duplicate comments (3)
src/models/api/responses/README.md (1)

9-13: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add required blank lines around these section headings.

The new headings still violate MD022 (blanks-around-headings), which will keep markdownlint warnings active.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/models/api/responses/README.md` around lines 9 - 13, The section headings
"## [error/](error/README.md)" and "## [successful/](successful/README.md)" lack
the required blank lines; insert a single blank line before and after each
heading so they are separated from surrounding content (i.e., ensure one empty
line above "## [error/](error/README.md)" and one empty line below it, and do
the same for "## [successful/](successful/README.md)") to satisfy MD022.
src/models/api/responses/successful/README.md (1)

3-37: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix MD022 heading spacing in this README.

The section headings still are not surrounded with required blank lines, so markdownlint continues to fail.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/models/api/responses/successful/README.md` around lines 3 - 37, The
README.md violates MD022 because each level-2 heading (e.g., "##
[__init__.py](__init__.py)", "## [bases.py](bases.py)", etc.) is not surrounded
by blank lines; update the file so there is exactly one blank line before and
one blank line after each "## ..." heading (including the first heading) to
satisfy markdownlint MD022, preserving the existing heading text and list
content.
src/models/api/responses/successful/feedback.py (1)

42-56: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Tighten status to a typed nested model instead of dict[str, Any].

status: dict[str, Any] keeps validation/schema open-ended and weakens the response contract. Define a dedicated Pydantic model for status and use it here.

Suggested change
-from typing import Any
-
-from pydantic import Field
+from pydantic import BaseModel, Field

 ...
+class FeedbackStatus(BaseModel):
+    """Status payload for feedback status updates."""
+
+    previous_status: bool
+    updated_status: bool
+    updated_by: str
+    timestamp: str
+
+
 class FeedbackStatusUpdateResponse(AbstractSuccessfulResponse):
 ...
-    status: dict[str, Any]
+    status: FeedbackStatus

As per coding guidelines, "Complete type annotations for all class attributes, use specific types, not Any."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/models/api/responses/successful/feedback.py` around lines 42 - 56,
Replace the open-ended status: dict[str, Any] with a concrete nested Pydantic
model: create a new class (e.g., FeedbackStatus or StatusModel) inheriting from
BaseModel that defines fields previous_status: bool, updated_status: bool,
updated_by: str, timestamp: str (or datetime if preferred), then update the
parent response model's status annotation to that new model and adjust the
model_config example to use the typed model shape; ensure imports for BaseModel
and typing are added and any JSON/schema generation will reflect the stricter
contract.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/openapi.json`:
- Around line 16501-16504: The OpenAPI schema for PromptDeleteResponse is
inconsistent: the required array lists "success" but the description (and likely
Pydantic model) uses "deleted". Update the PromptDeleteResponse schema so the
required property matches the actual field name — either rename the property
back to "success" everywhere or change the required entry to "deleted" (and
regenerate the spec from the Pydantic model if the model field is named deleted)
so the schema properties, required array, and description are all consistent.

In `@src/app/endpoints/conversations_v2.py`:
- Around line 27-30: The current imports of ConversationTurn and Message from
models.common are incompatible with how build_conversation_turn_from_cache_entry
populates fields (referenced_documents, tool_results, provider, model,
started_at, completed_at); update the import to use the conversation response
models that contain the full turn/message schema used by
ConversationResponse.chat_history (replace the models.common imports with the
ConversationResponse/ConversationTurn/Message classes from the conversation
response module) and ensure build_conversation_turn_from_cache_entry still maps
those fields to the response model properties.

In `@src/models/api/responses/successful/bases.py`:
- Around line 17-31: The openapi_response classmethod in this file currently
raises SchemaError when examples are missing; replace that runtime exception
with ValueError (update the raise in cls.openapi_response to raise
ValueError(f"Examples not found in {cls.__name__}")), and also update the
docstring/Raises section in AbstractDeleteResponse.openapi_response() to list
ValueError instead of SchemaError; keep the error message text the same for
consistency.
- Around line 34-57: The class docstring for AbstractDeleteResponse is missing
an Attributes section; update the docstring on AbstractDeleteResponse to include
an "Attributes" subsection that documents the Pydantic fields and computed
properties: deleted (bool) — whether the deletion was successful, resource_name
(ClassVar[str]) — the resource identifier, response (computed_field) —
human-readable outcome of the delete operation, and success (computed_field,
deprecated) — legacy success flag that returns True and is deprecated. Ensure
the wording matches existing docstring style and note that success is
deprecated.
- Around line 53-57: The computed_field method success currently calls
logger.warning on every serialization which floods logs; replace that call with
Python's warnings.warn using DeprecationWarning (e.g.,
warnings.warn("...deprecated...", DeprecationWarning, stacklevel=2)) so warnings
are deduplicated per process; add the necessary import for the warnings module
and keep the method returning True (method name: success, decorator:
`@computed_field`).

In `@src/models/api/responses/successful/conversations.py`:
- Around line 77-108: Update the ConversationDeleteResponse class docstring to
include an Attributes section that documents the Pydantic fields: document
resource_name: ClassVar[str] (the resource label, e.g., "Conversation") and
conversation_id: str (identifier passed to delete, with example UUID). Add brief
types and descriptions for both in the Attributes section of the
ConversationDeleteResponse docstring so it follows the project's docstring
guideline for Pydantic models.

In `@src/models/api/responses/successful/probes.py`:
- Around line 127-131: The attribute `status` is currently annotated as bare
`dict`; update its type to `dict[str, Any]` to provide a string-keyed mapping
and import `Any` from `typing` (or `collections.abc` if preferred) so the
annotation is complete; locate the `status: dict = Field(...)` declaration and
change it to `status: dict[str, Any] = Field(...)` and add the necessary `from
typing import Any` import near the other imports.

In `@src/models/api/responses/successful/query.py`:
- Around line 197-203: The SSE example for the "end" event currently places
"available_quotas" as a sibling of "event" and "data" due to how the string
fragments are concatenated; update the concatenation so that the
'"available_quotas": {}' key is included inside the "data" object for the
'"event": "end"' payload (i.e., ensure the fragment with '"available_quotas":
{}' is appended within the same string literal that builds the '"data": { ... }'
block in the SSE "end" event example).

In `@src/models/common/mcp.py`:
- Around line 6-13: The MCPServerAuthInfo Pydantic model docstring lacks an
Attributes section; update the class docstring for MCPServerAuthInfo to include
an "Attributes" section documenting the model fields `name: str` (MCP server
name) and `client_auth_headers: list[str]` (list of authentication header names
for client-provided tokens), describing their types and purposes consistent with
other model docstrings in the codebase.

In `@src/models/common/responses/__init__.py`:
- Around line 14-21: The module-level constant __all__ should be annotated as a
Final; add an import for Final from typing (e.g. from typing import Final) if
missing and change the declaration to use Final (for example: __all__:
Final[List[str]] = [...]) so the constant follows the project's typing
convention; update any existing typing imports to include Final and keep the
same list contents and name (__all__).

In `@tests/unit/app/endpoints/test_conversations_v2.py`:
- Line 25: The test imports models.common.ConversationData but constructs a
fixture with conversation_id, topic_summary, and last_message_timestamp which
doesn't match that schema; fix by either importing and using the correct
cache/list metadata model that contains those fields (replace the
ConversationData import with the appropriate model used elsewhere for list/cache
metadata) or change the fixture to a lightweight mock (e.g., SimpleNamespace or
a small dict/object) that exposes conversation_id, topic_summary, and
last_message_timestamp so validation won't run against the stricter
ConversationData schema.

---

Outside diff comments:
In `@docs/openapi.json`:
- Around line 6176-19470: Manual edits to the generated OpenAPI JSON caused CI
to fail; revert the changes to docs/openapi.json and regenerate it from the
source Pydantic models by running the generation script (use the project's
command: uv run python scripts/generate_openapi_schema.py docs/openapi.json),
and if you intended to change descriptions or the SSE schema update the Pydantic
model docstrings / class attributes (models referenced by
ResponsesRequest/ResponsesResponse, RlsapiV1*, QueryRequest, etc.) then re-run
the generator so the JSON is produced deterministically rather than hand-editing
docs/openapi.json.

In `@src/models/api/responses/successful/catalog.py`:
- Around line 10-259: Each Pydantic response class (ModelsResponse,
ToolsResponse, ShieldsResponse, RAGInfoResponse, RAGListResponse,
ProvidersListResponse, ProviderResponse) needs an "Attributes" section added to
its docstring listing each model field (name and short type/description) to
satisfy the project's docstring guideline; update each class docstring to
include an Attributes block that documents fields like models (list[dict]),
tools (list[dict]), shields (list[dict]),
id/name/created_at/last_active_at/usage_bytes/expires_at/object/status for
RAGInfoResponse, rags (list[str]) for RAGListResponse, providers (dict[str,
list[dict]]) for ProvidersListResponse, and
api/config/health/provider_id/provider_type for ProviderResponse — keep
descriptions concise and mirror the field descriptions already in the Field(...)
calls.

In `@src/models/common/turn_summary.py`:
- Around line 13-105: The model classes (RAGChunk, ReferencedDocument,
RAGContext, ToolCallSummary, ToolResultSummary, TurnSummary) have docstrings but
lack the Google-style "Attributes" sections required by our docstring standard;
update each class docstring to include an "Attributes" section that lists and
briefly describes each Pydantic field (e.g., for RAGChunk: content, source,
score, attributes; for ReferencedDocument: doc_url, doc_title, source; for
RAGContext: context_text, rag_chunks, referenced_documents; for ToolCallSummary:
id, name, args, type; for ToolResultSummary: id, status, content, type, round;
for TurnSummary: id, llm_response, tool_calls, tool_results, rag_chunks,
referenced_documents, token_usage), using Google Python docstring formatting and
matching the Field descriptions already present.

---

Duplicate comments:
In `@src/models/api/responses/README.md`:
- Around line 9-13: The section headings "## [error/](error/README.md)" and "##
[successful/](successful/README.md)" lack the required blank lines; insert a
single blank line before and after each heading so they are separated from
surrounding content (i.e., ensure one empty line above "##
[error/](error/README.md)" and one empty line below it, and do the same for "##
[successful/](successful/README.md)") to satisfy MD022.

In `@src/models/api/responses/successful/feedback.py`:
- Around line 42-56: Replace the open-ended status: dict[str, Any] with a
concrete nested Pydantic model: create a new class (e.g., FeedbackStatus or
StatusModel) inheriting from BaseModel that defines fields previous_status:
bool, updated_status: bool, updated_by: str, timestamp: str (or datetime if
preferred), then update the parent response model's status annotation to that
new model and adjust the model_config example to use the typed model shape;
ensure imports for BaseModel and typing are added and any JSON/schema generation
will reflect the stricter contract.

In `@src/models/api/responses/successful/README.md`:
- Around line 3-37: The README.md violates MD022 because each level-2 heading
(e.g., "## [__init__.py](__init__.py)", "## [bases.py](bases.py)", etc.) is not
surrounded by blank lines; update the file so there is exactly one blank line
before and one blank line after each "## ..." heading (including the first
heading) to satisfy markdownlint MD022, preserving the existing heading text and
list content.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 7f4f63e3-781b-4765-a04a-3cdae335c3dd

📥 Commits

Reviewing files that changed from the base of the PR and between 242ed91 and ad420c2.

📒 Files selected for processing (118)
  • docs/openapi.json
  • src/app/endpoints/authorized.py
  • src/app/endpoints/config.py
  • src/app/endpoints/conversations_v1.py
  • src/app/endpoints/conversations_v2.py
  • src/app/endpoints/feedback.py
  • src/app/endpoints/health.py
  • src/app/endpoints/info.py
  • src/app/endpoints/mcp_auth.py
  • src/app/endpoints/mcp_servers.py
  • src/app/endpoints/metrics.py
  • src/app/endpoints/models.py
  • src/app/endpoints/prompts.py
  • src/app/endpoints/providers.py
  • src/app/endpoints/query.py
  • src/app/endpoints/rags.py
  • src/app/endpoints/responses.py
  • src/app/endpoints/rlsapi_v1.py
  • src/app/endpoints/root.py
  • src/app/endpoints/shields.py
  • src/app/endpoints/stream_interrupt.py
  • src/app/endpoints/streaming_query.py
  • src/app/endpoints/tools.py
  • src/app/endpoints/vector_stores.py
  • src/app/main.py
  • src/authentication/jwk_token.py
  • src/authentication/k8s.py
  • src/authentication/utils.py
  • src/authorization/middleware.py
  • src/cache/cache.py
  • src/cache/in_memory_cache.py
  • src/cache/noop_cache.py
  • src/cache/postgres_cache.py
  • src/cache/sqlite_cache.py
  • src/client.py
  • src/metrics/utils.py
  • src/models/api/README.md
  • src/models/api/responses/README.md
  • src/models/api/responses/__init__.py
  • src/models/api/responses/error/README.md
  • src/models/api/responses/successful/README.md
  • src/models/api/responses/successful/__init__.py
  • src/models/api/responses/successful/bases.py
  • src/models/api/responses/successful/catalog.py
  • src/models/api/responses/successful/configuration.py
  • src/models/api/responses/successful/conversations.py
  • src/models/api/responses/successful/feedback.py
  • src/models/api/responses/successful/mcp_servers.py
  • src/models/api/responses/successful/probes.py
  • src/models/api/responses/successful/prompts.py
  • src/models/api/responses/successful/query.py
  • src/models/api/responses/successful/responses_openai.py
  • src/models/api/responses/successful/vector_stores.py
  • src/models/cache_entry.py
  • src/models/common/__init__.py
  • src/models/common/conversation.py
  • src/models/common/health.py
  • src/models/common/mcp.py
  • src/models/common/moderation.py
  • src/models/common/responses/__init__.py
  • src/models/common/responses/responses_api_params.py
  • src/models/common/responses/responses_context.py
  • src/models/common/responses/responses_conversation_context.py
  • src/models/common/responses/types.py
  • src/models/common/transcripts.py
  • src/models/common/turn_summary.py
  • src/models/context.py
  • src/models/requests.py
  • src/models/responses.py
  • src/models/rlsapi/responses.py
  • src/utils/conversations.py
  • src/utils/endpoints.py
  • src/utils/mcp_oauth_probe.py
  • src/utils/prompts.py
  • src/utils/query.py
  • src/utils/quota.py
  • src/utils/responses.py
  • src/utils/shields.py
  • src/utils/transcripts.py
  • src/utils/types.py
  • src/utils/vector_search.py
  • tests/integration/endpoints/test_query_byok_integration.py
  • tests/integration/endpoints/test_rlsapi_v1_integration.py
  • tests/integration/test_middleware_integration.py
  • tests/unit/app/endpoints/test_a2a.py
  • tests/unit/app/endpoints/test_config.py
  • tests/unit/app/endpoints/test_conversations.py
  • tests/unit/app/endpoints/test_conversations_v2.py
  • tests/unit/app/endpoints/test_health.py
  • tests/unit/app/endpoints/test_mcp_auth.py
  • tests/unit/app/endpoints/test_mcp_servers.py
  • tests/unit/app/endpoints/test_prompts.py
  • tests/unit/app/endpoints/test_query.py
  • tests/unit/app/endpoints/test_responses.py
  • tests/unit/app/endpoints/test_responses_splunk.py
  • tests/unit/app/endpoints/test_rlsapi_v1.py
  • tests/unit/app/endpoints/test_shields.py
  • tests/unit/app/endpoints/test_stream_interrupt.py
  • tests/unit/app/endpoints/test_streaming_query.py
  • tests/unit/app/endpoints/test_tools.py
  • tests/unit/app/test_main_middleware.py
  • tests/unit/cache/test_postgres_cache.py
  • tests/unit/cache/test_sqlite_cache.py
  • tests/unit/models/responses/test_authorized_response.py
  • tests/unit/models/responses/test_error_responses.py
  • tests/unit/models/responses/test_query_response.py
  • tests/unit/models/responses/test_rag_chunk.py
  • tests/unit/models/responses/test_response_types.py
  • tests/unit/models/responses/test_successful_responses.py
  • tests/unit/models/responses/test_types.py
  • tests/unit/models/rlsapi/test_responses.py
  • tests/unit/utils/test_conversations.py
  • tests/unit/utils/test_endpoints.py
  • tests/unit/utils/test_query.py
  • tests/unit/utils/test_shields.py
  • tests/unit/utils/test_transcripts.py
  • tests/unit/utils/test_types.py
  • tests/unit/utils/test_vector_search.py
💤 Files with no reviewable changes (2)
  • src/models/api/responses/error/README.md
  • src/models/responses.py
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: build-pr
  • GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-on-pull-request
  • GitHub Check: E2E: server mode / ci / group 3
  • GitHub Check: E2E: server mode / ci / group 1
  • GitHub Check: E2E: library mode / ci / group 2
  • GitHub Check: E2E: server mode / ci / group 2
  • GitHub Check: E2E: library mode / ci / group 1
  • GitHub Check: E2E Tests for Lightspeed Evaluation job
  • GitHub Check: E2E: library mode / ci / group 3
🧰 Additional context used
📓 Path-based instructions (7)
src/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

src/**/*.py: Use absolute imports for internal modules: from authentication import get_auth_dependency
All modules start with descriptive docstrings explaining purpose
Use logger = get_logger(__name__) from log.py for module logging
Type aliases defined at module level for clarity
Use Final[type] as type hint for all constants
All functions require docstrings with brief descriptions
Complete type annotations for function parameters and return types
Use Union types with modern syntax: str | int
Use Optional[Type] for optional type hints
Use snake_case with descriptive, action-oriented function names (get_, validate_, check_)
Avoid in-place parameter modification anti-patterns: return new data structures instead of modifying parameters
Use async def for I/O operations and external API calls
Use logger.debug() for detailed diagnostic information
Use logger.info() for general information about program execution
Use logger.warning() for unexpected events or potential problems
Use logger.error() for serious problems that prevented function execution
All classes require descriptive docstrings explaining purpose
Use PascalCase for class names with descriptive names and standard suffixes: Configuration, Error/Exception, Resolver, Interface
Abstract classes use ABC with @abstractmethod decorators
Complete type annotations for all class attributes, use specific types, not Any
Follow Google Python docstring conventions for all modules, classes, and functions
Docstring Parameters section documents function parameters
Docstring Returns section documents function return values
Docstring Raises section documents exceptions that may be raised
Use black for code formatting
Use pylint for static analysis with source-roots configuration set to "src"
Use pyright for type checking
Use ruff for fast linting
Use pydocstyle for docstring style validation
Use mypy for additional type checking
Use bandit for security issue detection

Files:

  • src/app/endpoints/metrics.py
  • src/cache/cache.py
  • src/utils/prompts.py
  • src/models/context.py
  • src/app/endpoints/config.py
  • src/models/common/responses/__init__.py
  • src/app/endpoints/info.py
  • src/models/common/responses/responses_conversation_context.py
  • src/models/common/health.py
  • src/authentication/jwk_token.py
  • src/utils/quota.py
  • src/app/endpoints/conversations_v1.py
  • src/app/endpoints/shields.py
  • src/models/common/__init__.py
  • src/models/common/mcp.py
  • src/models/api/responses/successful/configuration.py
  • src/authorization/middleware.py
  • src/models/api/responses/successful/feedback.py
  • src/utils/query.py
  • src/app/endpoints/stream_interrupt.py
  • src/models/api/responses/successful/mcp_servers.py
  • src/app/endpoints/query.py
  • src/app/endpoints/rlsapi_v1.py
  • src/utils/mcp_oauth_probe.py
  • src/models/common/moderation.py
  • src/models/requests.py
  • src/app/endpoints/conversations_v2.py
  • src/app/endpoints/root.py
  • src/cache/sqlite_cache.py
  • src/app/main.py
  • src/client.py
  • src/utils/conversations.py
  • src/cache/in_memory_cache.py
  • src/cache/postgres_cache.py
  • src/models/common/conversation.py
  • src/models/rlsapi/responses.py
  • src/models/api/responses/successful/vector_stores.py
  • src/models/api/responses/successful/catalog.py
  • src/app/endpoints/mcp_auth.py
  • src/models/common/responses/responses_api_params.py
  • src/models/api/responses/successful/query.py
  • src/models/common/responses/responses_context.py
  • src/models/api/responses/successful/probes.py
  • src/app/endpoints/tools.py
  • src/authentication/utils.py
  • src/models/api/responses/successful/prompts.py
  • src/metrics/utils.py
  • src/app/endpoints/feedback.py
  • src/models/api/responses/successful/conversations.py
  • src/utils/endpoints.py
  • src/models/cache_entry.py
  • src/utils/types.py
  • src/app/endpoints/mcp_servers.py
  • src/app/endpoints/health.py
  • src/models/api/responses/successful/bases.py
  • src/authentication/k8s.py
  • src/app/endpoints/rags.py
  • src/models/api/responses/successful/__init__.py
  • src/app/endpoints/responses.py
  • src/app/endpoints/prompts.py
  • src/app/endpoints/providers.py
  • src/app/endpoints/models.py
  • src/models/common/transcripts.py
  • src/models/common/turn_summary.py
  • src/models/api/responses/__init__.py
  • src/models/api/responses/successful/responses_openai.py
  • src/utils/responses.py
  • src/app/endpoints/streaming_query.py
  • src/utils/vector_search.py
  • src/utils/shields.py
  • src/cache/noop_cache.py
  • src/app/endpoints/authorized.py
  • src/app/endpoints/vector_stores.py
  • src/models/common/responses/types.py
  • src/utils/transcripts.py
src/app/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Use FastAPI dependencies: from fastapi import APIRouter, HTTPException, Request, status, Depends

Files:

  • src/app/endpoints/metrics.py
  • src/app/endpoints/config.py
  • src/app/endpoints/info.py
  • src/app/endpoints/conversations_v1.py
  • src/app/endpoints/shields.py
  • src/app/endpoints/stream_interrupt.py
  • src/app/endpoints/query.py
  • src/app/endpoints/rlsapi_v1.py
  • src/app/endpoints/conversations_v2.py
  • src/app/endpoints/root.py
  • src/app/main.py
  • src/app/endpoints/mcp_auth.py
  • src/app/endpoints/tools.py
  • src/app/endpoints/feedback.py
  • src/app/endpoints/mcp_servers.py
  • src/app/endpoints/health.py
  • src/app/endpoints/rags.py
  • src/app/endpoints/responses.py
  • src/app/endpoints/prompts.py
  • src/app/endpoints/providers.py
  • src/app/endpoints/models.py
  • src/app/endpoints/streaming_query.py
  • src/app/endpoints/authorized.py
  • src/app/endpoints/vector_stores.py
src/app/endpoints/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Use FastAPI HTTPException with appropriate status codes for API endpoint error handling

Files:

  • src/app/endpoints/metrics.py
  • src/app/endpoints/config.py
  • src/app/endpoints/info.py
  • src/app/endpoints/conversations_v1.py
  • src/app/endpoints/shields.py
  • src/app/endpoints/stream_interrupt.py
  • src/app/endpoints/query.py
  • src/app/endpoints/rlsapi_v1.py
  • src/app/endpoints/conversations_v2.py
  • src/app/endpoints/root.py
  • src/app/endpoints/mcp_auth.py
  • src/app/endpoints/tools.py
  • src/app/endpoints/feedback.py
  • src/app/endpoints/mcp_servers.py
  • src/app/endpoints/health.py
  • src/app/endpoints/rags.py
  • src/app/endpoints/responses.py
  • src/app/endpoints/prompts.py
  • src/app/endpoints/providers.py
  • src/app/endpoints/models.py
  • src/app/endpoints/streaming_query.py
  • src/app/endpoints/authorized.py
  • src/app/endpoints/vector_stores.py
tests/unit/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

tests/unit/**/*.py: Use pytest for all unit and integration tests
Use pytest-mock for AsyncMock objects in unit tests
Use marker pytest.mark.asyncio for async tests

Files:

  • tests/unit/app/test_main_middleware.py
  • tests/unit/models/responses/test_response_types.py
  • tests/unit/models/responses/test_types.py
  • tests/unit/app/endpoints/test_stream_interrupt.py
  • tests/unit/app/endpoints/test_prompts.py
  • tests/unit/utils/test_types.py
  • tests/unit/app/endpoints/test_shields.py
  • tests/unit/cache/test_sqlite_cache.py
  • tests/unit/app/endpoints/test_conversations_v2.py
  • tests/unit/app/endpoints/test_config.py
  • tests/unit/app/endpoints/test_responses_splunk.py
  • tests/unit/cache/test_postgres_cache.py
  • tests/unit/models/responses/test_query_response.py
  • tests/unit/app/endpoints/test_mcp_servers.py
  • tests/unit/utils/test_vector_search.py
  • tests/unit/utils/test_transcripts.py
  • tests/unit/app/endpoints/test_query.py
  • tests/unit/models/responses/test_error_responses.py
  • tests/unit/utils/test_shields.py
  • tests/unit/models/rlsapi/test_responses.py
  • tests/unit/utils/test_conversations.py
  • tests/unit/app/endpoints/test_rlsapi_v1.py
  • tests/unit/models/responses/test_rag_chunk.py
  • tests/unit/app/endpoints/test_a2a.py
  • tests/unit/utils/test_endpoints.py
  • tests/unit/models/responses/test_authorized_response.py
  • tests/unit/models/responses/test_successful_responses.py
  • tests/unit/app/endpoints/test_health.py
  • tests/unit/app/endpoints/test_responses.py
  • tests/unit/app/endpoints/test_mcp_auth.py
  • tests/unit/app/endpoints/test_streaming_query.py
  • tests/unit/app/endpoints/test_tools.py
  • tests/unit/app/endpoints/test_conversations.py
  • tests/unit/utils/test_query.py
tests/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Do not use unittest - pytest is the standard testing framework for this project

Files:

  • tests/unit/app/test_main_middleware.py
  • tests/unit/models/responses/test_response_types.py
  • tests/unit/models/responses/test_types.py
  • tests/unit/app/endpoints/test_stream_interrupt.py
  • tests/integration/test_middleware_integration.py
  • tests/unit/app/endpoints/test_prompts.py
  • tests/unit/utils/test_types.py
  • tests/unit/app/endpoints/test_shields.py
  • tests/unit/cache/test_sqlite_cache.py
  • tests/unit/app/endpoints/test_conversations_v2.py
  • tests/unit/app/endpoints/test_config.py
  • tests/unit/app/endpoints/test_responses_splunk.py
  • tests/unit/cache/test_postgres_cache.py
  • tests/unit/models/responses/test_query_response.py
  • tests/unit/app/endpoints/test_mcp_servers.py
  • tests/unit/utils/test_vector_search.py
  • tests/unit/utils/test_transcripts.py
  • tests/unit/app/endpoints/test_query.py
  • tests/unit/models/responses/test_error_responses.py
  • tests/unit/utils/test_shields.py
  • tests/unit/models/rlsapi/test_responses.py
  • tests/unit/utils/test_conversations.py
  • tests/unit/app/endpoints/test_rlsapi_v1.py
  • tests/unit/models/responses/test_rag_chunk.py
  • tests/unit/app/endpoints/test_a2a.py
  • tests/unit/utils/test_endpoints.py
  • tests/unit/models/responses/test_authorized_response.py
  • tests/unit/models/responses/test_successful_responses.py
  • tests/unit/app/endpoints/test_health.py
  • tests/integration/endpoints/test_query_byok_integration.py
  • tests/unit/app/endpoints/test_responses.py
  • tests/unit/app/endpoints/test_mcp_auth.py
  • tests/integration/endpoints/test_rlsapi_v1_integration.py
  • tests/unit/app/endpoints/test_streaming_query.py
  • tests/unit/app/endpoints/test_tools.py
  • tests/unit/app/endpoints/test_conversations.py
  • tests/unit/utils/test_query.py
src/models/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

src/models/**/*.py: Use @field_validator and @model_validator for custom validation in Pydantic models
Type hints for Pydantic models: Optional[FilePath], PositiveInt, SecretStr
Use typing_extensions.Self for model validators in Pydantic models
Pydantic config classes extend ConfigurationBase, data models extend BaseModel
Use @model_validator and @field_validator for validation in Pydantic models
Docstring Attributes section documents Pydantic model attributes

Files:

  • src/models/context.py
  • src/models/common/responses/__init__.py
  • src/models/common/responses/responses_conversation_context.py
  • src/models/common/health.py
  • src/models/common/__init__.py
  • src/models/common/mcp.py
  • src/models/api/responses/successful/configuration.py
  • src/models/api/responses/successful/feedback.py
  • src/models/api/responses/successful/mcp_servers.py
  • src/models/common/moderation.py
  • src/models/requests.py
  • src/models/common/conversation.py
  • src/models/rlsapi/responses.py
  • src/models/api/responses/successful/vector_stores.py
  • src/models/api/responses/successful/catalog.py
  • src/models/common/responses/responses_api_params.py
  • src/models/api/responses/successful/query.py
  • src/models/common/responses/responses_context.py
  • src/models/api/responses/successful/probes.py
  • src/models/api/responses/successful/prompts.py
  • src/models/api/responses/successful/conversations.py
  • src/models/cache_entry.py
  • src/models/api/responses/successful/bases.py
  • src/models/api/responses/successful/__init__.py
  • src/models/common/transcripts.py
  • src/models/common/turn_summary.py
  • src/models/api/responses/__init__.py
  • src/models/api/responses/successful/responses_openai.py
  • src/models/common/responses/types.py
src/**/__init__.py

📄 CodeRabbit inference engine (AGENTS.md)

Package __init__.py files contain brief package descriptions

Files:

  • src/models/common/responses/__init__.py
  • src/models/common/__init__.py
  • src/models/api/responses/successful/__init__.py
  • src/models/api/responses/__init__.py
🧠 Learnings (6)
📚 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/metrics.py
  • src/app/endpoints/config.py
  • src/app/endpoints/info.py
  • src/app/endpoints/conversations_v1.py
  • src/app/endpoints/shields.py
  • src/app/endpoints/stream_interrupt.py
  • src/app/endpoints/query.py
  • src/app/endpoints/rlsapi_v1.py
  • src/app/endpoints/conversations_v2.py
  • src/app/endpoints/root.py
  • src/app/endpoints/mcp_auth.py
  • src/app/endpoints/tools.py
  • src/app/endpoints/feedback.py
  • src/app/endpoints/mcp_servers.py
  • src/app/endpoints/health.py
  • src/app/endpoints/rags.py
  • src/app/endpoints/responses.py
  • src/app/endpoints/prompts.py
  • src/app/endpoints/providers.py
  • src/app/endpoints/models.py
  • src/app/endpoints/streaming_query.py
  • src/app/endpoints/authorized.py
  • src/app/endpoints/vector_stores.py
📚 Learning: 2026-01-12T10:58:40.230Z
Learnt from: blublinsky
Repo: lightspeed-core/lightspeed-stack PR: 972
File: src/models/config.py:459-513
Timestamp: 2026-01-12T10:58:40.230Z
Learning: In lightspeed-core/lightspeed-stack, for Python files under src/models, when a user claims a fix is done but the issue persists, verify the current code state before accepting the fix. Steps: review the diff, fetch the latest changes, run relevant tests, reproduce the issue, search the codebase for lingering references to the original problem, confirm the fix is applied and not undone by subsequent commits, and validate with local checks to ensure the issue is resolved.

Applied to files:

  • src/models/context.py
  • src/models/common/responses/__init__.py
  • src/models/common/responses/responses_conversation_context.py
  • src/models/common/health.py
  • src/models/common/__init__.py
  • src/models/common/mcp.py
  • src/models/api/responses/successful/configuration.py
  • src/models/api/responses/successful/feedback.py
  • src/models/api/responses/successful/mcp_servers.py
  • src/models/common/moderation.py
  • src/models/requests.py
  • src/models/common/conversation.py
  • src/models/rlsapi/responses.py
  • src/models/api/responses/successful/vector_stores.py
  • src/models/api/responses/successful/catalog.py
  • src/models/common/responses/responses_api_params.py
  • src/models/api/responses/successful/query.py
  • src/models/common/responses/responses_context.py
  • src/models/api/responses/successful/probes.py
  • src/models/api/responses/successful/prompts.py
  • src/models/api/responses/successful/conversations.py
  • src/models/cache_entry.py
  • src/models/api/responses/successful/bases.py
  • src/models/api/responses/successful/__init__.py
  • src/models/common/transcripts.py
  • src/models/common/turn_summary.py
  • src/models/api/responses/__init__.py
  • src/models/api/responses/successful/responses_openai.py
  • src/models/common/responses/types.py
📚 Learning: 2026-02-25T07:46:33.545Z
Learnt from: asimurka
Repo: lightspeed-core/lightspeed-stack PR: 1211
File: src/models/responses.py:8-16
Timestamp: 2026-02-25T07:46:33.545Z
Learning: In the Python codebase, requests.py should use OpenAIResponseInputTool as Tool while responses.py uses OpenAIResponseTool as Tool. This difference is intentional due to differing schemas for input vs output tools in llama-stack-api. Apply this distinction consistently to other models under src/models (e.g., ensure request-related tools use the InputTool variant and response-related tools use the ResponseTool variant). If adding new tools, choose the corresponding InputTool or Tool class based on whether the tool represents input or output, and document the rationale in code comments.

Applied to files:

  • src/models/context.py
  • src/models/common/responses/__init__.py
  • src/models/common/responses/responses_conversation_context.py
  • src/models/common/health.py
  • src/models/common/__init__.py
  • src/models/common/mcp.py
  • src/models/api/responses/successful/configuration.py
  • src/models/api/responses/successful/feedback.py
  • src/models/api/responses/successful/mcp_servers.py
  • src/models/common/moderation.py
  • src/models/requests.py
  • src/models/common/conversation.py
  • src/models/rlsapi/responses.py
  • src/models/api/responses/successful/vector_stores.py
  • src/models/api/responses/successful/catalog.py
  • src/models/common/responses/responses_api_params.py
  • src/models/api/responses/successful/query.py
  • src/models/common/responses/responses_context.py
  • src/models/api/responses/successful/probes.py
  • src/models/api/responses/successful/prompts.py
  • src/models/api/responses/successful/conversations.py
  • src/models/cache_entry.py
  • src/models/api/responses/successful/bases.py
  • src/models/api/responses/successful/__init__.py
  • src/models/common/transcripts.py
  • src/models/common/turn_summary.py
  • src/models/api/responses/__init__.py
  • src/models/api/responses/successful/responses_openai.py
  • src/models/common/responses/types.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
📚 Learning: 2026-04-15T18:54:07.540Z
Learnt from: Lifto
Repo: lightspeed-core/lightspeed-stack PR: 1510
File: src/models/requests.py:769-773
Timestamp: 2026-04-15T18:54:07.540Z
Learning: In lightspeed-core/lightspeed-stack request models, keep schema-level size limits defined as inline numeric literals (e.g., Pydantic Field max_length values used for validation) rather than extracting them into constants.py. Only extract values intended as configurable runtime defaults (e.g., DEFAULT_* settings like header/file upload sizes). Do not flag inline numeric literals used directly in Pydantic Field constraints or field validators as an extraction-to-constants issue.

Applied to files:

  • src/models/requests.py
📚 Learning: 2026-02-23T14:56:59.186Z
Learnt from: asimurka
Repo: lightspeed-core/lightspeed-stack PR: 1198
File: src/utils/responses.py:184-192
Timestamp: 2026-02-23T14:56:59.186Z
Learning: In the lightspeed-stack codebase (lightspeed-core/lightspeed-stack), do not enforce de-duplication of duplicate client.models.list() calls in model selection flows (e.g., in src/utils/responses.py prepare_responses_params). These calls are considered relatively cheap and removing duplicates could add unnecessary complexity to the flow. Apply this guideline specifically to this file/context unless similar performance characteristics and design decisions are documented elsewhere.

Applied to files:

  • src/utils/responses.py
🪛 GitHub Actions: OpenAPI (Spectral)
docs/openapi.json

[error] 1-1: OpenAPI schema is out of date. diff -u docs/openapi.json /tmp/openapi-generated.json failed; regenerate with: uv run python scripts/generate_openapi_schema.py docs/openapi.json.

🪛 markdownlint-cli2 (0.22.1)
src/models/api/responses/successful/README.md

[warning] 3-3: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


[warning] 6-6: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


[warning] 9-9: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


[warning] 12-12: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


[warning] 15-15: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


[warning] 18-18: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


[warning] 21-21: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


[warning] 24-24: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


[warning] 27-27: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


[warning] 30-30: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


[warning] 33-33: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


[warning] 36-36: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)

src/models/api/README.md

[warning] 6-6: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)

src/models/api/responses/README.md

[warning] 9-9: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


[warning] 12-12: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)

Comment thread docs/openapi.json Outdated
Comment thread src/app/endpoints/conversations_v2.py
Comment thread src/models/api/responses/successful/bases.py
Comment thread src/models/api/responses/successful/bases.py Outdated
Comment thread src/models/api/responses/successful/bases.py Outdated
Comment thread src/models/api/responses/successful/probes.py
Comment thread src/models/api/responses/successful/query.py
Comment thread src/models/common/mcp.py
Comment thread src/models/common/responses/__init__.py
Comment thread tests/unit/app/endpoints/test_conversations_v2.py
Copy link
Copy Markdown
Contributor

@tisnik tisnik left a comment

Choose a reason for hiding this comment

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

LGTM

@asimurka asimurka force-pushed the move_error_responses branch from ad420c2 to 5f8f41a Compare May 5, 2026 06:58
@asimurka asimurka force-pushed the move_error_responses branch from 5f8f41a to 53ff338 Compare May 5, 2026 07:10
@tisnik tisnik merged commit 8a8e1f1 into lightspeed-core:main May 5, 2026
30 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.

3 participants