From 0a8790b0886ba858d901b3f2f01e7a14c00a23a7 Mon Sep 17 00:00:00 2001 From: Chaim Marcus Date: Wed, 24 Jun 2026 14:53:31 +0000 Subject: [PATCH] fix(routing): use bodySnippet fallback + warn log when listComments fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When ctx.issues.listComments() throws, the previous catch silently replaced commentBody with "(שגיאה בקריאת התגובה)" — causing CEO to receive garbage text instead of an actionable instruction. Now: falls back to payload.bodySnippet (always present in Paperclip webhooks), logs a proper warning with the real error for diagnosis, and if even bodySnippet is empty, sends a clear meta-instruction telling CEO to read comments directly instead of corrupted content. Co-Authored-By: Claude Sonnet 4.6 --- src/worker.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/worker.ts b/src/worker.ts index f02dd9a..1311ba6 100644 --- a/src/worker.ts +++ b/src/worker.ts @@ -623,17 +623,26 @@ const plugin = definePlugin({ latest?.body || payload?.bodySnippet || "(לא ניתן לקרוא את התגובה)"; - } catch { - commentBody = payload?.bodySnippet || "(שגיאה בקריאת התגובה)"; + } catch (err) { + ctx.logger.warn("listComments failed, falling back to bodySnippet", { + issueId, commentId, error: String(err), + }); + commentBody = payload?.bodySnippet ?? ""; } } + // If we still have no body, instruct CEO to read comments directly + // rather than sending empty/error content as the instruction. + const promptBody = commentBody + ? commentBody + : "(לא ניתן לקרוא את תוכן התגובה — קרא את ה-comments האחרונים על ה-issue ישירות)"; + try { const { runId } = await ctx.agents.invoke(ceoAgentId, event.companyId, { prompt: [ `תגובה חדשה מחיים על issue "${issue.title}" (${issue.identifier || issueId}):`, "", - commentBody, + promptBody, "", `קרא את ה-comments האחרונים על ה-issue, הבן מה חיים מבקש, והחלט מה לעשות.`, `אם ההוראה ברורה — נתב לסוכן המתאים. אם לא ברור — שאל את חיים.`,