fix: address cross-target messaging and reasoning-only payload issues

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 <noreply@anthropic.com>
This commit is contained in:
chenxingzhen
2026-03-20 19:11:12 +08:00
committed by Josh Lehman
parent 5ff4522e74
commit e40e9500df
2 changed files with 5 additions and 3 deletions

View File

@@ -1615,7 +1615,6 @@ export async function runEmbeddedPiAgent(
payloads.length === 0 &&
!aborted &&
!timedOut &&
!attempt.didSendViaMessagingTool &&
!attempt.clientToolCall &&
!attempt.yieldDetected &&
!attempt.didSendDeterministicApprovalPrompt &&

View File

@@ -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 ?? "";