Skip to content

Commit b6ed027

Browse files
committed
🤖 fix: add context wrapper to post-compaction follow-up message
After compaction completes, the queued follow-up message was sent as raw text without any context. This made it unclear to the model that this message triggered compaction and that relevant context is in the summary. The fix wraps non-default follow-up messages with a context note: "(This was the message that triggered compaction - context is in the summary above)" The default resume sentinel ("Continue") is excluded since it's just a signal to continue, not meaningful user content. This is NOT a regression - the original implementation (dacc278, Nov 2025) always sent follow-ups as raw text. This change improves upon that design.
1 parent 5bc7135 commit b6ed027

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/node/services/agentSession.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,20 @@ export class AgentSession {
595595
const continueMessage = typedMuxMetadata.parsed.continueMessage;
596596

597597
// Process the continue message content (handles reviews -> text formatting + metadata)
598-
const { finalText, metadata } = prepareUserMessageForSend(continueMessage);
598+
const prepared = prepareUserMessageForSend(continueMessage);
599+
const { metadata } = prepared;
600+
let { finalText } = prepared;
601+
602+
// Wrap non-default follow-up with context so the model knows this was the message
603+
// that triggered compaction. The "Continue" sentinel is excluded since it's just
604+
// a resume signal, not meaningful user content.
605+
const isDefaultResume =
606+
continueMessage.text?.trim() === "Continue" &&
607+
!continueMessage.imageParts?.length &&
608+
!continueMessage.reviews?.length;
609+
if (!isDefaultResume && finalText.trim().length > 0) {
610+
finalText = `(This was the message that triggered compaction - context is in the summary above)\n\n${finalText}`;
611+
}
599612

600613
// Legacy compatibility: older clients stored `continueMessage.mode` (exec/plan) and compaction
601614
// requests run with agentId="compact". Avoid falling back to the compact agent for the

0 commit comments

Comments
 (0)