fix: enforce final tag gating (#754) (thanks @mcinteerj)

This commit is contained in:
Peter Steinberger
2026-01-12 08:45:23 +00:00
parent a7cb270999
commit 252841ab13
5 changed files with 13 additions and 52 deletions

View File

@@ -16,7 +16,7 @@ describe("subscribeEmbeddedPiSession", () => {
{ tag: "thought", open: "<thought>", close: "</thought>" },
{ tag: "antthinking", open: "<antthinking>", close: "</antthinking>" },
] as const;
it("filters to <final> and falls back when tags are malformed", () => {
it("filters to <final> and suppresses output without a start tag", () => {
let handler: ((evt: unknown) => void) | undefined;
const session: StubSession = {
subscribe: (fn) => {
@@ -38,6 +38,7 @@ describe("subscribeEmbeddedPiSession", () => {
onAgentEvent,
});
handler?.({ type: "message_start", message: { role: "assistant" } });
handler?.({
type: "message_update",
message: { role: "assistant" },
@@ -53,11 +54,7 @@ describe("subscribeEmbeddedPiSession", () => {
onPartialReply.mockReset();
handler?.({
type: "message_end",
message: { role: "assistant" },
});
handler?.({ type: "message_start", message: { role: "assistant" } });
handler?.({
type: "message_update",
message: { role: "assistant" },
@@ -67,8 +64,7 @@ describe("subscribeEmbeddedPiSession", () => {
},
});
const secondPayload = onPartialReply.mock.calls[0][0];
expect(secondPayload.text).toContain("Oops no start");
expect(onPartialReply).not.toHaveBeenCalled();
});
it("does not require <final> when enforcement is off", () => {