Skip to content

LCORE-1583: Allowed reasoning and max_output_tokens attributes#1483

Draft
asimurka wants to merge 1 commit intolightspeed-core:mainfrom
asimurka:allow_responses_attributes
Draft

LCORE-1583: Allowed reasoning and max_output_tokens attributes#1483
asimurka wants to merge 1 commit intolightspeed-core:mainfrom
asimurka:allow_responses_attributes

Conversation

@asimurka
Copy link
Copy Markdown
Contributor

@asimurka asimurka commented Apr 10, 2026

Description

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: N/A

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

  • Bug Fixes

    • Restored proper handling of response request parameters so provided values are no longer cleared.
  • New Features

    • Added an optional safety identifier parameter to responses requests for improved safety monitoring.
  • Tests

    • Updated response feature tests and removed outdated scenarios to reflect current behavior.

@asimurka asimurka marked this pull request as draft April 10, 2026 13:07
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 10, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 93e5d572-5128-4943-a331-5ecbd60ce75c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)

Walkthrough

These changes remove deprecated field-clearing logic from the responses endpoint handler and streamline test configurations by eliminating a skipped test scenario, removing unsupported tool_choice parameters from response assertions, and pruning e2e feature entries from the test list.

Changes

Cohort / File(s) Summary
Endpoint Handler
src/app/endpoints/responses.py
Removed logic that forcibly cleared unsupported LCORE fields (reasoning and max_output_tokens) with warning logs. Function now only performs deep copy before configuration checks and prompt transformations.
Test Updates
tests/e2e/features/responses.feature, tests/e2e/test_list.txt
Removed skipped test scenario for LCORE-1583. Updated "Responses accepts passthrough parameters" scenario by removing tool_choice: "auto" field from both request and expected response assertions. Removed 22 e2e feature entries from test list, retaining only responses.feature.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title describes allowing reasoning and max_output_tokens attributes, but the changeset actually removes the logic that cleared/blocked these attributes, making the title potentially misleading about the implementation approach. Consider revising the title to more accurately reflect the change, such as 'Remove unsupported LCORE field validation from responses handler' or 'Stop clearing reasoning and max_output_tokens in responses endpoint' to better represent the actual code modification.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 and usage tips.

@asimurka asimurka force-pushed the allow_responses_attributes branch from 7cd8248 to e89b907 Compare April 10, 2026 14:07
@tisnik
Copy link
Copy Markdown
Contributor

tisnik commented Apr 13, 2026

PR Reviewer Guide 🔍

(Review updated until commit e89b907)

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

AGENTS.md compliance

The PR title indicates allowing the reasoning attribute, but the handler still unconditionally strips and ignores incoming reasoning, which conflicts with instructions to support it.

if responses_request.reasoning is not None:
    logger.warning("reasoning is not yet supported in LCORE and will be ignored")
    responses_request.reasoning = None
Missing parameter definition

Although support for max_output_tokens was restored in the endpoint, there is no corresponding field in the ResponsesApiParams model, so requests including max_output_tokens will be rejected.

reasoning: Optional[Reasoning] = Field(
    default=None,
    description="Reasoning configuration for the response",
)
safety_identifier: Optional[str] = Field(
    default=None,
    description="Stable identifier for safety monitoring and abuse detection",
)
Duplicate key

The use_as_library_client key is defined twice with conflicting values; only the latter takes effect, making the configuration ambiguous.

use_as_library_client: true
library_client_config_path: run.yaml

@tisnik
Copy link
Copy Markdown
Contributor

tisnik commented Apr 13, 2026

Persistent review updated to latest commit e89b907

@tisnik
Copy link
Copy Markdown
Contributor

tisnik commented Apr 13, 2026

Persistent review updated to latest commit e89b907

@tisnik
Copy link
Copy Markdown
Contributor

tisnik commented Apr 14, 2026

@coderabbitai help

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 14, 2026

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

CodeRabbit commands

