fix: acp/zed race condition between MCP initialisation and prompt#20205
fix: acp/zed race condition between MCP initialisation and prompt#20205scidomino merged 4 commits intogoogle-gemini:mainfrom
Conversation
Signed-off-by: Kartik Angiras <angiraskartik@gmail.com>
Summary of ChangesHello @kartikangiras, 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 resolves a critical race condition in the ACP/Zed mode that caused inconsistent model responses due to premature handling of prompts before MCP server connections were fully initialized. The changes ensure that the system reliably waits for MCP initialization, providing a more stable and consistent user experience. Additionally, unit tests were added to validate the fix. Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request addresses a race condition where prompts could be handled before MCP server initialization was complete. This is fixed by introducing a mechanism to await MCP initialization within the Config class. This mechanism is then used in the a2a-server and Zed integration code paths to ensure MCP servers are ready before processing prompts. The changes include corresponding updates to tests to validate the new behavior.
packages/core/src/config/config.ts
Outdated
| } | ||
| }); | ||
|
|
||
| this.mcpInitializationPromise = mcpInitialization; |
There was a problem hiding this comment.
Remove the mcpInitialization variable and just immediately assign it to this.mcpInitializationPromise
There was a problem hiding this comment.
i have assigned it to the this.mcpInitializationPromise
5c5b98d to
0157330
Compare
|
please revert the changes to package-lock.json. |
Signed-off-by: Kartik Angiras <angiraskartik@gmail.com>
07e6033 to
f3e9942
Compare
|
@scidomino i have reverted the changes to package-lock.json. |
…ogle-gemini#20205) Signed-off-by: Kartik Angiras <angiraskartik@gmail.com>
…ogle-gemini#20205) Signed-off-by: Kartik Angiras <angiraskartik@gmail.com>
Summary
Fix a race condition in ACP/Zed mode where GeminiAgent.prompt could be handled before MCP server connections had finished initialising, causing the model to produce inconsistent responses.
Details
Config.initialize()intentionally starts MCP server connections in the background so the interactive CLI prompt appears quickly.Two code paths violated this contract:
config.tssetinteractive: truewithoutexperimentalZedIntegration: true, so MCP always ran in the background and was never awaited — even though the a2a-server is not a terminal and has no reason to skip waiting.zedIntegration.tshad no guard to wait for MCP to be ready before invoking the model.Related Issues
fixes #18893
How to Validate
Pre-Merge Checklist