
























@@ -458,6 +458,90 @@ describe("runPreparedReply media-only handling", () => {
458458expect(vi.mocked(runReplyAgent)).not.toHaveBeenCalled();
459459});
460460461+it("allows pending inbound history to trigger a bare mention turn", async () => {
462+vi.mocked(buildInboundUserContextPrefix).mockReturnValueOnce(
463+[
464+"Chat history since last reply (untrusted, for context):",
465+"```json",
466+JSON.stringify(
467+[{ sender: "Alice", timestamp_ms: 1_700_000_000_000, body: "what changed?" }],
468+null,
469+2,
470+),
471+"```",
472+].join("\n"),
473+);
474+475+const result = await runPreparedReply(
476+baseParams({
477+ctx: {
478+Body: "",
479+RawBody: "",
480+CommandBody: "",
481+ChatType: "group",
482+WasMentioned: true,
483+},
484+sessionCtx: {
485+Body: "",
486+BodyStripped: "",
487+Provider: "feishu",
488+OriginatingChannel: "feishu",
489+OriginatingTo: "chat-1",
490+ChatType: "group",
491+WasMentioned: true,
492+InboundHistory: [
493+{ sender: "Alice", timestamp: 1_700_000_000_000, body: "what changed?" },
494+],
495+},
496+}),
497+);
498+499+expect(result).toEqual({ text: "ok" });
500+expect(vi.mocked(runReplyAgent)).toHaveBeenCalledOnce();
501+const call = vi.mocked(runReplyAgent).mock.calls[0]?.[0];
502+expect(call?.followupRun.prompt).toContain("Chat history since last reply");
503+expect(call?.followupRun.prompt).toContain("what changed?");
504+expect(call?.followupRun.prompt).not.toContain("[User sent media without caption]");
505+});
506+507+it("does not treat blank pending inbound history as user input", async () => {
508+vi.mocked(buildInboundUserContextPrefix).mockReturnValueOnce(
509+[
510+"Chat history since last reply (untrusted, for context):",
511+"```json",
512+JSON.stringify([{ sender: "Alice", timestamp_ms: 1_700_000_000_000, body: "" }], null, 2),
513+"```",
514+].join("\n"),
515+);
516+517+const result = await runPreparedReply(
518+baseParams({
519+ctx: {
520+Body: "",
521+RawBody: "",
522+CommandBody: "",
523+ChatType: "group",
524+WasMentioned: true,
525+},
526+sessionCtx: {
527+Body: "",
528+BodyStripped: "",
529+Provider: "feishu",
530+OriginatingChannel: "feishu",
531+OriginatingTo: "chat-1",
532+ChatType: "group",
533+WasMentioned: true,
534+InboundHistory: [{ sender: "Alice", timestamp: 1_700_000_000_000, body: "\u0000 " }],
535+},
536+}),
537+);
538+539+expect(result).toEqual({
540+text: "I didn't receive any text in your message. Please resend or add a caption.",
541+});
542+expect(vi.mocked(runReplyAgent)).not.toHaveBeenCalled();
543+});
544+461545it("allows webchat pure-image turns when image content is carried outside MediaPath", async () => {
462546vi.mocked(buildInboundUserContextPrefix).mockReturnValueOnce(
463547[
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。