Skip to content

LCORE-2755: Finalization#2175

Merged
tisnik merged 1 commit into
lightspeed-core:mainfrom
tisnik:lcore-2755-finalization
Jul 20, 2026
Merged

LCORE-2755: Finalization#2175
tisnik merged 1 commit into
lightspeed-core:mainfrom
tisnik:lcore-2755-finalization

Conversation

@tisnik

@tisnik tisnik commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Description

LCORE-2755: Finalization

Type of change

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

Tools used to create PR

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

Related Tickets & Documents

  • Related Issue #LCORE-2755

Summary by CodeRabbit

  • Documentation
    • Updated the OpenAPI schema documentation to include response API parameters and MCP tool configuration schemas.
    • Improved completeness and accuracy for clients that generate integrations from the API specification.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

dump_models() now includes InputToolMCP and ResponsesApiParams in generated OpenAPI schemas. The dumper unit test adds the ResponsesApiParams definition to its expected output and verifies the schema name.

Changes

Responses schema dump

Layer / File(s) Summary
Extend dumped model set
src/utils/models_dumper.py
Imports response models and adds InputToolMCP and ResponsesApiParams to the models passed to the dumper.
Update dumper test
tests/unit/utils/test_models_dumper.py
Adds the ResponsesApiParams schema to the expected OpenAPI JSON and verifies its presence in components.schemas.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 1 inconclusive)

Check name Status Explanation Resolution
Security And Secret Handling ❌ Error ResponsesApiParams.omit_conversation is exported in the OpenAPI dump, leaking an internal-only field (responses_api_params.py:124-132, fixture test_models_dumper.py:6267-6272). Hide omit_conversation from schema generation (or filter it in dump_openapi_schema) and regenerate the dumped-schema fixture.
Title check ❓ Inconclusive The title identifies the ticket but doesn't describe the actual schema-dump and test changes in the PR. Rename it to mention the main change, e.g. "Dump ResponsesApiParams in OpenAPI schema models".
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Performance And Algorithmic Complexity ✅ Passed No meaningful perf regression: src/utils/models_dumper.py only adds two model classes to a fixed list; dump flow stays a single schema-generation call.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

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

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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 `@src/utils/models_dumper.py`:
- Around line 139-140: Update the ResponsesApiParams schema handling so
omit_conversation is excluded from the generated OpenAPI/JSON schema while
remaining available internally for compaction. Use the model’s existing schema
configuration or the models dumper filtering path, ensuring only fields accepted
by responses.create() are publicly exported.

In `@tests/unit/utils/test_models_dumper.py`:
- Around line 6071-6283: Remove the embedded JSON schema payload from the
docstring associated with the ResponsesApiParams test, retaining only a concise
description of the test if needed. Correct the grammar from “can be dump” to
“can be dumped,” and leave the test logic and validation behavior unchanged.
🪄 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: 86e374f0-67f4-4e6b-b821-f31dbc10cfd3

📥 Commits

Reviewing files that changed from the base of the PR and between 05a32a4 and b12ebf3.

📒 Files selected for processing (2)
  • src/utils/models_dumper.py
  • tests/unit/utils/test_models_dumper.py
📜 Review details
⏰ Context from checks skipped due to timeout. (14)
  • GitHub Check: build-pr
  • GitHub Check: radon
  • GitHub Check: check_dependencies
  • GitHub Check: integration_tests (3.12)
  • GitHub Check: integration_tests (3.13)
  • GitHub Check: unit_tests (3.12)
  • GitHub Check: Pylinter
  • GitHub Check: E2E: library mode / ci / group 2
  • GitHub Check: E2E: server mode / ci / group 1
  • GitHub Check: E2E: library mode / ci / group 3
  • GitHub Check: E2E: library mode / ci / group 1
  • GitHub Check: E2E: server mode / ci / group 3
  • GitHub Check: E2E: server mode / ci / group 2
  • GitHub Check: E2E Tests for Lightspeed Evaluation job
🧰 Additional context used
📓 Path-based instructions (6)
**/*

📄 CodeRabbit inference engine (Custom checks)

**/*: Flag meaningful O(n^2)+ algorithms on non-trivial inputs, including handlers and Kubernetes list operations.
Flag N+1 patterns that list items and then query once per item, including Kubernetes API and database access.
Flag expensive work inside loops, including API calls, JSON parsing, and regex compilation.
Flag unbounded growth in caches, watchers, or buffers when eviction or limits are missing.
Flag missing pagination or limits on list operations and API endpoints.
Flag secrets or tokens logged in plaintext or hardcoded in source.
Flag API endpoints missing authentication or authorization.
Flag injection vulnerabilities, including SQL injection, command injection, and path traversal.
Flag sensitive data leaked in API responses, WebSocket messages, or logs.
Flag Kubernetes Secrets and Red Hat secrets missing OwnerReferences.

Files:

  • src/utils/models_dumper.py
  • tests/unit/utils/test_models_dumper.py
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Use absolute imports for internal Python modules.
Start every module with a descriptive docstring and use logger = get_logger(__name__) for module logging.
Define shared constants in the central constants.py module, use descriptive comments, and annotate constants with Final[type].
Use complete type annotations for function parameters and return values, modern union syntax, and typing_extensions.Self for model validators.
Document all modules, classes, and functions using Google-style Python docstrings, including applicable Parameters, Returns, Raises, and Attributes sections.
Use descriptive snake_case, action-oriented function names such as get_, validate_, and check_.
Avoid modifying input parameters in place; return a newly created data structure instead.
Use async def for I/O operations and external API calls.
Use standard logger levels appropriately: debug for diagnostics, info for normal execution, warning for unexpected conditions, and error for serious failures.
Name classes with PascalCase and use descriptive suffixes such as Configuration, Error/Exception, Resolver, and Interface where applicable.
Use ABC and @abstractmethod for abstract interfaces; provide complete, specific type annotations for class attributes and avoid Any.

Files:

  • src/utils/models_dumper.py
  • tests/unit/utils/test_models_dumper.py
src/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Configuration models must extend ConfigurationBase, whose extra="forbid" behavior rejects unknown fields; use types such as Optional[FilePath], PositiveInt, and SecretStr where appropriate.

Files:

  • src/utils/models_dumper.py
