Skip to content

Commit 294afdf

Browse files
authored
Merge pull request #2586 from nsalvacao/fix/exit-plan-mode-yolo-2522
fix(tools): exit_plan_mode now exits correctly in YOLO mode
2 parents 0776627 + d3171a3 commit 294afdf

2 files changed

Lines changed: 37 additions & 1 deletion

File tree

packages/core/src/tools/exitPlanMode.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,4 +240,35 @@ describe('ExitPlanModeTool', () => {
240240
expect(tool.description).toContain('Help me implement yank mode for vim');
241241
});
242242
});
243+
244+
describe('YOLO mode', () => {
245+
it('should exit plan mode without onConfirm being called when approval mode is YOLO', async () => {
246+
// Simulate YOLO: scheduler sets approvalMode=YOLO but never calls onConfirm
247+
approvalMode = ApprovalMode.YOLO;
248+
const params: ExitPlanModeParams = { plan: 'YOLO test plan' };
249+
const signal = new AbortController().signal;
250+
251+
const invocation = tool.build(params);
252+
// Do NOT call onConfirm — this mirrors what the YOLO scheduler does
253+
const result = await invocation.execute(signal);
254+
255+
expect(result.llmContent).toContain(
256+
'User has approved your plan. You can now start coding',
257+
);
258+
expect(result.llmContent).not.toContain('not approved');
259+
});
260+
261+
it('should not downgrade approval mode to AUTO_EDIT when YOLO', async () => {
262+
approvalMode = ApprovalMode.YOLO;
263+
const params: ExitPlanModeParams = { plan: 'YOLO test plan' };
264+
const signal = new AbortController().signal;
265+
266+
const invocation = tool.build(params);
267+
await invocation.execute(signal);
268+
269+
// Approval mode must remain YOLO — do not downgrade to AUTO_EDIT
270+
expect(mockConfig.setApprovalMode).not.toHaveBeenCalled();
271+
expect(approvalMode).toBe(ApprovalMode.YOLO);
272+
});
273+
});
243274
});

packages/core/src/tools/exitPlanMode.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,12 @@ class ExitPlanModeToolInvocation extends BaseToolInvocation<
133133
const { plan } = this.params;
134134

135135
try {
136-
if (!this.wasApproved) {
136+
// In YOLO mode the scheduler auto-approves without calling onConfirm(),
137+
// so wasApproved stays false. Treat YOLO as implicit approval.
138+
const isYolo = this.config.getApprovalMode() === ApprovalMode.YOLO;
139+
const effectivelyApproved = this.wasApproved || isYolo;
140+
141+
if (!effectivelyApproved) {
137142
const rejectionMessage =
138143
'Plan execution was not approved. Remaining in plan mode.';
139144
return {

0 commit comments

Comments
 (0)