Skip to content

RSPEED-2408: fix(rlsapi): use customization.system_prompt in /v1/infer#1125

Merged
tisnik merged 1 commit intolightspeed-core:mainfrom
major:rlsapi-config-system-prompt
Feb 11, 2026
Merged

RSPEED-2408: fix(rlsapi): use customization.system_prompt in /v1/infer#1125
tisnik merged 1 commit intolightspeed-core:mainfrom
major:rlsapi-config-system-prompt

Conversation

@major
Copy link
Contributor

@major major commented Feb 9, 2026

Description

The /v1/infer endpoint hardcodes constants.DEFAULT_SYSTEM_PROMPT ("You are a helpful assistant") in _build_instructions(). The /v1/query and /v1/streaming_query endpoints already support configurable system prompts via customization.system_prompt in lightspeed-stack.yaml, but /v1/infer ignores this config entirely.

This change makes _build_instructions() check configuration.customization.system_prompt first, falling back to DEFAULT_SYSTEM_PROMPT when unset. Follows the same precedence pattern as get_system_prompt() in src/utils/prompts.py, simplified for rlsapi (no per-request prompt, no custom profiles).

Type of change

  • Bug fix
  • Unit tests improvement

Tools used to create PR

  • Assisted-by: Claude (claude-opus-4-6)
  • 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

  • uv run pytest tests/unit/app/endpoints/test_rlsapi_v1.py -v -k "build_instructions" — all 6 tests pass (3 existing + 3 new)
  • uv run make verify — all linters clean
  • New test cases:
    • test_build_instructions_customization_system_prompt_set — custom prompt used when configured
    • test_build_instructions_customization_system_prompt_none — falls back to DEFAULT_SYSTEM_PROMPT when system_prompt is None
    • test_build_instructions_no_customization — falls back when customization itself is None

Summary by CodeRabbit

  • New Features

    • System prompts can now be customized via configuration; the app uses a provided custom prompt or falls back to the default when none is set.
  • Tests

    • Added tests verifying custom prompt usage and correct fallback to the default prompt.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 9, 2026

Walkthrough

_build_instructions now uses configuration.customization.system_prompt when present; otherwise it falls back to constants.DEFAULT_SYSTEM_PROMPT. Tests were added to verify both the custom-prompt path and the fallback when customization is absent.

Changes

Cohort / File(s) Summary
System Prompt Configuration
src/app/endpoints/rlsapi_v1.py
Modify _build_instructions to select configuration.customization.system_prompt if available, else use constants.DEFAULT_SYSTEM_PROMPT.
Prompt Configuration Tests
tests/unit/app/endpoints/test_rlsapi_v1.py
Add parametrized test verifying custom system_prompt is used and contains OS info; add fallback test verifying default prompt when customization is None.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: implementing support for customization.system_prompt in the /v1/infer endpoint.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@major major force-pushed the rlsapi-config-system-prompt branch from 9451ea4 to 0845489 Compare February 9, 2026 22:35
@major
Copy link
Contributor Author

major commented Feb 11, 2026

The e2e failure looks unrelated 🤔

- Check configuration.customization.system_prompt before falling back
  to constants.DEFAULT_SYSTEM_PROMPT in _build_instructions()
- Add unit tests for custom prompt, None prompt, and None customization

Signed-off-by: Major Hayden <major@redhat.com>
@major major force-pushed the rlsapi-config-system-prompt branch from 0845489 to aff7004 Compare February 11, 2026 15:14
Copy link
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.

Caution

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

⚠️ Outside diff range comments (1)
tests/unit/app/endpoints/test_rlsapi_v1.py (1)

155-167: ⚠️ Potential issue | 🟠 Major

test_build_instructions lacks mocking for configuration — tests will fail.

The existing test at lines 155–167 has no mocker parameter and doesn't patch configuration, but _build_instructions now accesses configuration.customization at runtime. This will hit the uninitialized singleton and raise a LogicError.

The two new tests correctly mock configuration using mocker.patch(). The existing parametrized test should either:

  • Accept mocker: MockerFixture and patch configuration before calling _build_instructions, or
  • Use the mock_configuration fixture already defined in this test file (line 76)
🧹 Nitpick comments (1)
src/app/endpoints/rlsapi_v1.py (1)

95-101: Consider caching the configuration.customization access in a local variable.

configuration.customization is accessed twice, and each access goes through the property getter (which includes a None-check on _configuration). A local variable avoids the redundant property call and reads more cleanly.

♻️ Suggested refactor
-    if (
-        configuration.customization is not None
-        and configuration.customization.system_prompt is not None
-    ):
-        base_prompt = configuration.customization.system_prompt
-    else:
-        base_prompt = constants.DEFAULT_SYSTEM_PROMPT
+    customization = configuration.customization
+    if customization is not None and customization.system_prompt is not None:
+        base_prompt = customization.system_prompt
+    else:
+        base_prompt = constants.DEFAULT_SYSTEM_PROMPT

Copy link
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

@tisnik tisnik merged commit 1c809a4 into lightspeed-core:main Feb 11, 2026
20 of 21 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.

2 participants