Skip to content

LCORE-2311: Streaming query agent stream events#1870

Draft
asimurka wants to merge 1 commit into
lightspeed-core:mainfrom
asimurka:streaming_query_agent_stream_events
Draft

LCORE-2311: Streaming query agent stream events#1870
asimurka wants to merge 1 commit into
lightspeed-core:mainfrom
asimurka:streaming_query_agent_stream_events

Conversation

@asimurka

@asimurka asimurka commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Description

Wires agent streaming response into streaming query flow.

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

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.

@asimurka asimurka marked this pull request as draft June 8, 2026 11:26
@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: ac995784-6fcd-4f71-a6ee-eca766b701f6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ 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.

@asimurka asimurka force-pushed the streaming_query_agent_stream_events branch 9 times, most recently from c7304fd to 69353a8 Compare June 15, 2026 12:02
Comment thread src/pydantic_ai_lightspeed/llamastack/_model.py Fixed
@asimurka asimurka force-pushed the streaming_query_agent_stream_events branch 7 times, most recently from 1932d18 to b7ebcaa Compare June 17, 2026 08:31
# Skip the first token (shield status message)
if first_token:
first_token = False
continue

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed workaround from old Agents API that was introduced for Responses API
First token is no longer a shield status nor an empty token but a real token.

@asimurka asimurka force-pushed the streaming_query_agent_stream_events branch 8 times, most recently from 5fc1a76 to 4a18cb8 Compare June 19, 2026 07:11
@asimurka asimurka force-pushed the streaming_query_agent_stream_events branch from 4a18cb8 to d798fd8 Compare June 19, 2026 07:12
turn_summary,
background_topic_summary_tasks=_background_topic_summary_tasks,
emit_start=False,
compacted=compacted,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Originally used for persistence of compacted turn. This has to be done differently and will be addressed in a separate PR.


async def _responses_create(**kwargs: Any) -> Any:
if kwargs.get("stream", True):
return _mock_stream()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Client mock will be used only for vector_io operations, inference will be extracted to agent mock.

assert call_kwargs["query"] == "What is OpenShift?"

# Verify RAG context was injected into the agent prompt
await _collect_sse_events(response)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Has to be manually iterated because run_stream_events is an async context manager, not as a plain async function.

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