Skip to content

LCORE-4701: Implemented llm settings resolver - #3136

Merged
tisnik merged 1 commit into
lightspeed-core:mainfrom
asimurka:initialize-providers-registry
Nov 4, 2026
Merged

tisnik merged 1 commit into
lightspeed-core:mainfrom
asimurka:initialize-providers-registry

Conversation

@asimurka

@asimurka asimurka commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds shared LlmRunSettings under providers/inference to map OpenResponses generation/loop-limit fields to Pydantic AI ModelSettings and UsageLimits. Includes unit tests and README updates. Not wired into handlers yet.

Note: This is not the only PR related to this issue.

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up service version
  • Bump-up dependent library [pyproject.toml + uv.lock]
  • Bump-up dependent library [requirements.*.txt for Konflux]
  • 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: Cursor (Composer)
  • Generated 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

  1. uv run make format
  2. uv run make verify
  3. uv run make test-unit — tests/unit/providers/inference/test_llm_settings.py

Summary by CodeRabbit

  • New Features
    • Added support for configuring AI response generation options, reasoning and text preferences, and limits on tool calls and inference steps.
    • Responses-style request settings can now be carried into inference configuration, including reasoning effort and summary preferences. Unset options are omitted, while explicitly disabled options are preserved.

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration
Commits

Reviewing files that changed from the base of the PR and between a05442a and c4b4cd8.

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:

  • Trigger review

Walkthrough

The inference provider adds LlmRunSettings to map Responses request fields into model settings and usage limits. Unit tests cover field extraction, serialization, and limit behavior.

Changes

LLM run settings

Layer / File(s) Summary
Settings model, conversion, and validation
src/providers/inference/llm_settings.py, tests/unit/providers/inference/test_llm_settings.py, src/providers/inference/README.md, tests/unit/providers/inference/README.md
Adds request-setting extraction, model-settings serialization, and usage-limit conversion. Unit tests cover mapped fields, omitted values, explicit False, and limit defaults. Directory READMEs list the new module and tests.

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

Change: Other

Suggested reviewers: tisnik

Merge Risk: Low · previous review a0544

The new settings resolver is not yet used by any handler, so merging it changes no runtime behavior today. Before it is wired in, the response-wide output-token limit should also be mapped to the run-wide usage limit.

Pre-merge checks: Passed 7
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the implementation of the LLM settings resolver, which matches the main change.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
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 performance regression is introduced. The new resolver processes a fixed set of 10 fields, uses one bounded Pydantic serialization call, and has no loops over request items, API calls, l…
Security And Secret Handling Passed The changed code adds a settings mapper and unit tests only. LlmRunSettings copies request values into typed fields and serializes them into ModelSettings/UsageLimits; it does not log, hardcode,…
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 2 files. (2 skipped: 2 unsupported.)

Full details: Performance And Algorithmic Complexity

Explanation

No meaningful performance regression is introduced. The new resolver processes a fixed set of 10 fields, uses one bounded Pydantic serialization call, and has no loops over request items, API calls, list operations, unbounded state, or cache growth. The PR does not wire the resolver into handlers.

Full details: Security And Secret Handling

Explanation

The changed code adds a settings mapper and unit tests only. LlmRunSettings copies request values into typed fields and serializes them into ModelSettings/UsageLimits; it does not log, hardcode, expose, or execute secret-bearing values. No API endpoint, Kubernetes Secret, SQL/command/path operation, or response/logging path changes in the reviewed diff.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
Simplify code
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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
Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 1aee84a and a05442a.

Files selected for processing: 4
  • src/providers/inference/README.md
  • src/providers/inference/llm_settings.py
  • tests/unit/providers/inference/README.md
  • tests/unit/providers/inference/test_llm_settings.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Recent review details
Context from checks skipped due to timeout: 27
  • GitHub Check: Red Hat Konflux / rag-content-0-8-e2e-tests / lightspeed-stack-0-8
  • GitHub Check: mypy
  • GitHub Check: unit_tests (3.12)
  • GitHub Check: list_outdated_dependencies
  • GitHub Check: ruff
  • GitHub Check: integration_tests (3.12)
  • GitHub Check: unit_tests (3.14)
  • GitHub Check: pydocstyle
  • GitHub Check: integration_tests (3.13)
  • GitHub Check: Pylinter
  • GitHub Check: check_dependencies
  • GitHub Check: unit_tests (3.13)
  • GitHub Check: radon
  • GitHub Check: build-pr
  • GitHub Check: dispatch / Route
  • GitHub Check: integration_tests (3.14)
  • GitHub Check: spectral
  • GitHub Check: Pyright
  • GitHub Check: Red Hat Konflux / lightspeed-core-0-8-enterprise-contract / lightspeed-stack-0-8
  • GitHub Check: dispatch / Harness dispatch
  • GitHub Check: bandit
  • GitHub Check: shellcheck
  • GitHub Check: black
  • GitHub Check: check
  • GitHub Check: authorize / Check repository owner or member
  • GitHub Check: Red Hat Konflux / lightspeed-stack-0-8-e2e-tests / lightspeed-stack-0-8
  • GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-0-8-on-pull-request
Additional context used
Code guidelines: 2
CLAUDE.md — auto-discovered
AGENTS.md — auto-discovered
Path-based instructions: 3
Source excerpt: **Required**: Use pytest for all unit and integration tests **Forbidden**: Do not use unittest - pytest is the standard for this project Source excerpt: **Coverage**: Unit tests require 60% coverage, integration 10%

CodeRabbit inference engine (CLAUDE.md)

Files:

  • tests/unit/providers/inference/README.md
  • tests/unit/providers/inference/test_llm_settings.py
Source excerpt: **Required**: Use pytest for all unit and integration tests Source excerpt: **Forbidden**: Do not use unittest - pytest is the standard for this project Source excerpt: **Coverage**: Unit tests require 60% coverage, integrat...

CodeRabbit inference engine (AGENTS.md)

Files:

  • tests/unit/providers/inference/README.md
  • tests/unit/providers/inference/test_llm_settings.py
Source excerpt: **Fixtures**: Use `conftest.py` for shared fixtures Source excerpt: **Mocking**: `pytest-mock` for AsyncMock objects Source excerpt: **Async tests**: Use marker `pytest.mark.asyncio`

CodeRabbit inference engine (CLAUDE.md)

Files:

  • tests/unit/providers/inference/README.md
  • tests/unit/providers/inference/test_llm_settings.py
Additional comments: 3
tests/unit/providers/inference/test_llm_settings.py: 1

15-165: LGTM!

src/providers/inference/README.md: 1

31-34: LGTM!

tests/unit/providers/inference/README.md: 1

35-38: LGTM!

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

  • Fix comments: Fix CodeRabbit comments on this PR

Comment thread src/providers/inference/llm_settings.py Resolved
@fullsend-ai-review

fullsend-ai-review Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 1:35 PM UTC · Completed 1:51 PM UTC

Commit: a05442a · View workflow run →

Runtime: pi · Model: opus → claude-opus-4-6 · Effort: high · Cost: $5.56

@fullsend-ai-review fullsend-ai-review Bot added the risk/low PR risk: low label Nov 3, 2026
@fullsend-ai-review

fullsend-ai-review Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

<!-- fullsend:risk-assessment -->
Risk Assessment: low (1/5)

Details

Low-risk PR adding 2 new source files (LLM settings resolver + unit tests) and 2 README updates. Small scope (4 files, 296 lines), no protected paths, no security-sensitive paths, no CI or dependency changes. All files are net-new with no prior churn. Anchored to prior score of 1.

Previous run

<!-- fullsend:risk-assessment -->
Risk Assessment: low (1/5)

Details

Low-risk PR adding 2 new source files (llm_settings resolver + unit tests) and 2 README updates. Small scope (4 files, 296 lines), no protected paths, no security-sensitive paths, no CI or dependency changes.

@fullsend-ai-review

fullsend-ai-review Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Review

Findings

Low

  • [missing-test] tests/unit/providers/inference/test_llm_settings.py — No test verifies that thinking=False (mapped from effort="none") survives the round-trip through to_model_settings(). The test test_from_responses_maps_reasoning_none_to_thinking_false only asserts settings.thinking is False but never calls to_model_settings(). Since exclude_none=True is used in model_dump, it is important to confirm that False (a falsy but non-None value) appears as {"thinking": False} in the output dict.

  • [test-inadequate] tests/unit/providers/inference/test_llm_settings.py:109 — The test test_to_usage_limits_preserves_default_request_limit hardcodes assert limits.request_limit == 50, coupling the test to pydantic-ai's internal default for UsageLimits.request_limit. If pydantic-ai changes that default in a future version, this test will break without any production code change.

  • [pattern-inconsistency] src/providers/inference/llm_settings.py:17 — The module-level constant _USAGE_EXCLUDE is missing the Final annotation required by project convention (AGENTS.md: "Use Final[type] as type hint for all constants"). Existing package constants follow this pattern (e.g. PROVIDER_CLASSES: Final[...] in registry.py). Additionally, ReasoningSummary and TextVerbosity type aliases are defined inline rather than in types.py, which is acceptable while only used locally.
    Remediation: Add Final to the typing import and annotate: _USAGE_EXCLUDE: Final[set[str]] = {"max_tool_calls", "max_infer_iters"}

Earlier findings

  • src/providers/inference/llm_settings.py pattern-inconsistency — reclassified from info to low (finding now also covers missing Final annotation per project convention)

Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR
Previous run

<!-- fullsend:review-findings-v2:eyJ2ZXJzaW9uIjoyLCJhY3Rpb24iOiJyZXF1ZXN0LWNoYW5nZXMiLCJmaW5kaW5ncyI6W3sic2V2ZXJpdHkiOiJsb3ciLCJjYXRlZ29yeSI6Im1pc3NpbmctdGVzdCIsImZpbGUiOiJ0ZXN0cy91bml0L3Byb3ZpZGVycy9pbmZlcmVuY2UvdGVzdF9sbG1fc2V0dGluZ3MucHkiLCJpZCI6ImZfZTgxMzAzOTU1NjUxY2E2YyIsImFjdGlvbmFibGUiOnRydWV9LHsic2V2ZXJpdHkiOiJsb3ciLCJjYXRlZ29yeSI6InRlc3QtaW5hZGVxdWF0ZSIsImZpbGUiOiJ0ZXN0cy91bml0L3Byb3ZpZGVycy9pbmZlcmVuY2UvdGVzdF9sbG1fc2V0dGluZ3MucHkiLCJpZCI6ImZfZDM1OTk0Njc1ZTk3YzljMyIsImxpbmUiOjEwOSwiYWN0aW9uYWJsZSI6dHJ1ZX0seyJzZXZlcml0eSI6ImluZm8iLCJjYXRlZ29yeSI6InBhdHRlcm4taW5jb25zaXN0ZW5jeSIsImZpbGUiOiJzcmMvcHJvdmlkZXJzL2luZmVyZW5jZS9sbG1fc2V0dGluZ3MucHkiLCJpZCI6ImZfZDg1ZWExZTVkZDI4NWM3OCIsImxpbmUiOjE0LCJhY3Rpb25hYmxlIjpmYWxzZX0seyJzZXZlcml0eSI6ImluZm8iLCJjYXRlZ29yeSI6ImRlc2lnbi1kaXJlY3Rpb24iLCJmaWxlIjoic3JjL3Byb3ZpZGVycy9pbmZlcmVuY2UvbGxtX3NldHRpbmdzLnB5IiwiaWQiOiJmXzJlZmEwZWY5ZWY0ZTc2NWYiLCJhY3Rpb25hYmxlIjpmYWxzZX1dfQ== -->

Review

Findings

Low

  • [missing-test] tests/unit/providers/inference/test_llm_settings.py — No test covers the end-to-end path where effort="none" produces thinking=False which then flows through to_model_settings() emitting {"thinking": False}. The existing test_from_responses_maps_reasoning_none_to_thinking_false test only verifies the attribute is False but never calls to_model_settings() to confirm it appears in the serialized output (since False is not None, it will survive exclude_none=True).
    Remediation: Add a test that calls from_responses_request with effort='none' and then asserts to_model_settings() includes {"thinking": False}.

  • [test-inadequate] tests/unit/providers/inference/test_llm_settings.py:109 — The test test_to_usage_limits_preserves_default_request_limit hardcodes 50 as the expected default value of UsageLimits.request_limit. This couples the test to an implementation detail of pydantic-ai's UsageLimits class.
    Remediation: Assert against UsageLimits().request_limit instead of the magic number 50.

Info

  • [pattern-inconsistency] src/providers/inference/llm_settings.py:14 — Module-level type aliases ReasoningSummary and TextVerbosity are defined in llm_settings.py, but the established pattern in this package is to define shared literals and type aliases in types.py. If these aliases will be consumed by other modules, consider moving them.

  • [design-direction] src/providers/inference/llm_settings.py — Placing LlmRunSettings under providers/inference/ is a reasonable fit: it bridges provider-level request parameters to the Pydantic AI run configuration. The module follows project conventions. Not yet wired into any handler, consistent with the stated incremental rollout.


Labels: New feature PR adding inference provider settings with tests


Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR

fullsend-ai-review[bot]

This comment was marked as outdated.

@fullsend-ai-review fullsend-ai-review Bot added enhancement New feature or request Review effort 2/5 labels Nov 3, 2026
@asimurka
asimurka force-pushed the initialize-providers-registry branch from a05442a to c4b4cd8 Compare November 4, 2026 07:22
@fullsend-ai-review

fullsend-ai-review Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 7:24 AM UTC · Completed 7:47 AM UTC

Commit: c4b4cd8 · View workflow run →

Runtime: pi · Model: opus → claude-opus-4-6 · Effort: high · Cost: $6.18

@fullsend-ai-review fullsend-ai-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

See the review comment for full details.

Comment thread src/providers/inference/llm_settings.py Resolved

@tisnik tisnik 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.

LGTM

@tisnik
tisnik merged commit c080f06 into lightspeed-core:main Nov 4, 2026
60 of 64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Review effort 2/5 risk/low PR risk: low

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants