Skip to content

Implement Runner streaming and stateless execution#142

Open
dewitt wants to merge 6 commits intomainfrom
pr/4-streaming-runner
Open

Implement Runner streaming and stateless execution#142
dewitt wants to merge 6 commits intomainfrom
pr/4-streaming-runner

Conversation

@dewitt
Copy link
Collaborator

@dewitt dewitt commented Feb 13, 2026

This PR implements runStream and runStateless methods in the Runner class.

  • runStream: Returns an AsyncGenerator<AgentEvent> for streaming execution, yielding standardized events.
  • runStateless: Helper to create an ephemeral session, run a streaming execution, and cleanup afterwards.
  • convertEventToAgentEvents: Internal mapper from Event to standardized AgentEvent.

Reference: docs/adk-ts-improvements.md.

Fixes #141.

Copy link
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?

* @param event The internal Event.
* @yields The AgentEvent stream.
*/
private *convertEventToAgentEvents(
Copy link
Collaborator

Choose a reason for hiding this comment

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

this actually can be just a function but not part of the class method

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agree! Done

newMessage: Content;
stateDelta?: Record<string, unknown>;
runConfig?: RunConfig;
}): AsyncGenerator<AgentEvent, void, undefined> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need to stream AgentEvent but not just default ADK Event. What is the use case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right, I believe we could return Event directly.

While I'd argue this API is a lot cleaner for the caller and saves the client work, it is lossy, and adds code.

Let me think overnight on this, since if we want to drop AgentEvent from streaming (which might well be the right suggestion, thank you!) I'll go back and revise it all over.

Thanks @kalenkevich!

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