**/*.{py,yaml,yml,json,toml}

📄 CodeRabbit inference engine (AGENTS.md)

Never commit secrets or keys; use environment variables for sensitive data.

Files:

  • src/utils/models_dumper.py
  • tests/unit/utils/test_models_dumper.py
tests/unit/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Use pytest for unit tests, shared fixtures in conftest.py, pytest-mock for mocks, and pytest.mark.asyncio for asynchronous tests; do not use unittest.

Files:

  • tests/unit/utils/test_models_dumper.py
tests/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Maintain at least 60% unit-test coverage and 10% integration-test coverage.

Files:

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

Applied to files:

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

Applied to files:

  • src/utils/models_dumper.py
📚 Learning: 2026-07-17T19:25:05.325Z
Learnt from: Jdubrick
Repo: lightspeed-core/lightspeed-stack PR: 2166
File: src/utils/saved_prompts.py:129-157
Timestamp: 2026-07-17T19:25:05.325Z
Learning: For any endpoint that handles saved prompts and calls `src/utils/saved_prompts.py::create_saved_prompt`, treat the endpoint as the validation boundary. Before calling `create_saved_prompt`, validate the incoming saved-prompt name and content, specifically using `validate_saved_prompt_name` and then persist (store) the normalized value it returns. Do not call `create_saved_prompt` with unvalidated/raw name/content.

Applied to files:

  • src/utils/models_dumper.py
🔇 Additional comments (2)
src/utils/models_dumper.py (1)

8-8: LGTM!

tests/unit/utils/test_models_dumper.py (1)

9266-9266: LGTM!

Comment on lines +139 to +140
cr.InputToolMCP,
cr.ResponsesApiParams,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Prevent leaking internal fields in the exported schema.

Adding ResponsesApiParams to the OpenAPI dump exposes its internal omit_conversation field to public API clients. According to the ResponsesApiParams docstring, the dumped model should only reflect fields accepted by Llama Stack's responses.create() body, but omit_conversation is an internal lightspeed-stack flag used for compaction.

Consider hiding this internal field from the generated JSON schema (e.g., by using json_schema_extra or filtering it during schema generation) to maintain a clean and accurate public contract.

🤖 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/utils/models_dumper.py` around lines 139 - 140, Update the
ResponsesApiParams schema handling so omit_conversation is excluded from the
generated OpenAPI/JSON schema while remaining available internally for
compaction. Use the model’s existing schema configuration or the models dumper
filtering path, ensuring only fields accepted by responses.create() are publicly
exported.

Comment on lines +6071 to +6283
"ResponsesApiParams": {
"description": "Parameters for a Llama Stack Responses API request.\n\nAll fields accepted by the Llama Stack client responses.create() body are\nincluded so that dumped model can be passed directly to response create.",
"properties": {
"input": {
"$ref": "`#/components/schemas/`ResponseInput",
"description": "The input text or structured input items"
},
"model": {
"description": "The full model ID in format \"provider/model\"",
"title": "Model",
"type": "string"
},
"conversation": {
"description": "The conversation ID in llama-stack format",
"title": "Conversation",
"type": "string"
},
"include": {
"type": "array",
"nullable": true,
"default": null,
"description": "Output item types to include in the response",
"title": "Include"
},
"instructions": {
"type": "string",
"nullable": true,
"default": null,
"description": "The resolved system prompt",
"title": "Instructions"
},
"max_infer_iters": {
"type": "integer",
"nullable": true,
"default": null,
"description": "Maximum number of inference iterations",
"title": "Max Infer Iters"
},
"max_output_tokens": {
"type": "integer",
"nullable": true,
"default": null,
"description": "Maximum number of tokens allowed in the response",
"title": "Max Output Tokens"
},
"max_tool_calls": {
"type": "integer",
"nullable": true,
"default": null,
"description": "Maximum tool calls allowed in a single response",
"title": "Max Tool Calls"
},
"metadata": {
"type": "object",
"nullable": true,
"default": null,
"description": "Custom metadata for tracking or logging",
"title": "Metadata"
},
"parallel_tool_calls": {
"type": "boolean",
"nullable": true,
"default": null,
"description": "Whether the model can make multiple tool calls in parallel",
"title": "Parallel Tool Calls"
},
"previous_response_id": {
"type": "string",
"nullable": true,
"default": null,
"description": "Identifier of the previous response in a multi-turn conversation",
"title": "Previous Response Id"
},
"prompt": {
"anyOf": [
{
"$ref": "`#/components/schemas/`OpenAIResponsePrompt"
},
{
"type": "null"
}
],
"default": null,
"description": "Prompt template with variables for dynamic substitution"
},
"reasoning": {
"anyOf": [
{
"$ref": "`#/components/schemas/`OpenAIResponseReasoning"
},
{
"type": "null"
}
],
"default": null,
"description": "Reasoning configuration for the response"
},
"safety_identifier": {
"type": "string",
"nullable": true,
"default": null,
"description": "Stable identifier for safety monitoring and abuse detection",
"title": "Safety Identifier"
},
"store": {
"description": "Whether to store the response",
"title": "Store",
"type": "boolean"
},
"stream": {
"description": "Whether to stream the response",
"title": "Stream",
"type": "boolean"
},
"temperature": {
"type": "number",
"nullable": true,
"default": null,
"description": "Sampling temperature (e.g. 0.0-2.0)",
"title": "Temperature"
},
"text": {
"anyOf": [
{
"$ref": "`#/components/schemas/`OpenAIResponseText"
},
{
"type": "null"
}
],
"default": null,
"description": "Text response configuration (format constraints)"
},
"tool_choice": {
"anyOf": [
{
"$ref": "`#/components/schemas/`OpenAIResponseInputToolChoiceMode"
},
{
"discriminator": {
"mapping": {
"allowed_tools": "`#/components/schemas/`OpenAIResponseInputToolChoiceAllowedTools",
"custom": "`#/components/schemas/`OpenAIResponseInputToolChoiceCustomTool",
"file_search": "`#/components/schemas/`OpenAIResponseInputToolChoiceFileSearch",
"function": "`#/components/schemas/`OpenAIResponseInputToolChoiceFunctionTool",
"mcp": "`#/components/schemas/`OpenAIResponseInputToolChoiceMCPTool",
"web_search": "`#/components/schemas/`OpenAIResponseInputToolChoiceWebSearch",
"web_search_2025_08_26": "`#/components/schemas/`OpenAIResponseInputToolChoiceWebSearch",
"web_search_preview": "`#/components/schemas/`OpenAIResponseInputToolChoiceWebSearch",
"web_search_preview_2025_03_11": "`#/components/schemas/`OpenAIResponseInputToolChoiceWebSearch"
},
"propertyName": "type"
},
"oneOf": [
{
"$ref": "`#/components/schemas/`OpenAIResponseInputToolChoiceAllowedTools"
},
{
"$ref": "`#/components/schemas/`OpenAIResponseInputToolChoiceFileSearch"
},
{
"$ref": "`#/components/schemas/`OpenAIResponseInputToolChoiceWebSearch"
},
{
"$ref": "`#/components/schemas/`OpenAIResponseInputToolChoiceFunctionTool"
},
{
"$ref": "`#/components/schemas/`OpenAIResponseInputToolChoiceMCPTool"
},
{
"$ref": "`#/components/schemas/`OpenAIResponseInputToolChoiceCustomTool"
}
]
},
{
"type": "null"
}
],
"default": null,
"description": "Tool selection strategy",
"title": "Tool Choice"
},
"tools": {
"type": "array",
"nullable": true,
"default": null,
"description": "Prepared tool groups for Responses API (same type as ResponsesRequest.tools)",
"title": "Tools"
},
"extra_headers": {
"type": "object",
"nullable": true,
"default": null,
"description": "Extra HTTP headers to send with the request (e.g. x-llamastack-provider-data)",
"title": "Extra Headers"
},
"omit_conversation": {
"default": false,
"description": "When True, the conversation parameter is dropped from the request body while remaining on the object for identity. Set by conversation compaction (LCORE-1572): once a conversation is compacted, lightspeed-stack supplies explicit input and must not let Llama Stack reload the full history via the conversation parameter.",
"title": "Omit Conversation",
"type": "boolean"
}
},
"required": [
"input",
"model",
"conversation",
"store",
"stream"
],
"title": "ResponsesApiParams",
"type": "object"
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Remove the massive JSON schema from the docstring and fix grammar.

Maintaining a ~9,000-line JSON string inside a test function's docstring is a significant maintainability burden. It bloats the file, causes unnecessary merge conflicts (as seen in this PR), and serves no functional purpose since the test logic does not actually parse or validate this docstring text. Additionally, there is a minor grammatical error (can be dump instead of can be dumped).

Please consider removing the JSON payload from the docstring completely to adhere to KISS principles.

♻️ Proposed refactor
 def test_dump_models(tmpdir: Path) -> None:
-    """Test that models can be dump into a JSON file.
-
-    An example of schema dump:
-    {
-        ...
-    }
-    """
+    """Test that models can be dumped into a JSON file."""
     filename = tmpdir / "foo.json"
🤖 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 `@tests/unit/utils/test_models_dumper.py` around lines 6071 - 6283, Remove the
embedded JSON schema payload from the docstring associated with the
ResponsesApiParams test, retaining only a concise description of the test if
needed. Correct the grammar from “can be dump” to “can be dumped,” and leave the
test logic and validation behavior unchanged.

@tisnik
tisnik merged commit 8548f45 into lightspeed-core:main Jul 20, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant