Skip to content

LCORE-1861: config toggle for degraded mode#1777

Merged
tisnik merged 2 commits into
lightspeed-core:mainfrom
tisnik:lcore-1861-config-toggle-for-degraded-mode
May 21, 2026
Merged

LCORE-1861: config toggle for degraded mode#1777
tisnik merged 2 commits into
lightspeed-core:mainfrom
tisnik:lcore-1861-config-toggle-for-degraded-mode

Conversation

@tisnik
Copy link
Copy Markdown
Contributor

@tisnik tisnik commented May 21, 2026

Description

LCORE-1861: config toggle for degraded mode

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-1861

Summary by CodeRabbit

Release Notes

  • New Features

    • Added allow_degraded_mode configuration option to enable Lightspeed Core startup even when Llama Stack is unavailable (server mode only).
  • Documentation

    • Updated configuration schema documentation to reflect the new option.
  • Tests

    • Added unit tests to validate the new configuration field behavior.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 21, 2026

Warning

Rate limit exceeded

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

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ 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: 9e5796a8-66fa-4056-b817-bcdaa7a6f792

📥 Commits

Reviewing files that changed from the base of the PR and between 8019005 and 914c32e.

📒 Files selected for processing (2)
  • tests/unit/models/config/test_dump_configuration.py
  • tests/unit/models/config/test_llama_stack_configuration.py

Walkthrough

A new optional boolean configuration field allow_degraded_mode is added to LlamaStackConfiguration to permit Lightspeed Core startup when Llama Stack is unreachable (server mode only). The change includes model definition, schema/documentation updates in multiple formats, and comprehensive test coverage.

Changes

Add allow_degraded_mode Configuration Field

Layer / File(s) Summary
Configuration field definition
src/models/config.py
LlamaStackConfiguration gains allow_degraded_mode: Optional[bool] with default False and validation metadata for server mode only.
Schema and API documentation
docs/config.html, docs/config.json, docs/config.md, docs/openapi.json
New field is documented across HTML configuration table, OpenAPI schema definitions, JSON schema, and markdown config documentation with consistent descriptions and defaults.
Unit test coverage
tests/unit/models/config/test_llama_stack_configuration.py, tests/unit/models/config/test_dump_configuration.py
Constructor test refactored to use pytest_subtests with assertions for allow_degraded_mode default and enabled states. Existing dump tests updated to expect the new field; new test validates round-trip serialization with allow_degraded_mode=True.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'LCORE-1861: config toggle for degraded mode' directly and clearly summarizes the main change: adding a configuration toggle for degraded mode functionality.
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.

✏️ 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.

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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/models/config.py`:
- Around line 704-709: The new allow_degraded_mode field is documented as “valid
for server mode only” but check_llama_stack_model currently allows
allow_degraded_mode=True when use_as_library_client=True; update
check_llama_stack_model to explicitly reject this combination
(use_as_library_client True + allow_degraded_mode True) by raising a clear
validation error (or ValueError) with a helpful message pointing out that
allow_degraded_mode is only allowed in server mode; reference the
allow_degraded_mode field and the check_llama_stack_model and
use_as_library_client symbols when implementing the guard so the invalid config
is rejected early.

In `@tests/unit/models/config/test_dump_configuration.py`:
- Around line 1414-1419: Test config uses library mode while setting
allow_degraded_mode which is server-only; change
LlamaStackConfiguration(use_as_library_client=True, ...) to
use_as_library_client=False to represent server mode and then update the test's
expected serialized output to reflect server-mode fields (the serialized block
that contains the llama_stack section) so the assertion matches the new
server-mode representation.
🪄 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: 10318362-5b51-4577-9a51-1ecdc50eba8b

📥 Commits

Reviewing files that changed from the base of the PR and between 30b82a6 and 8019005.

📒 Files selected for processing (7)
  • docs/config.html
  • docs/config.json
  • docs/config.md
  • docs/openapi.json
  • src/models/config.py
  • tests/unit/models/config/test_dump_configuration.py
  • tests/unit/models/config/test_llama_stack_configuration.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). (7)
  • GitHub Check: E2E: server mode / ci / group 3
  • GitHub Check: E2E: library mode / ci / group 1
  • GitHub Check: E2E: server mode / ci / group 2
  • GitHub Check: E2E: server mode / ci / group 1
  • GitHub Check: E2E: library mode / ci / group 3
  • GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-on-pull-request
  • GitHub Check: E2E Tests for Lightspeed Evaluation job
🧰 Additional context used
📓 Path-based instructions (3)
src/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

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

Files:

  • src/models/config.py
src/models/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Pydantic models must use @model_validator and @field_validator for validation and complete type annotations for all attributes, avoiding Any type

Files:

  • src/models/config.py
tests/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

tests/**/*.py: Use pytest for all unit and integration tests; do not use unittest
Use pytest.mark.asyncio marker for async tests

Files:

  • tests/unit/models/config/test_llama_stack_configuration.py
  • tests/unit/models/config/test_dump_configuration.py
🧠 Learnings (2)
📚 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/config.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/config.py
🔇 Additional comments (6)
docs/config.html (1)

1118-1123: LGTM!

docs/config.json (1)

923-929: LGTM!

docs/config.md (1)

430-430: LGTM!

docs/openapi.json (1)

13852-13864: LGTM!

tests/unit/models/config/test_llama_stack_configuration.py (1)

11-59: LGTM!

tests/unit/models/config/test_dump_configuration.py (1)

163-163: LGTM!

Also applies to: 514-514, 764-764, 994-994, 1214-1214

Comment thread src/models/config.py
Comment on lines +704 to +709
allow_degraded_mode: Optional[bool] = Field(
False,
title="Allow degraded mode",
description="If enabled, Lightspeed Core can be started even when Llama Stack "
"is not accessible (valid for server mode only)",
)
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 | 🟡 Minor | ⚡ Quick win

Enforce the “server mode only” contract for allow_degraded_mode.

Line 704 adds a field described as “valid for server mode only”, but check_llama_stack_model does not reject allow_degraded_mode=True when use_as_library_client=True, so an invalid combination is currently accepted.

Suggested fix
-    allow_degraded_mode: Optional[bool] = Field(
+    allow_degraded_mode: bool = Field(
         False,
         title="Allow degraded mode",
         description="If enabled, Lightspeed Core can be started even when Llama Stack "
         "is not accessible (valid for server mode only)",
     )

@@
         if self.use_as_library_client:
+            if self.allow_degraded_mode:
+                raise ValueError(
+                    "allow_degraded_mode is valid only in server mode "
+                    "(use_as_library_client must be false)"
+                )
             # when use_as_library_client is set to true, Llama Stack will be run in library mode
             # it means that:
🤖 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/config.py` around lines 704 - 709, The new allow_degraded_mode
field is documented as “valid for server mode only” but check_llama_stack_model
currently allows allow_degraded_mode=True when use_as_library_client=True;
update check_llama_stack_model to explicitly reject this combination
(use_as_library_client True + allow_degraded_mode True) by raising a clear
validation error (or ValueError) with a helpful message pointing out that
allow_degraded_mode is only allowed in server mode; reference the
allow_degraded_mode field and the check_llama_stack_model and
use_as_library_client symbols when implementing the guard so the invalid config
is rejected early.

Comment thread tests/unit/models/config/test_dump_configuration.py
@tisnik tisnik force-pushed the lcore-1861-config-toggle-for-degraded-mode branch from c153763 to 914c32e Compare May 21, 2026 07:16
@tisnik tisnik merged commit fa51dfd into lightspeed-core:main May 21, 2026
30 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request May 24, 2026
16 tasks
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