Skip to content

Implement Runner streaming and stateless execution#142

Merged
dewitt merged 19 commits intomainfrom
pr/4-streaming-runner
Feb 23, 2026
Merged

Implement Runner streaming and stateless execution#142
dewitt merged 19 commits intomainfrom
pr/4-streaming-runner

Conversation

@dewitt
Copy link
Copy Markdown
Collaborator

@dewitt dewitt commented Feb 13, 2026

This PR implements the core streaming and session management improvements for the Runner class, ensuring architectural parity with the ADK Python implementation.

Key Features:

  • Streaming Execution (runAsync): The primary entry point for streaming. Returns an AsyncGenerator, yielding raw, non-lossy ADK events in real-time as the model processes the request.
  • Ephemeral Sessions (runEphemeral): A helper method that creates a temporary session, executes a stream (with an optional initial stateDelta), and automatically cleans up the session data upon completion.
  • Structured Introspection (toStructuredEvents): An optional, standalone utility that parses raw ADK events into a strongly-typed list of StructuredEvent objects. It categorizes parts into high-level actions (ThoughtEvent, ContentEvent, ToolCallEvent, CallCodeEvent, etc.) to simplify client-side event handling for complex UI or CLI integrations.

Reference: docs/adk-ts-improvements.md

Fixes #141.

Copy link
Copy Markdown
Collaborator

@kalenkevich kalenkevich left a comment

Choose a reason for hiding this comment

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

can we please also include some tests for those changes?

Comment thread core/src/runner/runner.ts Outdated
Comment thread core/src/runner/runner.ts Outdated
Comment thread core/src/runner/runner.ts Outdated
Comment thread core/src/runner/runner.ts Outdated
Comment thread core/src/runner/runner.ts
Comment thread core/src/utils/event_type.ts Outdated
Comment thread core/src/utils/event_type.ts Outdated
Comment thread core/src/utils/event_type.ts Outdated
Comment thread core/src/utils/event_type.ts Outdated
Comment thread core/src/utils/event_type.ts Outdated
Comment thread core/src/utils/event_type.ts Outdated
Comment thread core/src/runner/runner.ts Outdated
@dewitt
Copy link
Copy Markdown
Collaborator Author

dewitt commented Feb 23, 2026

@kalenkevich I think I've resolved all of your comments, and updated the PR description to match the revised API.

PTAL, and thank you!

Comment thread core/test/runner/streaming_runner_test.ts Outdated
Copy link
Copy Markdown
Collaborator

@kalenkevich kalenkevich left a comment

Choose a reason for hiding this comment

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

A bit more comments, sorry

Comment thread core/src/index.ts Outdated
Comment thread core/src/events/structured_events.ts Outdated
Comment thread core/src/events/structured_events.ts Outdated
Comment thread core/test/runner/streaming_runner_test.ts Outdated
Comment thread core/test/runner/streaming_runner_test.ts Outdated
Comment thread core/test/runner/streaming_runner_test.ts Outdated
Comment thread core/test/runner/streaming_runner_test.ts Outdated
Comment thread core/src/events/structured_events.ts Outdated
Comment thread core/src/events/structured_events.ts Outdated
@dewitt
Copy link
Copy Markdown
Collaborator Author

dewitt commented Feb 23, 2026

Thanks for the additional round of comments, @kalenkevich! The code is better for it.

All suggestions and fixes incorporated. PTAL.

Copy link
Copy Markdown
Collaborator

@kalenkevich kalenkevich left a comment

Choose a reason for hiding this comment

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

Thanks!

@dewitt dewitt merged commit bb7d4f6 into main Feb 23, 2026
6 checks passed
@dewitt dewitt deleted the pr/4-streaming-runner branch February 23, 2026 23:59
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.

Implement Runner streaming and stateless execution

2 participants