Skip to content

LCORE-461: sequence diagram for streaming query endpoint#792

Merged
tisnik merged 1 commit intolightspeed-core:mainfrom
tisnik:lcore-461-sequence-diagram-for-streaming-query-endpoint
Nov 13, 2025
Merged

LCORE-461: sequence diagram for streaming query endpoint#792
tisnik merged 1 commit intolightspeed-core:mainfrom
tisnik:lcore-461-sequence-diagram-for-streaming-query-endpoint

Conversation

@tisnik
Copy link
Contributor

@tisnik tisnik commented Nov 13, 2025

Description

LCORE-461: sequence diagram for streaming query endpoint

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

Related Tickets & Documents

  • Related Issue #LCORE-461

Summary by CodeRabbit

  • Documentation
    • Added comprehensive documentation for the streaming query endpoint REST API handler, including a detailed visual diagram illustrating the complete workflow, authentication flow, event handling, and response streaming mechanism for streaming queries.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 13, 2025

Walkthrough

Documentation additions for a streaming query endpoint REST API handler. The changes include a new table of contents entry and documentation section in README.md, plus a new UML sequence diagram file detailing the endpoint's control flow and component interactions.

Changes

Cohort / File(s) Summary
Streaming Query Endpoint Documentation
README.md
Adds table of contents entry and new documentation section for streaming query endpoint REST API handler with accompanying image
Streaming Query Endpoint Diagram
docs/streaming_query_endpoint.puml
Introduces UML sequence diagram detailing streaming query endpoint flow, including authentication, LlamaStack client interactions, SSE streaming initialization, per-chunk event handling (turn_start, inference, tool_execution, shield, turn_complete, error), and finalization with metadata and token usage

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Endpoint as Streaming Query<br/>Endpoint Handler
    participant Auth
    participant LlamaStack as Llama Stack<br/>Client
    participant Handler as Stream Build<br/>Event Handler
    participant SSE as SSE Response<br/>Stream

    Client->>Endpoint: HTTP POST /stream_query
    Endpoint->>Auth: Authenticate & Authorize
    Auth-->>Endpoint: ✓ Authorized
    
    Note over Endpoint,LlamaStack: Initialization Phase
    Endpoint->>LlamaStack: Request async response chunks
    LlamaStack-->>Endpoint: Stream chunks
    Endpoint->>SSE: Initialize SSE stream
    SSE-->>Client: Connection opened
    
    Note over Endpoint,Handler: Per-Chunk Processing
    loop For each chunk
        LlamaStack->>Handler: Deliver chunk
        Handler->>Handler: Branch on chunk type<br/>(turn_start | inference |<br/>tool_execution | shield |<br/>turn_complete | error)
        Handler->>SSE: Emit SSE event
        SSE-->>Client: Send event
    end
    
    Note over Endpoint,Handler: Finalization Phase
    Handler->>SSE: stream_end event<br/>(metadata + token_usage)
    SSE-->>Client: Final event
    SSE->>Endpoint: Stream closed
    opt Persistence
        Endpoint->>Endpoint: Cache/persist transcript
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Notes:

  • Straightforward documentation addition with no code logic changes
  • New diagram file requires validation of sequence accuracy and completeness against the actual endpoint implementation
  • Consider verifying that all chunk-type branches (turn_start, inference, tool_execution, shield, turn_complete, error) are correctly represented

Possibly related PRs

  • LCORE-304: REST API #264: Adds comprehensive REST API documentation/sequence diagram for streaming query endpoint, overlapping in scope with the focused streaming_query_endpoint.puml diagram introduced here

Pre-merge checks and finishing touches

✅ 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: adding a sequence diagram for the streaming query endpoint, which aligns directly with the changeset modifications to documentation files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 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.

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.

Actionable comments posted: 2

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 552704c and 6f86812.

