Files
oh-my-pi/packages/coding-agent/test/compaction-serialization.test.ts
T
can1357 acf4b45062 fix(coding-agent): backported pi-mono changes (5133697..15e0957b0)
packages/ai:
- fix: improve GitHub Copilot OAuth polling and Codex stream recovery
- fix: allow google-vertex authentication via GOOGLE_CLOUD_API_KEY
- fix: send Gemini/Claude provider-specific thinking headers and thought-signature fallbacks correctly
- test: added coverage for Gemini CLI alignment, Codex streaming, and stream edge cases

packages/coding-agent:
- feat: add treeFilterMode setting for the session tree selector default
- fix: prefer later-loaded explicit extensions when commands conflict
- fix: truncate serialized tool results during compaction summarization to prevent overflow
- fix: normalize CRLF in write tool previews
- fix: use shell-based external editor launch on Windows
- test: added compaction serialization and extension runner precedence coverage

packages/tui:
- fix: chain slash-command argument autocomplete after tab-completing the command name
- fix: normalize pasted tabs in Input using configured indentation
- fix: render blockquote lists, tables, and fenced code blocks correctly
- fix: ignore unsupported Kitty CSI-u modifiers and enable modifyOtherKeys fallback cleanup
- test: added editor, input, keys, and markdown regression coverage
2026-03-10 07:27:30 +01:00

79 lines
2.0 KiB
TypeScript

import { describe, expect, it } from "bun:test";
import type { Message } from "@oh-my-pi/pi-ai";
import { serializeConversation } from "../src/session/compaction/utils";
describe("serializeConversation", () => {
it("truncates long tool results in serialized summaries", () => {
const longContent = "x".repeat(5000);
const messages: Message[] = [
{
role: "toolResult",
toolCallId: "tc1",
toolName: "read",
content: [{ type: "text", text: longContent }],
isError: false,
timestamp: Date.now(),
},
];
const result = serializeConversation(messages);
expect(result).toContain("[Tool result]:");
expect(result).toContain("[... 3000 more characters truncated]");
expect(result).toContain("x".repeat(2000));
expect(result).not.toContain("x".repeat(3000));
});
it("does not truncate short tool results", () => {
const shortContent = "x".repeat(1500);
const messages: Message[] = [
{
role: "toolResult",
toolCallId: "tc1",
toolName: "read",
content: [{ type: "text", text: shortContent }],
isError: false,
timestamp: Date.now(),
},
];
const result = serializeConversation(messages);
expect(result).toBe(`[Tool result]: ${shortContent}`);
expect(result).not.toContain("truncated");
});
it("does not truncate assistant or user messages", () => {
const longText = "y".repeat(5000);
const messages: Message[] = [
{
role: "user",
content: [{ type: "text", text: longText }],
timestamp: Date.now(),
},
{
role: "assistant",
content: [{ type: "text", text: longText }],
api: "anthropic",
provider: "anthropic",
model: "test",
usage: {
input: 0,
output: 0,
cacheRead: 0,
cacheWrite: 0,
totalTokens: 0,
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
},
stopReason: "stop",
timestamp: Date.now(),
},
];
const result = serializeConversation(messages);
expect(result).not.toContain("truncated");
expect(result).toContain(longText);
});
});