Skip to content

LCORE-2917 Adding image attachment capabilities to /query and /streaming_query#2108

Open
JslYoon wants to merge 4 commits into
lightspeed-core:mainfrom
JslYoon:JslYoon-image-attachments
Open

LCORE-2917 Adding image attachment capabilities to /query and /streaming_query#2108
JslYoon wants to merge 4 commits into
lightspeed-core:mainfrom
JslYoon:JslYoon-image-attachments

Conversation

@JslYoon

@JslYoon JslYoon commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

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: Claude Code
  • Generated by: (e.g., tool name and version; N/A if not used)

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

  • New Features
    • Added support for JPEG/PNG image attachments, including new multimodal prompt construction for both standard and streaming agent responses.
    • Introduced dedicated handling/extraction of image attachments so they’re provided as image payloads.
  • Bug Fixes
    • Prevented image attachments from being included in plain-text moderation/response input.
  • Documentation
    • Updated the OpenAPI schema with image attachment examples and MIME/base64 details.
  • Tests
    • Added unit tests for image attachment validation, extraction, and multimodal prompt/streaming behavior.

JslYoon added 2 commits July 7, 2026 22:12
Add 'image' attachment type with 'image/jpeg' and 'image/png' content
types. Validate base64 encoding and enforce size limits for image
attachments.
- prepare_input() skips image attachments (text-only for moderation)
- build_multimodal_input() converts text + images into pydantic-ai
  UserContent parts with ImageUrl data URLs
- ResponsesApiParams carries image_attachments (excluded from API body)
- prepare_responses_params() extracts image attachments from request
- Agent runners build multimodal prompts when images are present
- Text-only requests are completely unchanged
@JslYoon JslYoon changed the title Adding image attachment capabilities to /query and /streaming_query LCORE-2917 Adding image attachment capabilities to /query and /streaming_query Jul 9, 2026
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@JslYoon, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 38 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5e2276d9-d683-4a3f-92e4-e0174c9c603e

📥 Commits

Reviewing files that changed from the base of the PR and between 865afd3 and 6f9d644.

📒 Files selected for processing (13)
  • docs/openapi.json
  • src/constants.py
  • src/models/common/query.py
  • src/models/common/responses/responses_api_params.py
  • src/utils/agents/query.py
  • src/utils/agents/streaming.py
  • src/utils/query.py
  • src/utils/responses.py
  • tests/unit/models/requests/test_attachment.py
  • tests/unit/utils/agents/test_query.py
  • tests/unit/utils/agents/test_streaming.py
  • tests/unit/utils/test_query.py
  • tests/unit/utils/test_responses.py

Walkthrough

Image attachments now support JPEG and PNG base64 content, validation, OpenAPI examples, request extraction, multimodal prompt construction, and synchronous or streaming agent execution.

Changes

Multimodal attachment flow

Layer / File(s) Summary
Image attachment contracts and validation
src/constants.py, src/models/common/query.py, docs/openapi.json, tests/unit/models/requests/test_attachment.py
Attachment types and MIME types include images; image content is validated as base64 with metadata consistency and upload-size limits. Schemas, examples, and tests reflect the new behavior.
Request extraction and multimodal input construction
src/utils/query.py, src/utils/responses.py, src/models/common/responses/responses_api_params.py, tests/unit/utils/test_query.py, tests/unit/utils/test_responses.py
Image attachments are excluded from text input, retained in an excluded request parameter, and converted into base64 ImageUrl content.
Synchronous and streaming agent execution
src/utils/agents/query.py, src/utils/agents/streaming.py, tests/unit/utils/agents/*
Both agent execution paths construct multimodal prompts when image attachments are present and retain text-only behavior otherwise.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant QueryRequest
  participant ResponsesApiParams
  participant AgentRunner
  participant build_multimodal_input
  participant Agent
  QueryRequest->>ResponsesApiParams: Extract image_attachments
  ResponsesApiParams->>AgentRunner: Pass input and image attachments
  AgentRunner->>build_multimodal_input: Build multimodal prompt
  build_multimodal_input->>Agent: Text plus ImageUrl content
  Agent-->>AgentRunner: Response or streamed events
Loading

Possibly related PRs

Suggested reviewers: asimurka, tisnik

🚥 Pre-merge checks | ✅ 7
✅ Passed checks (7 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change: adding image attachment support to query and streaming endpoints.
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 Attachment handling stays linear and bounded; no new O(n^2), N+1, or unbounded growth patterns were introduced.
Security And Secret Handling ✅ Passed PASS: Auth deps remain on query/responses endpoints; image attachments are excluded from API bodies, and I found no plaintext secrets, leaks, injections, or Secret ownerRef issues.
✨ 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.

@JslYoon JslYoon marked this pull request as draft July 9, 2026 21:54
@JslYoon JslYoon marked this pull request as ready for review July 10, 2026 21:41

@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: 5

Caution

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

⚠️ Outside diff range comments (1)
src/utils/query.py (1)

173-220: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Use "Parameters:" instead of "Args:" in docstrings.

Both prepare_input (line 179) and build_multimodal_input (line 209) use the "Args:" section header. The project's coding guidelines require "Parameters:" as the section header name for function arguments, and this is confirmed by the repository's established convention.

As per coding guidelines: "Follow Google Python docstring conventions with required sections: Parameters, Returns, Raises, and Attributes for classes." Based on learnings: "In the lightspeed-stack repository, docstrings must use the section header name 'Parameters:' (not 'Args:') for function arguments."

♻️ Proposed fix for both docstrings
     """Prepare text input for moderation and Responses API.

     Takes the query text, appends any inline RAG context for the LLM call, then
     appends any text attachment content with type labels. Image attachments are
     skipped — they are handled separately as structured multimodal input.

-    Args:
+    Parameters:
         query_request: The query request containing the query and optional attachments
         inline_rag_context: Optional RAG context to inject into the query before
             sending to the LLM. Passed separately to keep QueryRequest a pure public
             API model.
     """Build a pydantic-ai multimodal prompt from text and image attachments.

     Constructs a list of UserContent items containing the text prompt followed
     by ImageUrl entries for each image attachment, using base64 data URLs.

-    Args:
+    Parameters:
         text: The text portion of the input (query + RAG context + text attachments).
         image_attachments: Image attachments with base64-encoded content.

     Returns:
         List of UserContent items: the text string followed by ImageUrl objects.
     """
🤖 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/query.py` around lines 173 - 220, Update the docstrings for
prepare_input and build_multimodal_input by renaming the “Args:” section header
to “Parameters:”; leave the parameter descriptions and all implementation logic
unchanged.

Sources: Coding guidelines, Learnings

🤖 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/common/query.py`:
- Around line 43-81: Add a Google-style “Returns:” section to the
validate_image_attachment docstring, documenting that it returns the validated
Attachment instance. Keep the existing “Raises:” section and follow the
project’s “Parameters:”/Google docstring conventions.
- Around line 67-78: In the image branch of the content validation method, add a
pre-decode size guard using the base64 payload length (for example,
len(self.content) * 3 // 4) and raise the same size-limit ValueError before
calling base64.b64decode; retain the existing decoded-size check afterward to
handle padding and malformed inputs accurately.

In `@src/utils/agents/query.py`:
- Around line 322-329: Extract the duplicated prompt-selection logic into a
shared build_prompt_from_params helper in src/utils/query.py, preserving the
existing multimodal-input and text fallback behavior. Update
retrieve_agent_response and agent_response_generator to call this helper, and
add the necessary imports while removing their local if/else blocks.

In `@tests/unit/models/requests/test_attachment.py`:
- Around line 97-105: Reduce memory usage in
test_image_attachment_exceeds_size_limit by patching
DEFAULT_MAX_FILE_UPLOAD_SIZE to a small test value and constructing a tiny
payload just above that limit, while preserving the expected ValidationError and
message assertion.

In `@tests/unit/utils/test_responses.py`:
- Around line 2231-2278: Strengthen test_image_attachments_extracted by
asserting that result.input contains the text attachment content ("log output")
and does not contain the image base64 payload (image_data), while retaining the
existing string type and image_attachments assertions.

---

Outside diff comments:
In `@src/utils/query.py`:
- Around line 173-220: Update the docstrings for prepare_input and
build_multimodal_input by renaming the “Args:” section header to “Parameters:”;
leave the parameter descriptions and all implementation logic 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: 0536ea0a-f0bc-48d0-b6ea-5b759273df58

📥 Commits

Reviewing files that changed from the base of the PR and between 1e60f35 and 2977e84.

📒 Files selected for processing (13)
  • docs/openapi.json
  • src/constants.py
  • src/models/common/query.py
  • src/models/common/responses/responses_api_params.py
  • src/utils/agents/query.py
  • src/utils/agents/streaming.py
  • src/utils/query.py
  • src/utils/responses.py
  • tests/unit/models/requests/test_attachment.py
  • tests/unit/utils/agents/test_query.py
  • tests/unit/utils/agents/test_streaming.py
  • tests/unit/utils/test_query.py
  • tests/unit/utils/test_responses.py
📜 Review details
⏰ Context from checks skipped due to timeout. (10)
  • GitHub Check: integration_tests (3.13)
  • GitHub Check: integration_tests (3.12)
  • GitHub Check: build-pr
  • GitHub Check: E2E Tests for Lightspeed Evaluation job
  • GitHub Check: E2E: server mode / ci / group 2
  • GitHub Check: E2E: server mode / ci / group 3
  • GitHub Check: E2E: library mode / ci / group 3
  • GitHub Check: E2E: server mode / ci / group 1
  • GitHub Check: E2E: library mode / ci / group 2
  • GitHub Check: E2E: library mode / ci / group 1
🧰 Additional context used
📓 Path-based instructions (5)
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/utils/agents/query.py
  • src/models/common/responses/responses_api_params.py
  • src/utils/agents/streaming.py
  • src/utils/responses.py
  • src/constants.py
  • src/models/common/query.py
  • src/utils/query.py
**/*

📄 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/agents/query.py
  • src/models/common/responses/responses_api_params.py
  • tests/unit/utils/test_responses.py
  • tests/unit/utils/agents/test_query.py
  • docs/openapi.json
  • tests/unit/models/requests/test_attachment.py
  • src/utils/agents/streaming.py
  • tests/unit/utils/agents/test_streaming.py
  • tests/unit/utils/test_query.py
  • src/utils/responses.py
  • src/constants.py
  • src/models/common/query.py
  • src/utils/query.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/common/responses/responses_api_params.py
  • src/models/common/query.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/utils/test_responses.py
  • tests/unit/utils/agents/test_query.py
  • tests/unit/models/requests/test_attachment.py
  • tests/unit/utils/agents/test_streaming.py
  • tests/unit/utils/test_query.py
src/constants.py

📄 CodeRabbit inference engine (AGENTS.md)

Use constants.py for shared constants with descriptive comments and type hints using Final[type]

Files:

  • src/constants.py
🧠 Learnings (5)
📚 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/agents/query.py
  • src/models/common/responses/responses_api_params.py
  • tests/unit/utils/test_responses.py
  • tests/unit/utils/agents/test_query.py
  • tests/unit/models/requests/test_attachment.py
  • src/utils/agents/streaming.py
  • tests/unit/utils/agents/test_streaming.py
  • tests/unit/utils/test_query.py
  • src/utils/responses.py
  • src/constants.py
  • src/models/common/query.py
  • src/utils/query.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/agents/query.py
  • src/models/common/responses/responses_api_params.py
  • src/utils/agents/streaming.py
  • src/utils/responses.py
  • src/constants.py
  • src/models/common/query.py
  • src/utils/query.py
📚 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/common/responses/responses_api_params.py
  • src/models/common/query.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/common/responses/responses_api_params.py
  • src/models/common/query.py
📚 Learning: 2026-02-23T14:56:59.186Z
Learnt from: asimurka
Repo: lightspeed-core/lightspeed-stack PR: 1198
File: src/utils/responses.py:184-192
Timestamp: 2026-02-23T14:56:59.186Z
Learning: In the lightspeed-stack codebase (lightspeed-core/lightspeed-stack), do not enforce de-duplication of duplicate client.models.list() calls in model selection flows (e.g., in src/utils/responses.py prepare_responses_params). These calls are considered relatively cheap and removing duplicates could add unnecessary complexity to the flow. Apply this guideline specifically to this file/context unless similar performance characteristics and design decisions are documented elsewhere.

Applied to files:

  • src/utils/responses.py
🔇 Additional comments (13)
src/constants.py (1)

34-61: LGTM!

src/utils/responses.py (1)

96-96: LGTM!

Also applies to: 387-401, 446-446

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

5-13: LGTM!

Also applies to: 32-32, 261-350, 444-463

src/utils/agents/streaming.py (1)

61-65: LGTM!

Also applies to: 323-329

tests/unit/utils/agents/test_query.py (1)

3-3: LGTM!

Also applies to: 15-15, 30-30, 437-479

src/models/common/query.py (3)

3-13: LGTM!


25-42: LGTM!


102-106: LGTM!

docs/openapi.json (1)

11490-11543: LGTM!

tests/unit/models/requests/test_attachment.py (1)

3-7: LGTM!

Also applies to: 45-65, 67-86, 88-95, 107-115

src/models/common/responses/responses_api_params.py (1)

23-23: LGTM!

Also applies to: 134-139

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

5-5: LGTM!

Also applies to: 59-59

tests/unit/utils/agents/test_streaming.py (1)

6-6: LGTM!

Also applies to: 23-23, 55-55, 895-956

Comment thread src/models/common/query.py
Comment thread src/models/common/query.py
Comment thread src/utils/agents/query.py
Comment thread tests/unit/models/requests/test_attachment.py
Comment thread tests/unit/utils/test_responses.py
Regenerate docs/openapi.json to reflect Attachment model changes
(image type, content_type examples, description updates).

Add tests for image attachment validation, prepare_responses_params
image extraction, and multimodal prompt construction in both blocking
and streaming agent runners.

Signed-off-by: Lucas <lyoon@redhat.com>
@JslYoon JslYoon force-pushed the JslYoon-image-attachments branch from 2977e84 to 824ed3f Compare July 13, 2026 18:11

@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: 1

🤖 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 `@docs/openapi.json`:
- Around line 11539-11543: Update the invalid-value example in the
unprocessable-entity response definition to use the current attachment
validator/schema MIME list, replacing the stale hardcoded list. Ensure the
generated 422 examples for /v1/query, /v1/streaming_query, and /v1/responses all
show the updated Invalid attachment type message.
🪄 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: 25b01ea8-9fe7-43ab-9a6c-e70c9717d301

📥 Commits

Reviewing files that changed from the base of the PR and between 2977e84 and 824ed3f.

📒 Files selected for processing (6)
  • docs/openapi.json
  • src/models/common/query.py
  • tests/unit/utils/agents/test_query.py
  • tests/unit/utils/agents/test_streaming.py
  • tests/unit/utils/test_query.py
  • tests/unit/utils/test_responses.py
📜 Review details
⏰ Context from checks skipped due to timeout. (7)
  • GitHub Check: E2E Tests for Lightspeed Evaluation job
  • GitHub Check: E2E: server mode / ci / group 2
  • GitHub Check: E2E: library mode / ci / group 1
  • GitHub Check: E2E: library mode / ci / group 2
  • GitHub Check: E2E: server mode / ci / group 3
  • GitHub Check: E2E: library mode / ci / group 3
  • GitHub Check: E2E: server mode / ci / group 1
🧰 Additional context used
📓 Path-based instructions (4)
**/*

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

  • docs/openapi.json
  • tests/unit/utils/test_responses.py
  • tests/unit/utils/test_query.py
  • tests/unit/utils/agents/test_streaming.py
  • src/models/common/query.py
  • tests/unit/utils/agents/test_query.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/utils/test_responses.py
  • tests/unit/utils/test_query.py
  • tests/unit/utils/agents/test_streaming.py
  • tests/unit/utils/agents/test_query.py
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/common/query.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/common/query.py
🧠 Learnings (4)
📚 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:

  • tests/unit/utils/test_responses.py
  • tests/unit/utils/test_query.py
  • tests/unit/utils/agents/test_streaming.py
  • src/models/common/query.py
  • tests/unit/utils/agents/test_query.py
📚 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/common/query.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/common/query.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/models/common/query.py
🔇 Additional comments (8)
src/models/common/query.py (1)

47-48: LGTM!

docs/openapi.json (2)

11490-11509: Attachment schema updates for image support look correct.

The added "image" attachment type and image/jpeg/image/png content-type examples are consistent with the PR's multimodal attachment feature.


11523-11523: LGTM!

tests/unit/utils/test_responses.py (2)

2231-2278: Strengthen assertions on result.input content.

The test verifies isinstance(result.input, str) but doesn't confirm the image base64 data is absent from the input or that the text attachment content is present. Since prepare_input is not mocked, adding these assertions would verify the real separation of text and image attachments.

♻️ Suggested additional assertions
         assert isinstance(result.input, str)
+        assert image_data not in result.input
+        assert "log output" in result.input
         assert result.image_attachments is not None

5-5: LGTM!

Also applies to: 59-59

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

444-463: LGTM!

tests/unit/utils/agents/test_query.py (1)

3-3: LGTM!

Also applies to: 15-15, 30-30, 437-479

tests/unit/utils/agents/test_streaming.py (1)

6-6: LGTM!

Also applies to: 23-23, 55-55, 895-956

Comment thread docs/openapi.json
Signed-off-by: Lucas <lyoon@redhat.com>
@JslYoon JslYoon force-pushed the JslYoon-image-attachments branch from 865afd3 to 6f9d644 Compare July 14, 2026 17:43
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