Skip to content

LCORE-4723: Responses models and display-history projection item updates - #3370

Merged
tisnik merged 1 commit into
lightspeed-core:mainfrom
asimurka:responses-models-display-projection
Nov 30, 2026
Merged

tisnik merged 1 commit into
lightspeed-core:mainfrom
asimurka:responses-models-display-projection

Conversation

@asimurka

@asimurka asimurka commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Description

Align OpenResponses stream event models and display-history tool-result projection with Pydantic AI ToolReturnContent shapes.

  • Add ResponseStreamEventBase with shared sequence_number; stream event types inherit it (default 0 for projector assignment).
  • Tool result display: accept any Mapping via dict(content); serialize knowledge matches from sequences; clarify docstring.
  • Minor responses model tweaks (items.py, response.py) in the same slice.

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

  • uv run pytest tests/unit/conversations/display_history/agentic/projection/ -q (36 passed)
  • Existing coverage: string/dict/knowledge-match tool returns via test_items.py; no new tests in this PR

Summary by CodeRabbit

  • Improvements
    • Stream events now receive a default sequence number when one is not provided.
    • Reasoning summaries and response outputs can be omitted and default to empty lists.
    • Tool results now support mapping-shaped content and sequences containing knowledge matches; unsupported sequence content continues to use fallback text.

@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 48 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 8a687ac and 76a851b.

Files selected for processing: 4

  • src/conversations/display_history/agentic/projection/items.py
  • src/responses/models/events.py
  • src/responses/models/items.py
  • src/responses/models/response.py

No actionable comments were generated in the recent review.

Walkthrough

The changes broaden tool-result projection handling and update response model contracts. Stream events inherit a shared sequence number that defaults to 0. ReasoningItem.summary and ResponseObject.output now default to empty lists.

Changes

Tool result projection

Layer / File(s) Summary
Tool-result body handling
src/conversations/display_history/agentic/projection/items.py
_tool_result_body converts mappings to plain dictionaries and serializes KnowledgeMatch items in sequences. It returns fallback text for sequences without matches and other unsupported shapes. Strings pass through unchanged.

Response model contracts

Layer / File(s) Summary
Shared event sequence number
src/responses/models/events.py
Event models inherit sequence_number from ResponseStreamEventBase. The shared field defaults to 0; event-specific fields remain unchanged.
Empty-list field defaults
src/responses/models/items.py, src/responses/models/response.py
ReasoningItem.summary and ResponseObject.output now default to empty lists. ResponseObject.output is typed as a list.

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

Change: Refactor

Possibly related PRs

Suggested reviewers: jrobertboos, tisnik

Merge Risk: Minimal · previous review 8a687

The change broadens tool-result handling and gives stream events and response models sensible defaults. No concrete defect was found, so it looks safe to merge.

Pre-merge checks: Passed 6

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the two areas the PR touches: Responses models and display-history projection item updates. The raw summary shows changes to events.py, items.py, response.py, and projection/items.py, …
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 PR #3370 (asimurka, lightspeed-core/lightspeed-stack) makes four small changes. I read the full diffs for _tool_result_body, ReasoningItem.summary, ResponseObject.output, and the event models. -…
Security And Secret Handling Passed The PR changes four files: src/conversations/display_history/agentic/projection/items.py, src/responses/models/events.py, src/responses/models/items.py, and src/responses/models/response.py. T…
Full details: Title check

Explanation

The title names the two areas the PR touches: Responses models and display-history projection item updates. The raw summary shows changes to events.py, items.py, response.py, and projection/items.py, which match both named areas. The title does not name the main behavioral change, which is the shared ResponseStreamEventBase with sequence_number defaulting to 0. It also omits the Mapping-based tool-result handling. The title is therefore partially related: it is accurate but broad. The ticket prefix is a tracking reference and does not affect the assessment.

Full details: Performance And Algorithmic Complexity

Explanation

PR #3370 (asimurka, lightspeed-core/lightspeed-stack) makes four small changes. I read the full diffs for _tool_result_body, ReasoningItem.summary, ResponseObject.output, and the event models. - _tool_result_body (items.py): now calls dict(content) for a Mapping and asdict for KnowledgeMatch items in a Sequence. Both run once per tool result and are linear in the payload. The old code also used asdict in a list comprehension, so this adds no new loop cost. - events.py: adds a base class with a shared sequence_number field. This removes duplicate field declarations and adds no runtime work. - items.py and response.py: change summary and output to Field(default_factory=list). This is a constant-time default and does not change any collection's size. None of the five criteria applies. The diff adds no O(n^2) work, no N+1 query or API pattern, no expensive work inside a loop, no unbounded cache or buffer, and no List endpoint without limits.

Full details: Security And Secret Handling

Explanation

The PR changes four files: src/conversations/display_history/agentic/projection/items.py, src/responses/models/events.py, src/responses/models/items.py, and src/responses/models/response.py. The diff contains no endpoints, auth logic, logging, secrets, or K8s/RH secret resources. Checked against each criterion: 1. Secrets or tokens in logs or source: none added. The grep of events.py for secret, token, key, log, and auth terms matched only logprobs. 2. Missing auth on endpoints: no endpoint or route changes. 3. Injection: _tool_result_body now uses dict(content) for any Mapping. This is a type-shape change. It does not build commands, SQL, or paths. 4. Sensitive data in responses, WebSocket messages, or logs: tool results already flowed into this display payload before the PR. Dict results were already returned unchanged. The PR widens the accepted type and serializes KnowledgeMatch items from sequences. It adds no new data source or sink. 5. K8s/RH secrets: none touched. Author confirmed as asimurka from the primary PR record. The change is a model refactor with no security-relevant effect.

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 eb1ae7f and 8a687ac.

Files selected for processing: 4

  • src/conversations/display_history/agentic/projection/items.py
  • src/responses/models/events.py
  • src/responses/models/items.py
  • src/responses/models/response.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: 22

  • GitHub Check: E2E: ci / other
  • GitHub Check: E2E: ci / mcp
  • GitHub Check: E2E: ci / shields
  • GitHub Check: E2E: ci / authorized
  • GitHub Check: E2E: ci / rbac
  • GitHub Check: E2E: ci / default
  • GitHub Check: E2E: ci / skills
  • GitHub Check: Red Hat Konflux / lightspeed-core-0-8-enterprise-contract / lightspeed-stack-0-8
  • GitHub Check: Red Hat Konflux / rag-content-0-8-e2e-tests / lightspeed-stack-0-8
  • GitHub Check: dispatch / Harness dispatch
  • GitHub Check: Red Hat Konflux / lightspeed-stack-0-8-e2e-tests / lightspeed-stack-0-8
  • GitHub Check: dispatch / Route
  • GitHub Check: mypy
  • GitHub Check: integration_tests (3.12)
  • GitHub Check: integration_tests (3.13)
  • GitHub Check: Pylinter
  • GitHub Check: unit_tests (3.14)
  • GitHub Check: unit_tests (3.12)
  • GitHub Check: integration_tests (3.14)
  • GitHub Check: build-pr
  • GitHub Check: unit_tests (3.13)
  • GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-0-8-on-pull-request
Additional context used

Learnings: 2

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/conversations/display_history/agentic/projection/items.py
Learning: 2026-11-17T11:23:03.910Z

Learnt from: CR
Repo: lightspeed-core/lightspeed-stack PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-11-17T11:23:03.910Z
Learning: Source excerpt:
# Lightspeed Core Stack Development Guide

## Code Architecture & Patterns

### Coding Standards

#### Function Standards

- **Type Annotations**: Complete type annotations for parameters and return types
  - Use `typing_extensions.Self` for model validators
  - Union types: `str | int` (modern syntax)
  - Optional: `Optional[Type]`

Applied to files:

  • src/responses/models/events.py
Additional comments: 1

src/conversations/display_history/agentic/projection/items.py: 1

391-391: Functional Correctness

The concern depends on search_knowledge returning a tuple of KnowledgeMatch objects. The search_knowledge producer is declared to return list[KnowledgeMatch], and it returns the value of search_sources unchanged. Tool content is therefore a list on the supported path, which _knowledge_matches handles and cites. The tuple branch is not reached by the supported producer, so the missing-citation consequence does not occur from this path.

@asimurka
asimurka force-pushed the responses-models-display-projection branch from 8a687ac to 76a851b Compare November 30, 2026 07:38
@asimurka
asimurka requested a review from tisnik November 30, 2026 07:40

@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 908f056 into lightspeed-core:main Nov 30, 2026
45 of 47 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