Skip to content

Conversation

@pavelgj
Copy link
Collaborator

@pavelgj pavelgj commented Jan 21, 2026

Introduces bidirectional streaming capabilities to Genkit Actions, Flows, and Models. This allows these primitives to accept a continuous input stream and an initialization payload, in addition to producing an output stream.

@github-actions github-actions bot added the docs Improvements or additions to documentation label Jan 21, 2026
@pavelgj pavelgj changed the title RFC: Bidirectional Actions, Flows, and Models RFC: [JS] Bidirectional Actions, Flows, and Models Jan 21, 2026
@pavelgj
Copy link
Collaborator Author

pavelgj commented Jan 21, 2026

/gemini review

@pavelgj
Copy link
Collaborator Author

pavelgj commented Jan 21, 2026

@gemini-code-assist

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a comprehensive RFC document outlining bidirectional streaming capabilities for Genkit Actions, Flows, and Models. The document clearly articulates the motivation, design principles, and usage examples for defineBidiAction, defineBidiFlow, and defineBidiModel, along with the streamBidi execution API. The integration with Reflection API V2 is also well-described. The proposal is well-structured and easy to understand.

#### The Role of `init`
For real-time sessions, the connection to the model API often requires configuration (temperature, system prompt, tools) to be established *before* the first user message is received. The `init` payload fulfills this requirement, separating session configuration from the conversation stream.

- **`init`**: `GenerateRequest` (contains config, tools, system prompt).
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For clarity, consider rephrasing this to indicate that the system prompt is part of the messages array within the GenerateRequest, rather than a direct field. While GenerateRequest can contain a system prompt, it's typically nested within its messages field.

@gemini-code-assist
Copy link
Contributor

Hello @pavelgj, I have reviewed the RFC document docs/rfc-bidi-actions-flows-models.md. The proposal to introduce bidirectional streaming capabilities to Genkit Actions, Flows, and Models is clearly articulated and addresses important interaction patterns like real-time communication and session management. The design for defineBidiAction, defineBidiFlow, and defineBidiModel seems well-thought-out, providing clear examples for their usage and integration with the Reflection API. I don't have any specific concerns or suggestions at this time, as the document serves as a high-level design proposal. Please let me know if you have any further questions or require a more in-depth analysis of specific aspects.

Actions and Flows expose a `streamBidi` method that returns a `BidiStreamingResponse`.

```typescript
interface BidiStreamingResponse<O, S, I> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
interface BidiStreamingResponse<O, S, I> {
interface BidiStreamingResponse<I, O, S> {

model: 'my-model',
config: init?.config,
systemPrompt: init?.messages?.find(m => m.role === 'system'),
tools: init?.tools,
Copy link
Collaborator

@apascal07 apascal07 Jan 21, 2026

Choose a reason for hiding this comment

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

Tool requests are also streamed out, unless I'm missing something, we have no way of handling them automatically, the client will have to handle these?

Copy link
Contributor

@xavidop xavidop left a comment

Choose a reason for hiding this comment

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

This RFC is heading in a good direction, but I wonder if we can simplify the API further. Introducing defineBidiFlow adds another concept that users need to learn and distinguish from defineFlow, which may increase cognitive load without providing a clearly different mental model.

Would it be possible to support this functionality by extending defineFlow with a configuration option instead? For example, using defineFlow with a specific config to indicate bidirectional or streaming behavior would keep the API surface smaller and make it easier for users to understand what’s going on without having to learn a parallel set of abstractions.

From a usability perspective, having a single defineFlow entry point feels cleaner and more consistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants