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, הבן מה חיים מבקש, והחלט מה לעשות.`, `אם ההוראה ברורה — נתב לסוכן המתאים. אם לא ברור — שאל את חיים.`,