fix(compaction): route plan-mode guidance via internalGuidance channel
Plan-approval's 'Approve and compact context' used to pass the rendered plan-mode-compact-instructions prompt as the first positional argument to handleCompactCommand -> session.compact(), which landed on the session_before_compact extension hook as customInstructions. Extensions treating that field as user focus (e.g. to bias a query-focused summary) would then see plan-mode boilerplate instead of operator intent and produce query-biased compactions. Add CompactOptions.internalGuidance: a private summarizer-only channel. session.compact() reads it into the fallback-model summarizer while the session_before_compact hook payload still only carries the public customInstructions arg (undefined for the plan-compact path). The snapcompact-disable predicate and the /compact rejectsFocus guard cover both fields so a directed summary is never silently downgraded. Extend the interactive-mode handleCompactCommand facade + command controller with a fourth internalGuidance parameter, and switch the plan-approval callsite in interactive-mode.ts to route the plan prompt through it. Fixes #4359
This commit is contained in:
@@ -1124,6 +1124,7 @@ export class CommandController {
|
||||
customInstructions?: string,
|
||||
mode?: CompactMode,
|
||||
beforeFlush?: (outcome: CompactionOutcome) => void | Promise<void>,
|
||||
internalGuidance?: string,
|
||||
): Promise<CompactionOutcome> {
|
||||
const entries = this.ctx.sessionManager.getEntries();
|
||||
const messageCount = entries.filter(e => e.type === "message").length;
|
||||
@@ -1133,6 +1134,15 @@ export class CommandController {
|
||||
return "ok";
|
||||
}
|
||||
|
||||
// `internalGuidance` is a private summarizer directive (plan-mode
|
||||
// "Approve and compact context") that MUST stay off the public
|
||||
// `customInstructions` channel of the `session_before_compact` extension
|
||||
// hook — extensions treat that field as user focus and would otherwise
|
||||
// bias the summary toward the plan boilerplate (issue #4359). Ride it
|
||||
// through as a CompactOptions field instead.
|
||||
if (internalGuidance) {
|
||||
return this.executeCompaction({ internalGuidance, ...(mode ? { mode } : {}) }, false, beforeFlush, mode);
|
||||
}
|
||||
return this.executeCompaction(customInstructions, false, beforeFlush, mode);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user