A reply read the session once at the start, so a message sent while it ran was never seen, and the follow-up reply queued for it then finished silently: the message was saved before the reply, so the thread ended with the bot. Those messages went unanswered. The text loop now reads new user messages after every round of tools and before an answer goes out, and the bot decides from what each one means whether it changes the work (folded in, or the unsent answer redrafted) or is a separate request, which it acknowledges at once with the new send_message tool and does after the current work. Messages sent that way are marked interim, so the thinking row stays up while the bot works. A reply job records the newest user message it read, and a queued reply only stays silent when a finished reply already read everything. Co-Authored-By: Claude Opus 5.5 <[email protected]>
30 lines
1.2 KiB
TypeScript
30 lines
1.2 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import isAwaitingReply from "./is-awaiting-reply";
|
|
|
|
describe("isAwaitingReply", () => {
|
|
test("the user having the last word owes a reply", () => {
|
|
expect(isAwaitingReply({ last_message: { author: "user" }, face: "idle" })).toBe(true);
|
|
});
|
|
|
|
test("an acknowledgement sent mid-reply keeps it due while the bot works", () => {
|
|
expect(isAwaitingReply({ last_message: { author: "bot", interim: 1 }, face: "working" })).toBe(
|
|
true,
|
|
);
|
|
});
|
|
|
|
test("once the reply is over, an acknowledgement left last owes nothing", () => {
|
|
expect(isAwaitingReply({ last_message: { author: "bot", interim: 1 }, face: "idle" })).toBe(false);
|
|
});
|
|
|
|
test("an answer owes nothing, even while the bot works elsewhere", () => {
|
|
expect(isAwaitingReply({ last_message: { author: "bot", interim: 0 }, face: "working" })).toBe(
|
|
false,
|
|
);
|
|
expect(isAwaitingReply({ last_message: { author: "bot" }, face: "working" })).toBe(false);
|
|
});
|
|
|
|
test("an empty thread owes nothing", () => {
|
|
expect(isAwaitingReply({ last_message: null, face: "working" })).toBe(false);
|
|
});
|
|
});
|