feat(core): isolate sub-agent activeExtensionName via AsyncLocalStorage#25396
Conversation
…prompt via activeExtensionName
🛑 Action Required: Evaluation ApprovalSteering changes have been detected in this PR. To prevent regressions, a maintainer must approve the evaluation run before this PR can be merged. Maintainers:
Once approved, the evaluation results will be posted here automatically. |
Summary of ChangesHello, 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 enhances the dynamic extension plan directory resolution by introducing a mechanism to isolate the Highlights
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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces scoped isolation for the active extension name using AsyncLocalStorage, ensuring that sub-agents do not leak context. It updates the Config class and various tools, including Edit, WriteFile, and ExitPlanMode, to retrieve extension-specific settings such as the plans directory. A review comment correctly identifies code duplication in exit-plan-mode.ts regarding the resolution of the plans directory, suggesting a refactor for better consistency.
| private getResolvedPlansDir(): string { | ||
| let customDir: string | undefined; | ||
| const activeExt = this.config.activeExtensionName; | ||
| if (activeExt) { | ||
| customDir = this.config.getExtensionSetting<string>( | ||
| activeExt, | ||
| 'plan.directory', | ||
| ); | ||
| } | ||
| return this.config.storage.getPlansDir(customDir); | ||
| } |
There was a problem hiding this comment.
This getResolvedPlansDir method is a duplicate of the one in the ExitPlanModeTool class (lines 56-66). To ensure consistent path resolution, use a single, robust function (like resolveToRealPath) for all related path validations across components. Consider refactoring to remove this duplication, for instance by resolving the plans directory once in ExitPlanModeTool and passing it to the ExitPlanModeInvocation constructor.
References
- Ensure consistent path resolution by using a single, robust function (e.g., resolveToRealPath) for all related path validations, including internal validations in components like WorkspaceContext.
ece2b0c to
0bb1927
Compare
0bb1927 to
aad3e4b
Compare
|
Hi there! Thank you for your interest in contributing to Gemini CLI. To ensure we maintain high code quality and focus on our prioritized roadmap, we have updated our contribution policy (see Discussion #17383). We only guarantee review and consideration of pull requests for issues that are explicitly labeled as 'help wanted'. All other community pull requests are subject to closure after 14 days if they do not align with our current focus areas. For this reason, we strongly recommend that contributors only submit pull requests against issues explicitly labeled as 'help-wanted'. This pull request is being closed as it has been open for 14 days without a 'help wanted' designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding and for being part of our community! |
Summary
Phase 4 of the dynamic extension plan directory resolution implementation. This PR introduces the concept of an
activeExtensionNamethroughout theConfigandAgentLoopContextand implements robustAsyncLocalStorageisolation for sub-agents.Details
Configto trackactiveExtensionNamealongsideWorkspaceContext.AsyncLocalStorageinscoped-config.tsto implementrunWithScopedActiveExtension. This ensures that any context switches triggered by a sub-agent (e.g., executing a command that activates an extension context) remain isolated and do not leak back and pollute the global main session.Related Issues
Depends on Phase 3 (PR #25384).
How to Validate
Run unit tests for scoped config execution:
npm test -w @google/gemini-cli-core -- src/config/scoped-config.test.ts src/agents/local-executor.test.tsPre-Merge Checklist