fix(rectification): persist the next interview after a choice tap
Closing a discriminator used to leave GET without a card after refresh. Write the next dated question in the same request, skip childhood career and move probes, and do not continue a read-only turn when that question is already persisted. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -28,9 +28,14 @@ test("does not publish intermediate tool-step text as answer.delta", () => {
|
||||
isPublicTool,
|
||||
);
|
||||
assert.equal(afterTool.kind, "discard");
|
||||
applyStepAnswerChunk(state, chunk("text-delta", { text: "记下了,2020年4月开始实习。" }), isPublicTool);
|
||||
const live = applyStepAnswerChunk(
|
||||
state,
|
||||
chunk("text-delta", { text: "记下了,2020年4月开始实习。" }),
|
||||
isPublicTool,
|
||||
);
|
||||
assert.deepEqual(live, { kind: "live", text: "记下了,2020年4月开始实习。" });
|
||||
const finish = applyStepAnswerChunk(state, chunk("step-finish", { reason: "stop" }), isPublicTool);
|
||||
assert.deepEqual(finish, { kind: "publish", pieces: ["记下了,2020年4月开始实习。"] });
|
||||
assert.equal(finish.kind, "none");
|
||||
});
|
||||
|
||||
test("never publishes reasoning-delta to the browser", () => {
|
||||
@@ -47,7 +52,76 @@ test("publishes only the terminal no-tool step as assistant text", () => {
|
||||
applyStepAnswerChunk(state, chunk("step-finish", { stepResult: { reason: "tool-calls" } }), isPublicTool);
|
||||
assert.equal(shouldPublishStepText({ calledTool: true, text: "_probe" }, "tool-calls"), false);
|
||||
applyStepAnswerChunk(state, chunk("step-start"), isPublicTool);
|
||||
applyStepAnswerChunk(state, chunk("text-delta", { text: "已经记下实习。" }), isPublicTool);
|
||||
const live = applyStepAnswerChunk(state, chunk("text-delta", { text: "已经记下实习。" }), isPublicTool);
|
||||
assert.deepEqual(live, { kind: "live", text: "已经记下实习。" });
|
||||
const finish = flushStepAnswerOnStreamFinish(state, "stop");
|
||||
assert.deepEqual(finish, { kind: "publish", pieces: ["已经记下实习。"] });
|
||||
assert.equal(finish.kind, "none");
|
||||
});
|
||||
|
||||
test("streams terminal Chinese tokens live after compare", () => {
|
||||
const state = createStepAnswerState();
|
||||
applyStepAnswerChunk(
|
||||
state,
|
||||
chunk("tool-result", { toolName: "rectification-compare-candidates" }),
|
||||
isPublicTool,
|
||||
);
|
||||
const first = applyStepAnswerChunk(state, chunk("text-delta", { text: "记下了," }), isPublicTool);
|
||||
const second = applyStepAnswerChunk(
|
||||
state,
|
||||
chunk("text-delta", { text: "2020年4月开始实习。" }),
|
||||
isPublicTool,
|
||||
);
|
||||
assert.deepEqual(first, { kind: "live", text: "记下了," });
|
||||
assert.deepEqual(second, { kind: "live", text: "2020年4月开始实习。" });
|
||||
assert.equal(applyStepAnswerChunk(state, chunk("step-finish", { reason: "stop" }), isPublicTool).kind, "none");
|
||||
});
|
||||
|
||||
test("retracts a live spoken prefix if that step later calls a public tool", () => {
|
||||
const state = createStepAnswerState();
|
||||
applyStepAnswerChunk(
|
||||
state,
|
||||
chunk("tool-result", { toolName: "rectification-compare-candidates" }),
|
||||
isPublicTool,
|
||||
);
|
||||
assert.deepEqual(
|
||||
applyStepAnswerChunk(state, chunk("text-delta", { text: "记下了," }), isPublicTool),
|
||||
{ kind: "live", text: "记下了," },
|
||||
);
|
||||
const retracted = applyStepAnswerChunk(
|
||||
state,
|
||||
chunk("tool-call", { toolName: "rectification-read-diagnostics" }),
|
||||
isPublicTool,
|
||||
);
|
||||
assert.equal(retracted.kind, "retract");
|
||||
applyStepAnswerChunk(
|
||||
state,
|
||||
chunk("tool-result", { toolName: "rectification-read-diagnostics" }),
|
||||
isPublicTool,
|
||||
);
|
||||
const spoken = applyStepAnswerChunk(
|
||||
state,
|
||||
chunk("text-delta", { text: "诊断已经看过。接下来确认入职年份。" }),
|
||||
isPublicTool,
|
||||
);
|
||||
assert.deepEqual(spoken, { kind: "live", text: "诊断已经看过。接下来确认入职年份。" });
|
||||
});
|
||||
|
||||
test("does not live-publish English planning before a tool-call", () => {
|
||||
const state = createStepAnswerState();
|
||||
assert.equal(
|
||||
applyStepAnswerChunk(state, chunk("text-delta", { text: "Let me set" }), isPublicTool).kind,
|
||||
"none",
|
||||
);
|
||||
assert.equal(
|
||||
applyStepAnswerChunk(state, chunk("text-delta", { text: " _probe" }), isPublicTool).kind,
|
||||
"none",
|
||||
);
|
||||
assert.equal(
|
||||
applyStepAnswerChunk(
|
||||
state,
|
||||
chunk("tool-call", { toolName: "rectification-record-evidence-batch" }),
|
||||
isPublicTool,
|
||||
).kind,
|
||||
"none",
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user