These commands are invoked using PR/Issue comments.

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai evaluate custom pre-merge check --instructions <custom-checks-instructions> --name <custom-checks-title> [--mode <error|warning>] to validate the custom pre-merge checks instructions. Defaults to error when --mode is omitted.
  • @coderabbitai ignore pre-merge checks to override pre-merge checks and get an approval on PR.
  • @coderabbitai run pre-merge checks to run pre-merge checks on the pull request.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve merge conflict to automatically resolve merge conflicts.
  • @coderabbitai autofix to automatically fix issues identified in unresolved review comments.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai generate configuration to create a PR that adds the current resolved configuration as .coderabbit.yaml (or show it if already present).
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, support, documentation and community

  • Visit our status page to check the current availability of CodeRabbit.
  • Create a ticket on our support page for assistance with any issues or questions.
  • Visit our documentation site for detailed information on how to use CodeRabbit.
  • Join our Discord community to connect with other users and get help from the community.
  • Follow us on X/Twitter for updates and announcements.

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: 2

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

Inline comments:
In `@lightspeed-stack.yaml`:
- Around line 13-15: The YAML contains a duplicated key use_as_library_client
with conflicting values (false and true); remove one of the entries so the map
contains a single use_as_library_client key with the intended boolean value,
ensuring the remaining value reflects the desired behavior and resolving the
parser/lint error.

In `@src/app/endpoints/responses.py`:
- Around line 165-170: The code currently nulls out responses_request.reasoning
(responses_request.reasoning = None) and mutates the input before copying,
preventing the field from reaching ResponsesApiParams.model_validate(...) and
client.responses.create(...); remove the in-place assignment so reasoning is
preserved, log a warning if present but do not modify responses_request, and
ensure you perform the deep copy (responses_request =
responses_request.model_copy(deep=True)) before any non-mutating checks or logs
so the original object is not altered and the reasoning value is passed through
to downstream validation and client.responses.create.
🪄 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: 8abc4275-a00c-4ee0-8518-6e7140b44683

📥 Commits

Reviewing files that changed from the base of the PR and between 7cd8248 and e89b907.

📒 Files selected for processing (6)
  • lightspeed-stack.yaml
  • run.yaml
  • src/app/endpoints/responses.py
  • src/utils/types.py
  • tests/e2e/features/responses.feature
  • tests/e2e/test_list.txt
💤 Files with no reviewable changes (3)
  • run.yaml
  • tests/e2e/test_list.txt
  • tests/e2e/features/responses.feature
📜 Review details
🧰 Additional context used
📓 Path-based instructions (2)
src/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

src/**/*.py: Use absolute imports for internal modules (e.g., from authentication import get_auth_dependency)
Use from llama_stack_client import AsyncLlamaStackClient for Llama Stack imports
Check constants.py for shared constants before defining new ones
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
All functions require docstrings with brief descriptions
Use complete type annotations for function parameters and return types
Use union types with modern syntax: str | int instead of Union[str, int]
Use Optional[Type] for optional types in type annotations
Use snake_case with descriptive, action-oriented names for functions (get_, validate_, check_)
Avoid in-place parameter modification anti-patterns: return new data structures instead of modifying parameters
Use async def for I/O operations and external API calls
Handle APIConnectionError from Llama Stack in error handling
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
Use complete type annotations for all class attributes; avoid using Any
Follow Google Python docstring conventions for all modules, classes, and functions
Include Parameters:, Returns:, Raises: sections in function docstrings as needed

Files:

  • src/app/endpoints/responses.py
  • src/utils/types.py
src/app/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

src/app/**/*.py: Use from fastapi import APIRouter, HTTPException, Request, status, Depends for FastAPI dependencies
Use FastAPI HTTPException with appropriate status codes for API endpoint error handling

Files:

  • src/app/endpoints/responses.py
🧠 Learnings (3)
📚 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/responses.py
📚 Learning: 2025-12-18T10:21:09.038Z
Learnt from: are-ces
Repo: lightspeed-core/lightspeed-stack PR: 935
File: run.yaml:114-115
Timestamp: 2025-12-18T10:21:09.038Z
Learning: In Llama Stack version 0.3.x, telemetry provider configuration is not supported under the `providers` section in run.yaml configuration files. Telemetry can be enabled with just `telemetry.enabled: true` without requiring an explicit provider block.

Applied to files:

  • lightspeed-stack.yaml
📚 Learning: 2026-04-05T12:19:36.009Z
Learnt from: CR
Repo: lightspeed-core/lightspeed-stack PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-05T12:19:36.009Z
Learning: Applies to src/**/*.py : Use `from llama_stack_client import AsyncLlamaStackClient` for Llama Stack imports

