fix: address P2 review comments on compaction notices
P2-1 (agent-runner.ts): Restrict direct completion notice to block-streaming runs. The condition now checks blockStreamingEnabled in addition to opts?.onBlockReply, preventing duplicate completion notices in non-streaming sessions where verboseNotices already handles the compaction-complete text. P2-2 (agent-runner-execution.ts): Emit compaction start notice when streaming is off. blockReplyHandler is a no-op for non-streaming runs, so add a direct fallback path: when blockStreamingEnabled is false and opts.onBlockReply is present, send the start notice directly with applyReplyToMode threading applied.
This commit is contained in:
parent
197ef0a1f5
commit
bcc2d2188e
@ -418,10 +418,24 @@ export async function runAgentTurnWithFallback(params: {
|
||||
if (phase === "start") {
|
||||
if (params.opts?.onCompactionStart) {
|
||||
await params.opts.onCompactionStart();
|
||||
} else {
|
||||
} else if (params.blockStreamingEnabled) {
|
||||
// Route through the shared block reply handler so
|
||||
// reply-to threading matches other in-run notices.
|
||||
await blockReplyHandler?.({ text: "🧹 Compacting context..." });
|
||||
} else if (params.opts?.onBlockReply) {
|
||||
// blockReplyHandler is a no-op when streaming is disabled.
|
||||
// Fall back to direct delivery so non-streaming runs also
|
||||
// receive the compaction start notice.
|
||||
const currentMessageId =
|
||||
params.sessionCtx.MessageSidFull ?? params.sessionCtx.MessageSid;
|
||||
const noticePayload = params.applyReplyToMode({
|
||||
text: "🧹 Compacting context...",
|
||||
replyToId: currentMessageId,
|
||||
replyToCurrent: true,
|
||||
});
|
||||
await params.opts.onBlockReply(noticePayload);
|
||||
} else {
|
||||
await params.opts?.onBlockReply?.({ text: "🧹 Compacting context..." });
|
||||
}
|
||||
}
|
||||
const completed = evt.data?.completed === true;
|
||||
|
||||
@ -423,7 +423,7 @@ export async function runReplyAgent(params: {
|
||||
// stopped, so the enqueue does not set didStream() = true and cause
|
||||
// buildReplyPayloads to discard the real assistant reply. We still apply a
|
||||
// timeout so the notice cannot stall the run indefinitely.
|
||||
if (autoCompactionCompleted && opts?.onBlockReply) {
|
||||
if (autoCompactionCompleted && blockStreamingEnabled && opts?.onBlockReply) {
|
||||
const verboseEnabled = resolvedVerboseLevel !== "off";
|
||||
const completionText = verboseEnabled
|
||||
? `🧹 Auto-compaction complete.`
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user