






















@@ -154,6 +154,79 @@ describe("normalizeAssistantReplayContent", () => {
154154expect(out[2]).toBe(length);
155155});
156156157+it("drops reasoning-only length turns before provider replay", () => {
158+const reasoningOnly = bedrockAssistant(
159+[
160+{
161+type: "thinking",
162+thinking: "partial hidden reasoning",
163+thinkingSignature: "partial-signature",
164+},
165+{ type: "text", text: " " },
166+],
167+"length",
168+{ output: 42, totalTokens: 42 },
169+);
170+const messages = [userMessage("before"), reasoningOnly, userMessage("continue")];
171+172+const out = normalizeAssistantReplayContent(messages);
173+174+expect(out).toEqual([messages[0], messages[2]]);
175+expect(JSON.stringify(out)).not.toContain("partial-signature");
176+});
177+178+it("drops length turns that become reasoning-only after content normalization", () => {
179+const messages = [
180+userMessage("before"),
181+bedrockAssistant(
182+[
183+{
184+type: "thinking",
185+thinking: "partial hidden reasoning",
186+thinkingSignature: "partial-signature",
187+},
188+{ type: "text", text: "NO_REPLY" },
189+],
190+"length",
191+),
192+{
193+ ...bedrockAssistant([], "length"),
194+content: {
195+type: "thinking",
196+thinking: "partial object reasoning",
197+thinkingSignature: "partial-object-signature",
198+},
199+},
200+userMessage("continue"),
201+] as AgentMessage[];
202+203+const out = normalizeAssistantReplayContent(messages);
204+205+expect(out).toEqual([messages[0], messages[3]]);
206+});
207+208+it("preserves length turns with visible text or tool calls", () => {
209+const visible = bedrockAssistant(
210+[
211+{ type: "thinking", thinking: "partial reasoning", thinkingSignature: "sig_visible" },
212+{ type: "text", text: "partial visible answer" },
213+],
214+"length",
215+);
216+const toolCall = bedrockAssistant(
217+[
218+{ type: "thinking", thinking: "partial reasoning", thinkingSignature: "sig_tool" },
219+{ type: "toolCall", id: "call_1", name: "read", arguments: {} },
220+],
221+"length",
222+);
223+const messages = [userMessage("before"), visible, toolCall, userMessage("continue")];
224+225+const out = normalizeAssistantReplayContent(messages);
226+227+expect(out).toBe(messages);
228+});
229+157230it("wraps legacy string assistant content as a single text block (regression)", () => {
158231const messages = [userMessage("hi"), bedrockAssistant("plain string content")];
159232const out = normalizeAssistantReplayContent(messages);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。