|
9 | 9 | stripProcessedImages, |
10 | 10 | stripReasoningFromMergedAssistants, |
11 | 11 | stripSystemInjectedMessages, |
12 | | - truncateErroredTools, |
13 | 12 | } from "./strip-content"; |
14 | 13 | import type { MessageLike, ThinkingLikePart } from "./tag-messages"; |
15 | 14 |
|
@@ -309,105 +308,6 @@ describe("strip-content", () => { |
309 | 308 | }); |
310 | 309 | }); |
311 | 310 |
|
312 | | - describe("truncateErroredTools", () => { |
313 | | - describe("#given tool error parts above and below a watermark", () => { |
314 | | - describe("#when truncating errored tools", () => { |
315 | | - it("#then it truncates only long errors at or below the watermark", () => { |
316 | | - const below = message("m-1", "assistant", [ |
317 | | - { |
318 | | - type: "tool", |
319 | | - state: { |
320 | | - status: "error", |
321 | | - error: "e".repeat(200), |
322 | | - }, |
323 | | - }, |
324 | | - ]); |
325 | | - const above = message("m-2", "assistant", [ |
326 | | - { |
327 | | - type: "tool", |
328 | | - state: { |
329 | | - status: "error", |
330 | | - error: "f".repeat(200), |
331 | | - }, |
332 | | - }, |
333 | | - ]); |
334 | | - const shortError = message("m-3", "assistant", [ |
335 | | - { |
336 | | - type: "tool", |
337 | | - state: { |
338 | | - status: "error", |
339 | | - error: "short", |
340 | | - }, |
341 | | - }, |
342 | | - ]); |
343 | | - const success = message("m-4", "assistant", [ |
344 | | - { |
345 | | - type: "tool", |
346 | | - state: { |
347 | | - status: "completed", |
348 | | - output: "done", |
349 | | - }, |
350 | | - }, |
351 | | - ]); |
352 | | - const tags = new Map<MessageLike, number>([ |
353 | | - [below, 1], |
354 | | - [above, 10], |
355 | | - [shortError, 2], |
356 | | - [success, 3], |
357 | | - ]); |
358 | | - |
359 | | - const truncated = truncateErroredTools( |
360 | | - [below, above, shortError, success], |
361 | | - 5, |
362 | | - tags, |
363 | | - ); |
364 | | - |
365 | | - expect(truncated).toBe(1); |
366 | | - const belowPart = below.parts[0] as { |
367 | | - state: { error: string }; |
368 | | - }; |
369 | | - const abovePart = above.parts[0] as { |
370 | | - state: { error: string }; |
371 | | - }; |
372 | | - expect(belowPart.state.error.endsWith("[truncated]")).toBe(true); |
373 | | - expect(abovePart.state.error.length).toBe(200); |
374 | | - }); |
375 | | - }); |
376 | | - }); |
377 | | - |
378 | | - describe("#given an already truncated long error", () => { |
379 | | - describe("#when truncating errored tools again", () => { |
380 | | - it("#then it is byte-identical after the second pass", () => { |
381 | | - const tool = message("m-1", "assistant", [ |
382 | | - { |
383 | | - type: "tool", |
384 | | - state: { |
385 | | - status: "error", |
386 | | - error: "e".repeat(200), |
387 | | - }, |
388 | | - }, |
389 | | - ]); |
390 | | - const tags = new Map<MessageLike, number>([[tool, 1]]); |
391 | | - |
392 | | - truncateErroredTools([tool], 5, tags); |
393 | | - const firstPass = JSON.stringify(tool); |
394 | | - truncateErroredTools([tool], 5, tags); |
395 | | - |
396 | | - expect(JSON.stringify(tool)).toBe(firstPass); |
397 | | - }); |
398 | | - }); |
399 | | - }); |
400 | | - |
401 | | - describe("#given empty messages", () => { |
402 | | - describe("#when truncating errored tools", () => { |
403 | | - it("#then it returns zero", () => { |
404 | | - const tags = new Map<MessageLike, number>(); |
405 | | - expect(truncateErroredTools([], 5, tags)).toBe(0); |
406 | | - }); |
407 | | - }); |
408 | | - }); |
409 | | - }); |
410 | | - |
411 | 311 | describe("stripProcessedImages (sentinel-based)", () => { |
412 | 312 | describe("#given user image uploads around assistant responses and watermark boundaries", () => { |
413 | 313 | describe("#when stripping processed images", () => { |
|
0 commit comments