Skip to content

Conversation

@apascal07
Copy link
Collaborator

No description provided.

@github-actions github-actions bot added the docs Improvements or additions to documentation label Jan 16, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @apascal07, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a detailed design document for enhancing Genkit Go with robust bidirectional streaming capabilities. It proposes three new core primitives: 'BidiAction' for fundamental streaming operations, 'BidiFlow' for observable streaming, and 'SessionFlow' for managing stateful, multi-turn interactions with automatic persistence. The document comprehensively covers the API surface, integration with existing tracing and session management infrastructure, and provides concrete examples to guide implementation and usage, aiming to facilitate the development of advanced conversational agents and streaming applications.

Highlights

  • Introduction of Core Bidirectional Primitives: Details the design for 'BidiAction' (core bidi operations), 'BidiFlow' (bidi actions with observability), and 'SessionFlow' (stateful, multi-turn agent interactions with persistence).
  • Comprehensive API Design: Outlines the API for defining and interacting with these new primitives, including 'NewBidiAction', 'DefineBidiAction', 'DefineBidiFlow', 'DefineSessionFlow', and the unified 'StreamBidi' method for starting connections.
  • Advanced Session Management: Describes how 'SessionFlow' handles automatic session state persistence, including resuming existing sessions, starting new ones with initial state, and integrating with a 'session.Store'.
  • Integrated Observability and Action Registration: Explains the tracing integration for 'BidiFlows' (spans open for connection lifetime, real-time Dev UI visualization) and updates to 'ActionDesc' for 'StreamSchema' and 'InitSchema'.
  • Detailed Implementation Notes and Examples: Provides insights into error handling, goroutine management, thread safety, channel backpressure, Go 1.23 iterator usage for turn semantics, and a shutdown sequence. Includes practical examples for an echo flow and a chat agent.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

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 design document for new bidirectional streaming features in Genkit Go, including BidiAction, BidiFlow, and SessionFlow. The document is well-structured and detailed. My review focuses on ensuring the clarity and consistency of the proposed design. I've identified a significant contradiction in the description of the Stream() method's behavior which could lead to implementation errors. I've also suggested a clarification in one of the code examples to improve understanding of the multi-turn flow. Overall, this is a solid design that will be even stronger with these clarifications.

apascal07 and others added 2 commits January 16, 2026 15:59
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@apascal07 apascal07 changed the title doc(go): design for BidiAction, BidiFlow, and SessionFlow docs(go): design for BidiAction, BidiFlow, and SessionFlow Jan 17, 2026
@apascal07 apascal07 changed the title docs(go): design for BidiAction, BidiFlow, and SessionFlow doc(go): design for BidiAction, BidiFlow, and SessionFlow Jan 17, 2026
}

// SessionFlowOutput wraps the output with session info for persistence.
type SessionFlowOutput[State, Out any] struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's define these as common schemas (in genkit-tools/common/src/types) standardized across runtimes.

Copy link
Collaborator Author

@apascal07 apascal07 Jan 17, 2026

Choose a reason for hiding this comment

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

I tend to agree but we haven't been doing the core concepts (action, etc) as generated types because they have type parameters and they're just "core" to the runtime and sometimes implemented differently. But Artifact I agree.

Copy link
Collaborator Author

@apascal07 apascal07 Jan 17, 2026

Choose a reason for hiding this comment

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

In Go, we only generate types for the ai package. Not for any technical reason but that's just been the use case since they tend to be POD structs.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I mean, we literally must define these types in genkit-tools/common/src/types because we will be building Dev UI agent playground. So, not only we need zod types for the Dev UI, we also need those types to be the same across languages (which generation ensures). So, I guess I don't have a strong opinion if you want to maintain these types by hand in Go, up to you, but they need to be treated as "source of truth is in genkit-tools/common".

@apascal07 apascal07 changed the title doc(go): design for BidiAction, BidiFlow, and SessionFlow RFC: BidiAction, BidiFlow, and Agent in Go Jan 17, 2026
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.

Overall, while this design introduces useful primitives for bidirectional flows and persistence, it does not yet align with the agentic patterns seen in modern frameworks like LangChain or LlamaIndex. The current approach feels closer to a single, persistent agent rather than a true agent system where agents can call, delegate to, or coordinate with other agents.

A key limitation is the lack of clear multi-agent orchestration. Modern agent frameworks treat agents as composable units that can collaborate, delegate tasks, or be orchestrated in workflows.

Additionally, the API surface feels too low-level for end users. Concepts like bidirectional flows and actions require developers to manage execution mechanics explicitly. Many of these concerns should be handled by the framework itself, exposing a cleaner and more minimal interface that is easier to read, reason about, and scale over time.

This contrasts with existing patterns in Genkit JS and ADK, where agent definitions are more declarative and focused on intent rather than wiring. For reference, Genkit JS chat agents provide a much simpler mental model: https://genkit.dev/docs/tutorials/chat-with-pdf/#6-implement-the-ui, and ADK’s Go agent definitions show a clearer agent-first abstraction: https://google.github.io/adk-docs/get-started/go/#define-the-agent-code.

@xavidop
Copy link
Contributor

xavidop commented Jan 22, 2026

related to bidi flows:

That 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.

@apascal07
Copy link
Collaborator Author

related to bidi flows:

That 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.

There's not much we can do given the large differences in both flow inputs but also return type. They're distinctly different. Go is especially not flexible enough to handle things like this.

@apascal07
Copy link
Collaborator Author

Overall, while this design introduces useful primitives for bidirectional flows and persistence, it does not yet align with the agentic patterns seen in modern frameworks like LangChain or LlamaIndex. The current approach feels closer to a single, persistent agent rather than a true agent system where agents can call, delegate to, or coordinate with other agents.

A key limitation is the lack of clear multi-agent orchestration. Modern agent frameworks treat agents as composable units that can collaborate, delegate tasks, or be orchestrated in workflows.

What would you like to see here?

Additionally, the API surface feels too low-level for end users. Concepts like bidirectional flows and actions require developers to manage execution mechanics explicitly. Many of these concerns should be handled by the framework itself, exposing a cleaner and more minimal interface that is easier to read, reason about, and scale over time.

This contrasts with existing patterns in Genkit JS and ADK, where agent definitions are more declarative and focused on intent rather than wiring. For reference, Genkit JS chat agents provide a much simpler mental model: https://genkit.dev/docs/tutorials/chat-with-pdf/#6-implement-the-ui, and ADK’s Go agent definitions show a clearer agent-first abstraction: https://google.github.io/adk-docs/get-started/go/#define-the-agent-code.

ADK's agent concept is closer (or almost identical) to our concept of a prompt. It doesn't provide meaningful control beyond the generation and tool calling, which we do automatically as part of either prompt or generate APIs. Agent here is more about the automatic state management, turn-based streaming chats, revertible snapshots, and more while still giving you control over being able to do anything you'd like during its lifecycle. It is meant to be lower level than other "agent" abstractions given that those map to our "prompt" abstraction.

@apascal07
Copy link
Collaborator Author

@xavidop

@xavidop
Copy link
Contributor

xavidop commented Jan 22, 2026

What would you like to see here?

@apascal07

Thanks for the clarification, that helps, and I think we’re generally aligned on the intent of this abstraction being lower-level. My main point isn’t about whether this primitive should exist, but about how easy it is to build more agentic patterns on top of it.

With the current pattern, it’s somewhat hard to express agents where the agent itself decides which sub-agent or capability should run next (for example, supervisor, router, or planner-style agents). While this is definitely possible, it tends to require a fair amount of additional orchestration code, which can make these patterns less straightforward to implement and reason about.

One of the things I really appreciate about Genkit is that it’s clean, easy to use, and largely self-explainable. From experience working on teams that build AI agents in production, I’ve often seen that when users need to write a lot of glue code to express common patterns, they either look at other frameworks or end up building their own abstractions on top.

What I’d love to see here is a slightly cleaner way to express common agentic patterns where delegation and routing are easier to model. Even if this remains a low-level abstraction, having some framework-supported patterns or helpers could reduce boilerplate and make these use cases more approachable.

Overall, I think this is a useful direction, and with a bit more support for agent-driven orchestration, it could fit very nicely with Genkit’s philosophy and developer experience.

@apascal07 apascal07 changed the title RFC: BidiAction, BidiFlow, and Agent in Go RFC: [Go] BidiAction, BidiFlow, BidiModel, and Agent Jan 22, 2026
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