fix(acp): resolve agent mode disconnect and improve mode awareness (#26332)

This commit is contained in:
Sri Pasumarthi
2026-05-01 16:00:10 -07:00
committed by GitHub
parent 40b384de2c
commit 4e175527a2
12 changed files with 186 additions and 40 deletions
+1
View File
@@ -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());
+18 -16
View File
@@ -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();
}
}