Skip to content

Conversation

@huangjeff5
Copy link
Contributor

Consolidate session/chat under blocks, drop ai-level session/chat surfaces, and
introduce shared interfaces to avoid type-only import cycles.

@huangjeff5 huangjeff5 requested a review from yesudeep January 29, 2026 22:59
@github-actions github-actions bot added docs Improvements or additions to documentation python Python config refactor labels Jan 29, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @huangjeff5, 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 significantly refactors the Python Genkit library by consolidating session and chat functionalities under the genkit.blocks module. The primary goal is to simplify the public genkit.ai API by removing direct session and chat entry points, while enhancing the internal architecture through the introduction of shared interfaces. These new interfaces are crucial for breaking import cycles and improving type safety across different modules, leading to a more robust and maintainable codebase.

Highlights

  • Consolidation of Session and Chat Functionality: The core session and chat management logic has been moved from the top-level genkit.session module into genkit.blocks.session, centralizing block-related components.
  • Removal of Public AI-Level Session/Chat APIs: Direct ai.create_session(), ai.load_session(), and ai.chat() methods have been removed from the genkit.ai public interface, streamlining the top-level API.
  • Introduction of Shared Interfaces for Type Safety: New Input, Output, GenkitLike, SessionLike, and ExecutablePromptLike interfaces (protocols) have been introduced in genkit.blocks.interfaces to resolve type-only import cycles and improve modularity.
  • Refactored Chat Message Handling: The Chat class's send and send_stream methods now explicitly manage message history by appending user prompts before generation and model responses after, ensuring consistent state updates.
  • Removal of Session and Chat Demos: The chat-demo and session-demo sample applications have been removed, likely due to their reliance on the deprecated AI-level session/chat APIs.

🧠 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 is a significant refactoring that moves the session and chat management logic into the genkit.blocks package and removes the public API surface from the top-level genkit.ai module. This is a good architectural improvement that helps to better organize the code. A key part of this change is the introduction of a new genkit.blocks.interfaces module, which defines shared protocols like SessionLike and GenkitLike to break circular dependencies. The implementations of chat.send() and chat.send_stream() have also been simplified. Additionally, several demo applications have been removed, presumably because they relied on the now-internalized public APIs.

My review has identified one critical issue: a syntax error in py/packages/genkit/src/genkit/ai/_registry.py due to incorrect indentation after removing a TYPE_CHECKING block. I've also provided a medium-severity suggestion to restore the detailed docstrings for the send and send_stream methods in chat.py, as the examples and parameter explanations were valuable for users.

Overall, the refactoring is well done and improves the codebase structure, pending the fix for the critical syntax error.

@huangjeff5 huangjeff5 marked this pull request as ready for review January 30, 2026 00:06
@huangjeff5 huangjeff5 enabled auto-merge (squash) January 30, 2026 02:56
@huangjeff5 huangjeff5 merged commit 8dbe8f1 into main Jan 30, 2026
22 checks passed
@huangjeff5 huangjeff5 deleted the jh-refactor-typecycles branch January 30, 2026 02:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config docs Improvements or additions to documentation python Python refactor

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants