mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-14 05:42:54 -07:00
fix(acp): resolve agent mode disconnect and improve mode awareness (#26332)
This commit is contained in:
@@ -203,6 +203,7 @@ const mockCoreEvents = vi.hoisted(() => ({
|
||||
emitConsoleLog: vi.fn(),
|
||||
emitQuotaChanged: vi.fn(),
|
||||
on: vi.fn(),
|
||||
emit: vi.fn(),
|
||||
}));
|
||||
|
||||
const mockSetGlobalProxy = vi.hoisted(() => vi.fn());
|
||||
|
||||
@@ -2697,26 +2697,28 @@ export class Config implements McpContext, AgentLoopContext {
|
||||
this,
|
||||
new ApprovalModeSwitchEvent(currentMode, mode),
|
||||
);
|
||||
}
|
||||
|
||||
this.policyEngine.setApprovalMode(mode);
|
||||
this.refreshSandboxManager();
|
||||
this.policyEngine.setApprovalMode(mode);
|
||||
this.refreshSandboxManager();
|
||||
coreEvents.emit(CoreEvent.ApprovalModeChanged, {
|
||||
sessionId: this.getSessionId(),
|
||||
mode,
|
||||
});
|
||||
|
||||
const isPlanModeTransition =
|
||||
currentMode !== mode &&
|
||||
(currentMode === ApprovalMode.PLAN || mode === ApprovalMode.PLAN);
|
||||
const isYoloModeTransition =
|
||||
currentMode !== mode &&
|
||||
(currentMode === ApprovalMode.YOLO || mode === ApprovalMode.YOLO);
|
||||
const isPlanModeTransition =
|
||||
currentMode === ApprovalMode.PLAN || mode === ApprovalMode.PLAN;
|
||||
const isYoloModeTransition =
|
||||
currentMode === ApprovalMode.YOLO || mode === ApprovalMode.YOLO;
|
||||
|
||||
if (isPlanModeTransition || isYoloModeTransition) {
|
||||
if (this._geminiClient?.isInitialized()) {
|
||||
this._geminiClient.clearCurrentSequenceModel();
|
||||
this._geminiClient.setTools().catch((err) => {
|
||||
debugLogger.error('Failed to update tools', err);
|
||||
});
|
||||
if (isPlanModeTransition || isYoloModeTransition) {
|
||||
if (this._geminiClient?.isInitialized()) {
|
||||
this._geminiClient.clearCurrentSequenceModel();
|
||||
this._geminiClient.setTools().catch((err) => {
|
||||
debugLogger.error('Failed to update tools', err);
|
||||
});
|
||||
}
|
||||
this.updateSystemInstructionIfInitialized();
|
||||
}
|
||||
this.updateSystemInstructionIfInitialized();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user