⛔ Files ignored due to path filters (1)
  • docs/streaming_query_endpoint.svg is excluded by !**/*.svg
📒 Files selected for processing (2)
  • README.md (2 hunks)
  • docs/streaming_query_endpoint.puml (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-29T13:05:22.438Z
Learnt from: luis5tb
Repo: lightspeed-core/lightspeed-stack PR: 727
File: src/app/endpoints/a2a.py:43-43
Timestamp: 2025-10-29T13:05:22.438Z
Learning: In the lightspeed-stack repository, endpoint files in src/app/endpoints/ intentionally use a shared logger name "app.endpoints.handlers" rather than __name__, allowing unified logging configuration across all endpoint handlers (query.py, streaming_query.py, a2a.py).

Applied to files:

  • README.md
🪛 markdownlint-cli2 (0.18.1)
README.md

83-83: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)

⏰ 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). (4)
  • GitHub Check: build-pr
  • GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-on-pull-request
  • GitHub Check: e2e_tests (ci)
  • GitHub Check: e2e_tests (azure)
🔇 Additional comments (4)
docs/streaming_query_endpoint.puml (4)

1-8: LGTM! Clear participant declarations.

The PlantUML syntax is correct, and the participant declarations are clear and descriptive with appropriate aliases.


10-14: LGTM! Proper authentication and streaming setup.

The initial flow correctly shows authentication/authorization before calling the LlamaStack backend, and appropriately indicates the streaming nature with AsyncIterator[AgentTurnResponseStreamChunk].


16-35: LGTM! Comprehensive chunk processing with proper error handling.

The loop structure effectively illustrates the streaming flow with all major chunk types (turn_start, inference, tool_execution, shield, turn_complete) and includes error handling. The event handler pattern provides good separation of concerns.


37-41: LGTM! Proper stream finalization.

The finalization flow correctly includes metadata and token usage in the end event, shows conditional persistence/caching, and explicitly closes the stream.

* [REST API](#rest-api)
* [Sequence diagrams](#sequence-diagrams)
* [Query endpoint REST API handler](#query-endpoint-rest-api-handler)
* [Streaming query endpoint REST API handler](#streaming-query-endpoint-rest-api-handler)
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Minor: Indentation inconsistent with markdown linting standards.

The 4-space indentation is consistent with the existing ToC entry on line 82, but markdownlint expects 2 spaces for nested list items. While this maintains consistency with the current style, consider updating both entries to use 2-space indentation in a follow-up to comply with markdown standards.

Apply this diff to fix the indentation:

     * [Sequence diagrams](#sequence-diagrams)
         * [Query endpoint REST API handler](#query-endpoint-rest-api-handler)
-    * [Streaming query endpoint REST API handler](#streaming-query-endpoint-rest-api-handler)
+  * [Streaming query endpoint REST API handler](#streaming-query-endpoint-rest-api-handler)

Note: You may also want to fix line 82 in the same way for full compliance.

📝 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
* [Streaming query endpoint REST API handler](#streaming-query-endpoint-rest-api-handler)
* [Streaming query endpoint REST API handler](#streaming-query-endpoint-rest-api-handler)
🧰 Tools
🪛 markdownlint-cli2 (0.18.1)

83-83: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)

🤖 Prompt for AI Agents
In README.md around line 83, the ToC entry uses 4-space indentation which
conflicts with markdownlint's 2-space expectation for nested list items; change
the indentation of the line 83 entry from 4 spaces to 2 spaces to match
markdownlint rules, and also update the adjacent line 82 to 2-space indentation
for consistent nested list formatting across both entries.

Comment on lines +905 to +907
## Streaming query endpoint REST API handler

![Streaming query endpoint](docs/streaming_query_endpoint.svg)
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Fix heading level to match document structure.

The heading uses ## (h2) but should use ### (h3) to match the existing "Query endpoint REST API handler" section at line 901 and align with the ToC structure where both entries are nested under "Sequence diagrams".

Apply this diff to fix the heading level:

-## Streaming query endpoint REST API handler
+### Streaming query endpoint REST API handler
📝 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
## Streaming query endpoint REST API handler
![Streaming query endpoint](docs/streaming_query_endpoint.svg)
### Streaming query endpoint REST API handler
![Streaming query endpoint](docs/streaming_query_endpoint.svg)
🤖 Prompt for AI Agents
In README.md around lines 905 to 907, change the heading level for "Streaming
query endpoint REST API handler" from an h2 (##) to an h3 (###) so it matches
the "Query endpoint REST API handler" section at line 901 and aligns with the
Table of Contents under "Sequence diagrams"; open the file, replace the leading
"##" with "###" on that heading line and save.

@tisnik tisnik merged commit 144fb13 into lightspeed-core:main Nov 13, 2025
21 of 23 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.

1 participant