feat(coding-agent/session): preserved signed thinking blocks during demotion

- Updated the demotion logic to treat complete, signed thinking blocks as stable content that terminates an interrupted stream.
- Protected signed thinking runs from being stripped when processing interrupted agent messages.
This commit is contained in:
can1357
2026-06-28 08:26:24 +02:00
parent 670d60fa60
commit da07a3ac5f
4 changed files with 48 additions and 6 deletions
@@ -69,4 +69,26 @@ describe("demoteInterruptedThinking", () => {
expect(demoteContent([{ type: "thinking", thinking: " \n\t" }])).toBeUndefined();
expect(demoteContent([{ type: "redactedThinking", data: "encrypted" }])).toBeUndefined();
});
it("preserves a non-empty signed thinking tail as native replayable reasoning", () => {
expect(
demoteContent([
{ type: "text", text: "Visible answer." },
{ type: "thinking", thinking: "Complete signed reasoning", thinkingSignature: "sig" },
]),
).toBeUndefined();
});
it("demotes only the unsigned tail and keeps an earlier signed thinking block", () => {
expect(
demoteContent([
{ type: "thinking", thinking: "Complete signed reasoning", thinkingSignature: "sig" },
{ type: "thinking", thinking: "Interrupted unsigned tail" },
]),
).toEqual({
reasoning: "Interrupted unsigned tail",
strippedContent: [{ type: "thinking", thinking: "Complete signed reasoning", thinkingSignature: "sig" }],
blockCount: 1,
});
});
});