fix(agent): keep approved plan readable

This commit is contained in:
can1357
2026-07-01 20:47:22 +02:00
parent 569b83d5a6
commit 070143682e
2 changed files with 11 additions and 10 deletions
@@ -2601,11 +2601,10 @@ export class InteractiveMode implements InteractiveModeContext {
this.session.clearPlanInternalAbortPending();
}
// Tool restoration runs on every path — the plan mode tools must be
// retired regardless of whether the synthetic prompt fires.
if (previousTools.length > 0) {
await this.session.setActiveToolsByName(previousTools);
}
// Restore the execution tool set, but force-enable `read`: approved-plan
// prompts now require loading the durable local:// plan file before work.
const executionTools = previousTools.includes("read") ? previousTools : [...previousTools, "read"];
await this.session.setActiveToolsByName(executionTools);
this.session.setPlanReferencePath(options.planFilePath);
// Resolve the deferred plan-approval model transition. On the compact path
@@ -228,9 +228,10 @@ describe("AgentSession approved-plan reference re-injection after compaction (is
emitHighUsageTurn(session);
const continuation = await waitForCall(call => call.messageTexts.some(text => text.includes(CONTINUE_MARKER)));
// The post-compaction continuation MUST carry the plan reference again.
expect(continuation.messageTexts.some(text => text.includes(planMarker))).toBe(true);
expect(continuation.messageTexts.some(text => text.includes(`<plan path="${planUrl}">`))).toBe(true);
// The post-compaction continuation MUST carry the durable plan reference again.
expect(continuation.messageTexts.some(text => text.includes(planMarker))).toBe(false);
expect(continuation.messageTexts.some(text => text.includes(planUrl))).toBe(true);
expect(continuation.messageTexts.some(text => text.includes(`MUST read \`${planUrl}\``))).toBe(true);
});
it("re-injects the approved plan reference after snapcompact auto-compaction", async () => {
@@ -251,8 +252,9 @@ describe("AgentSession approved-plan reference re-injection after compaction (is
emitHighUsageTurn(session);
const continuation = await waitForCall(call => call.messageTexts.some(text => text.includes(CONTINUE_MARKER)));
expect(continuation.messageTexts.some(text => text.includes(planMarker))).toBe(true);
expect(continuation.messageTexts.some(text => text.includes(`<plan path="${planUrl}">`))).toBe(true);
expect(continuation.messageTexts.some(text => text.includes(planMarker))).toBe(false);
expect(continuation.messageTexts.some(text => text.includes(planUrl))).toBe(true);
expect(continuation.messageTexts.some(text => text.includes(`MUST read \`${planUrl}\``))).toBe(true);
});
// Blast-radius guard: clearing the flag on every compaction must NOT start