test: tighten thinking recovery assertions · openclaw/openclaw@c62168a
steipete
·
2026-05-09
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -453,10 +453,13 @@ describe("wrapAnthropicStreamWithRecovery", () => {
|
453 | 453 | ), |
454 | 454 | ).rejects.toBe(anthropicThinkingError); |
455 | 455 | expect(callCount).toBe(2); |
456 | | -expect(contexts[1]?.messages?.[0]).toMatchObject({ |
457 | | -role: "assistant", |
458 | | -content: [{ type: "text", text: OMITTED_ASSISTANT_REASONING_TEXT }], |
459 | | -}); |
| 456 | +const retryMessage = contexts[1]?.messages?.[0]; |
| 457 | +if (!retryMessage || retryMessage.role !== "assistant") { |
| 458 | +throw new Error("Expected Anthropic recovery retry to start with an assistant message"); |
| 459 | +} |
| 460 | +expect(retryMessage.content).toEqual([ |
| 461 | +{ type: "text", text: OMITTED_ASSISTANT_REASONING_TEXT }, |
| 462 | +]); |
460 | 463 | }); |
461 | 464 | |
462 | 465 | it("retries with visible assistant text when stripping thinking leaves content", async () => { |
@@ -487,10 +490,11 @@ describe("wrapAnthropicStreamWithRecovery", () => {
|
487 | 490 | ), |
488 | 491 | ).rejects.toBe(anthropicThinkingError); |
489 | 492 | |
490 | | -expect(contexts[1]?.messages?.[0]).toMatchObject({ |
491 | | -role: "assistant", |
492 | | -content: [{ type: "text", text: "visible answer" }], |
493 | | -}); |
| 493 | +const retryMessage = contexts[1]?.messages?.[0]; |
| 494 | +if (!retryMessage || retryMessage.role !== "assistant") { |
| 495 | +throw new Error("Expected Anthropic recovery retry to start with an assistant message"); |
| 496 | +} |
| 497 | +expect(retryMessage.content).toEqual([{ type: "text", text: "visible answer" }]); |
494 | 498 | }); |
495 | 499 | |
496 | 500 | it("does not retry when the stream fails after yielding a chunk", async () => { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。