Repository navigation
Conversation
| if (queueSettings.mode === "collect") { | ||
| const origin = resolveAnnounceOrigin(entry, params.requesterOrigin); | ||
| enqueueAnnounce({ | ||
| key: canonicalKey, | ||
| item: { | ||
| prompt: params.triggerMessage, | ||
| summaryLine: params.summaryLine, | ||
| enqueuedAt: Date.now(), | ||
| sessionKey: canonicalKey, | ||
| origin, | ||
| }, | ||
| settings: queueSettings, | ||
| send: sendAnnounce, | ||
| }); | ||
| return "queued"; | ||
| } |
There was a problem hiding this comment.
Missing announceId in collect-mode queue item
The new collect-mode early-return path omits announceId from the enqueued item, while the existing followup/steer/interrupt path at line 412 includes it. Without announceId, resolveQueueAnnounceId falls back to a timestamp-based legacy key using Date.now(), which is non-deterministic. If the same announcement is processed twice (e.g., retry or race), the timestamp values may differ, producing different idempotency keys and potentially allowing duplicate announces through the gateway dedup cache.
Consider adding announceId: params.announceId to the item object, matching the pattern used at line 412.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agents/subagent-announce.ts
Line: 386-401
Comment:
**Missing `announceId` in collect-mode queue item**
The new collect-mode early-return path omits `announceId` from the enqueued item, while the existing followup/steer/interrupt path at line 412 includes it. Without `announceId`, `resolveQueueAnnounceId` falls back to a timestamp-based legacy key using `Date.now()`, which is non-deterministic. If the same announcement is processed twice (e.g., retry or race), the timestamp values may differ, producing different idempotency keys and potentially allowing duplicate announces through the gateway dedup cache.
Consider adding `announceId: params.announceId` to the item object, matching the pattern used at line 412.
How can I resolve this? If you propose a fix, please make it concise.|
This pull request has been automatically marked as stale due to inactivity. |
|
Still relevant — removing stale label. Will rebase if needed. |
Co-Authored-By: Claude Opus 4.6 <[email protected]>
…Text The splice in finalizeAssistantTexts() only removed entries from the internal assistantTexts array — by that point emitBlockChunk() had already fired onBlockReply() which sent text to Discord immediately. Buffer onBlockReply payloads when suppressPreToolText is active, flush on final answer (stopReason !== "toolUse"), discard on tool-use turns.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
Yeah, I am running this, as it's super annoying |
…enclaw#19932) Buffer all onBlockReply payloads during each assistant turn; at message_end, discard the buffer when stopReason === "toolUse" (tool-calling turn) or flush it when stopReason === "stop" (final answer). Handles both text_end (streaming) and message_end (non-streaming) delivery paths. Adds EmbeddedPiSubscribeState.suppressPreToolText (enabled whenever onBlockReply is registered) and pendingBlockReplies buffer. Both the outer emitBlockReplySafely in subscribeEmbeddedPiSession (streaming/text_end path) and the local one in handleMessageEnd (message_end path) buffer through pendingBlockReplies. Regression test covers text_end mode (streaming), message_end mode, and multiple intermediate turns all suppressed before a single final delivery. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…scard (openclaw#19932) The previous suppression fix buffered onBlockReply calls and discarded them for toolUse turns — preventing intermediate text from being streamed to Mattermost as separate messages. But the texts were already pushed to state.assistantTexts in emitBlockChunk before the stopReason was known. This meant they survived in the final reply payload (hasSentPayload deduplication can't filter them because they never touched the pipeline). Fix: capture preTurnAssistantTextBaseline at the start of handleMessageEnd (before finalizeAssistantTexts updates it), and when discarding for toolUse, splice assistantTexts back to that baseline and reset the baseline. Adds a regression test verifying intermediate texts are absent from assistantTexts after a toolUse turn.
|
This pull request has been automatically marked as stale due to inactivity. |
…enclaw#19932) Buffer all onBlockReply payloads during each assistant turn; at message_end, discard the buffer when stopReason === "toolUse" (tool-calling turn) or flush it when stopReason === "stop" (final answer). Handles both text_end (streaming) and message_end (non-streaming) delivery paths. Adds EmbeddedPiSubscribeState.suppressPreToolText (enabled whenever onBlockReply is registered) and pendingBlockReplies buffer. Both the outer emitBlockReplySafely in subscribeEmbeddedPiSession (streaming/text_end path) and the local one in handleMessageEnd (message_end path) buffer through pendingBlockReplies. Regression test covers text_end mode (streaming), message_end mode, and multiple intermediate turns all suppressed before a single final delivery. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…scard (openclaw#19932) The previous suppression fix buffered onBlockReply calls and discarded them for toolUse turns — preventing intermediate text from being streamed to Mattermost as separate messages. But the texts were already pushed to state.assistantTexts in emitBlockChunk before the stopReason was known. This meant they survived in the final reply payload (hasSentPayload deduplication can't filter them because they never touched the pipeline). Fix: capture preTurnAssistantTextBaseline at the start of handleMessageEnd (before finalizeAssistantTexts updates it), and when discarding for toolUse, splice assistantTexts back to that baseline and reset the baseline. Adds a regression test verifying intermediate texts are absent from assistantTexts after a toolUse turn.
|
This pull request has been automatically marked as stale due to inactivity. |
|
Closing due to inactivity. |
Summary
Adds a
suppressPreToolTextoption to agent defaults that discards intermediate assistant text from tool-use turns (e.g. "Let me check that for you...") before they reach the channel. This is useful for Discord bots where pre-tool narration creates noise.Changes
Commit 1:
fix(agents): batch announces + suppress pre-tool textagents.defaults.suppressPreToolTextconfig option (boolean, default: false)AgentDefaultsConfig→RunEmbeddedPiAgentParams→SubscribeEmbeddedPiSessionParams→ subscribe stateemitBlockChunk()skips text emission whensuppressPreToolTextis enabled and the turn contains tool usehandleMessageEnd()/finalizeAssistantTexts()properly handle the suppress flagcollectModefor subagent announce batching (related improvement)Commit 2:
fix(agents): buffer onBlockReply during streamingpendingBlockRepliesbuffer in the subscribe handlersuppressPreToolTextis enabled, block replies are buffered during streamingmessage_end, if the message contains tool use, buffered replies are discardedConfig example
Testing
pi-embedded-subscribe.suppress-pre-tool-text.test.tszod-schema.agent-defaults.suppress-pre-tool-text.test.tsGreptile Summary
This PR adds a
suppressPreToolTextconfig option that buffersonBlockReplypayloads during assistant message streaming and discards them if the message ends with a tool call (stopReason === "toolUse"). This prevents intermediate narration like "Let me check that for you..." from reaching Discord/messaging channels. Final-answer turns are flushed normally.The implementation touches the full config-to-subscribe pipeline:
AgentDefaultsConfig->FollowupRun->RunEmbeddedPiAgentParams->SubscribeEmbeddedPiSessionParams-> subscribe state, which is clean and consistent.A secondary change fixes collect-mode subagent announce batching to always queue (even when the parent agent is idle), and bumps the default announce debounce from 1s to 3s.
suppressPreToolTextcorrectly buffers and discards intermediate text, with verbose-mode bypass for debuggingassistantTextssplice logic removes intermediate texts from the accumulated array on tool-use turnspendingBlockRepliesbuffer is properly initialized, reset on message boundaries, and flushed/discarded at the end ofhandleMessageEndsubagent-announce.tsomitsannounceIdfrom the queue item, which may weaken idempotency dedup (see inline comment)blockReplyBreakmodesConfidence Score: 4/5
Last reviewed commit: cd2462d