From e40e9500dfce77a32e3b98015df7a30d3a05d7db Mon Sep 17 00:00:00 2001 From: chenxingzhen Date: Fri, 20 Mar 2026 19:11:12 +0800 Subject: [PATCH] fix: address cross-target messaging and reasoning-only payload issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. run.ts: remove didSendViaMessagingTool guard from incomplete turn detection — this boolean is too coarse and blocks cross-target sends (e.g. agent posts to slack but should still reply in originating channel). Same-origin dedup is handled downstream by buildReplyPayloads()/shouldSuppressMessagingToolReplies. 2. agent-runner-execution.ts: exclude isReasoning payloads from hasNonErrorContent check — reasoning-only payloads are dropped during delivery, so they should not prevent 429/overload error surfacing. Also remove didSendViaMessagingTool guard for same cross-target reason as run.ts. Co-Authored-By: Claude Opus 4.6 --- src/agents/pi-embedded-runner/run.ts | 1 - src/auto-reply/reply/agent-runner-execution.ts | 7 +++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/agents/pi-embedded-runner/run.ts b/src/agents/pi-embedded-runner/run.ts index a8cd1799b75..1a116495ffa 100644 --- a/src/agents/pi-embedded-runner/run.ts +++ b/src/agents/pi-embedded-runner/run.ts @@ -1615,7 +1615,6 @@ export async function runEmbeddedPiAgent( payloads.length === 0 && !aborted && !timedOut && - !attempt.didSendViaMessagingTool && !attempt.clientToolCall && !attempt.yieldDetected && !attempt.didSendDeterministicApprovalPrompt && diff --git a/src/auto-reply/reply/agent-runner-execution.ts b/src/auto-reply/reply/agent-runner-execution.ts index 9cfea79a29c..c03ae71f154 100644 --- a/src/auto-reply/reply/agent-runner-execution.ts +++ b/src/auto-reply/reply/agent-runner-execution.ts @@ -708,9 +708,12 @@ export async function runAgentTurnWithFallback(params: { // error payload into runResult so it flows through the normal // kind:"success" path — preserving streaming dedup, message_send // suppression, and usage/model metadata updates. - if (runResult && !runResult.didSendViaMessagingTool) { + if (runResult) { const hasNonErrorContent = runResult.payloads?.some( - (p) => !p.isError && (p.text?.trim() || (p.mediaUrls?.length ?? 0) > 0), + (p) => + !p.isError && + !p.isReasoning && + (p.text?.trim() || (p.mediaUrls?.length ?? 0) > 0), ); if (!hasNonErrorContent) { const metaErrorMsg = finalEmbeddedError?.message ?? "";