Applied to files:

  • lightspeed-stack.yaml
🪛 YAMLlint (1.38.0)
lightspeed-stack.yaml

[error] 15-15: duplication of key "use_as_library_client" in mapping

(key-duplicates)

🔇 Additional comments (2)
lightspeed-stack.yaml (1)

16-18: Library mode wiring looks correct once the duplicate key is removed.

library_client_config_path: run.yaml plus disabled URL/API key matches the intended library-client startup path.

src/utils/types.py (1)

217-220: Good contract alignment for safety_identifier passthrough.

This field addition cleanly matches the request/response models and allows forwarding without special-case logic.

Comment thread lightspeed-stack.yaml
Comment on lines 13 to +15
use_as_library_client: false
# Alternative for "as library use"
# use_as_library_client: true
# library_client_config_path: <path-to-llama-stack-run.yaml-file>
url: http://llama-stack:8321
api_key: xyzzy
use_as_library_client: true
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.

⚠️ Potential issue | 🟠 Major

Remove duplicated use_as_library_client key (conflicting values).

This map defines use_as_library_client twice (false then true). It is ambiguous, fails lint, and parser behavior can differ. Keep only one value.

Suggested fix
 llama_stack:
-  # Uses a remote llama-stack service
-  # The instance would have already been started with a llama-stack-run.yaml file
-  use_as_library_client: false
-  # Alternative for "as library use"
+  # Use llama-stack in library-client mode
   use_as_library_client: true
   library_client_config_path: run.yaml
   # url: http://llama-stack:8321
   # api_key: xyzzy
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
use_as_library_client: false
# Alternative for "as library use"
# use_as_library_client: true
# library_client_config_path: <path-to-llama-stack-run.yaml-file>
url: http://llama-stack:8321
api_key: xyzzy
use_as_library_client: true
llama_stack:
# Use llama-stack in library-client mode
use_as_library_client: true
library_client_config_path: run.yaml
# url: http://llama-stack:8321
# api_key: xyzzy
🧰 Tools
🪛 YAMLlint (1.38.0)

[error] 15-15: duplication of key "use_as_library_client" in mapping

(key-duplicates)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lightspeed-stack.yaml` around lines 13 - 15, The YAML contains a duplicated
key use_as_library_client with conflicting values (false and true); remove one
of the entries so the map contains a single use_as_library_client key with the
intended boolean value, ensuring the remaining value reflects the desired
behavior and resolving the parser/lint error.

Comment on lines 165 to +170
if responses_request.reasoning is not None:
logger.warning("reasoning is not yet supported in LCORE and will be ignored")
responses_request.reasoning = None
if responses_request.max_output_tokens is not None:
logger.warning(
"max_output_tokens is not yet supported in LCORE and will be ignored"
)
responses_request.max_output_tokens = None

responses_request = responses_request.model_copy(deep=True)

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.

⚠️ Potential issue | 🔴 Critical

Do not strip reasoning; this currently breaks the advertised passthrough behavior.

Line 165-Line 167 still nullifies responses_request.reasoning, so the field can never reach ResponsesApiParams.model_validate(...) (Line 302/Line 657) or client.responses.create(...). This contradicts LCORE-1583 and also mutates the request object in place before the copy on Line 169.

✅ Suggested fix
-    # Known LLS bug: https://redhat.atlassian.net/browse/LCORE-1583
-    if responses_request.reasoning is not None:
-        logger.warning("reasoning is not yet supported in LCORE and will be ignored")
-        responses_request.reasoning = None
-
-    responses_request = responses_request.model_copy(deep=True)
+    responses_request = responses_request.model_copy(deep=True)

As per coding guidelines "Avoid in-place parameter modification anti-patterns: return new data structures instead of modifying parameters".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/app/endpoints/responses.py` around lines 165 - 170, The code currently
nulls out responses_request.reasoning (responses_request.reasoning = None) and
mutates the input before copying, preventing the field from reaching
ResponsesApiParams.model_validate(...) and client.responses.create(...); remove
the in-place assignment so reasoning is preserved, log a warning if present but
do not modify responses_request, and ensure you perform the deep copy
(responses_request = responses_request.model_copy(deep=True)) before any
non-mutating checks or logs so the original object is not altered and the
reasoning value is passed through to downstream validation and
client.responses.create.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants