Skip to content

fix(py): race condition when starting dev server and implement reflection api parity and action cancellation#4225

Merged
yesudeep merged 1 commit intomainfrom
yesudeep/fix/discreet-sign
Jan 22, 2026
Merged

fix(py): race condition when starting dev server and implement reflection api parity and action cancellation#4225
yesudeep merged 1 commit intomainfrom
yesudeep/fix/discreet-sign

Conversation

@yesudeep
Copy link
Contributor

@yesudeep yesudeep commented Jan 22, 2026

fix(py): race condition when starting dev server, implement reflection api parity and action cancellation

  • Fixed race condition where the runtime metadata was written before the server was ready.
  • Implemented action cancellation support in the Reflection API.
  • Added endpoints for retrieving registered values and environment info for JS SDK parity.
  • Improved signal handling and server startup/shutdown logic.
  • Updated samples to use standard startup commands and dependencies.
  • Fixed rate limit issues in prompt demo by updating model configuration.
  • Improved error message formatting and performed general code cleanup.
  • Fixed the xai-hello sample run.sh
  • Fixed xai-hello dependency
  • Updated readmes to include more information about obtaining keys.
  • Added a preview feature to the run_sample script
Screenshot 2026-01-21 at 9 34 49 PM Screenshot 2026-01-21 at 9 39 34 PM

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @yesudeep, 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 focuses on enhancing the robustness and feature parity of the Python Genkit runtime. It resolves a critical race condition during server initialization, expands the reflection API to match its JavaScript counterpart by adding endpoints for values and environments, and introduces a much-needed action cancellation capability. These changes improve the developer experience by providing more control over the runtime and ensuring consistent behavior across different Genkit implementations.

Highlights

  • Race Condition Fix: Addressed a race condition during development server startup by implementing a 'lazy write' mechanism for runtime files and polling the reflection server's health endpoint to ensure it's fully operational before marking it as ready.
  • Reflection API Parity: Introduced new API endpoints: GET /api/values to retrieve registered default models, GET /api/envs for environment information, and POST support for /api/__quitquitquit for consistency with the JavaScript implementation.
  • Action Cancellation: Implemented a mechanism to cancel running actions via a new POST /api/cancelAction endpoint. This involves tracking active action tasks by their trace IDs and providing a callback to register tasks for cancellation.
  • Graceful Shutdown: Added SIGTERM signal handling to the Python runtime to ensure graceful shutdown of the reflection server, aligning with best practices for process management.

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

@yesudeep yesudeep force-pushed the yesudeep/fix/discreet-sign branch from cb0440f to d0e13ce Compare January 22, 2026 04:54
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 several significant features to achieve parity with the JS implementation, including new reflection API endpoints (/api/values, /api/envs, /api/cancelAction), support for POST on /api/__quitquitquit, and a mechanism for action cancellation. It also resolves a race condition during development server startup by implementing lazy writing of the runtime file. The changes are well-structured, particularly the implementation of action cancellation and the fix for the race condition. My review includes suggestions to remove dead code, organize imports according to best practices, and enhance error handling for better security and debuggability.

@yesudeep yesudeep force-pushed the yesudeep/fix/discreet-sign branch 2 times, most recently from 96324e6 to 7dd867d Compare January 22, 2026 05:15
@yesudeep yesudeep force-pushed the yesudeep/fix/discreet-sign branch 2 times, most recently from eb246ef to 24f2310 Compare January 22, 2026 05:25
@github-actions github-actions bot added the docs Improvements or additions to documentation label Jan 22, 2026
@yesudeep yesudeep force-pushed the yesudeep/fix/discreet-sign branch 3 times, most recently from 2e862ed to ed80c89 Compare January 22, 2026 05:32
@yesudeep yesudeep enabled auto-merge (squash) January 22, 2026 05:32
…n api parity and action cancellation

- Fixed race condition where the runtime metadata was written before the server was ready.
- Implemented action cancellation support in the Reflection API.
- Added endpoints for retrieving registered values and environment info for JS SDK parity.
- Improved signal handling and server startup/shutdown logic.
- Updated samples to use standard startup commands and dependencies.
- Fixed rate limit issues in prompt demo by updating model configuration.
- Improved error message formatting and performed general code cleanup.
- Fixed the xai-hello sample run.sh
- Fixed xai-hello dependency
- Updated readmes to include more information about obtaining keys.
- Added a preview feature to the run_sample script
@yesudeep yesudeep merged commit 2de3d48 into main Jan 22, 2026
10 checks passed
@yesudeep yesudeep deleted the yesudeep/fix/discreet-sign branch January 22, 2026 05:45
This was referenced Feb 4, 2026
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 fix python Python

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants