mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 16:28:26 +00:00
fix: enforce final tag gating (#754) (thanks @mcinteerj)
This commit is contained in:
@@ -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", () => {
|
||||
|
||||
Reference in New Issue
Block a user