fix: inject reply context into body

This commit is contained in:
Peter Steinberger
2025-12-23 02:44:38 +01:00
parent 950432eac0
commit 67a3dda53a
7 changed files with 23 additions and 6 deletions

View File

@@ -141,7 +141,8 @@ describe("createTelegramBot", () => {
expect(replySpy).toHaveBeenCalledTimes(1);
const payload = replySpy.mock.calls[0][0];
expect(payload.Body).not.toContain("Reply to Ada: Can you summarize this?");
expect(payload.Body).toContain("[Replying to Ada]");
expect(payload.Body).toContain("Can you summarize this?");
expect(payload.ReplyToId).toBe("9001");
expect(payload.ReplyToBody).toBe("Can you summarize this?");
expect(payload.ReplyToSender).toBe("Ada");

View File

@@ -124,13 +124,16 @@ export function createTelegramBot(opts: TelegramBotOptions) {
""
).trim();
if (!rawBody) return;
const replySuffix = replyTarget
? `\n\n[Replying to ${replyTarget.sender}]\n${replyTarget.body}\n[/Replying]`
: "";
const body = formatAgentEnvelope({
surface: "Telegram",
from: isGroup
? buildGroupLabel(msg, chatId)
: buildSenderLabel(msg, chatId),
timestamp: msg.date ? msg.date * 1000 : undefined,
body: rawBody,
body: `${rawBody}${replySuffix}`,
});
const ctxPayload = {