Skip to content

Commit bef14ab

Browse files
johan vazclaude
authored andcommitted
fix(server): large tool summaries no longer split an emoji at the cap
Co-Authored-By: GPT-6.1 Sol (Codex) via T3 Code Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent fa2f4ff commit bef14ab

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎apps/server/src/orchestration-v2/WireProjection.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,15 @@ describe("orchestration V2 wire projection", () => {
175175
summary: '"'.repeat(159) + "…",
176176
truncated: true,
177177
});
178+
179+
const boundary = projectTurnItemForWire({
180+
...base,
181+
input: { text: "a".repeat(149) + "😀" + "b".repeat(17_000) },
182+
});
183+
expect(boundary.type === "dynamic_tool" ? boundary.input : null).toEqual({
184+
summary: '{"text":"' + "a".repeat(149) + "…",
185+
truncated: true,
186+
});
178187
});
179188

180189
it("truncates detail at a UTF-8 boundary without changing the source", () => {

‎apps/server/src/orchestration-v2/WireProjection.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,10 @@ function summarizeDynamicValue(value: unknown): unknown {
9797
pendingSpace = false;
9898
if (firstLine.length > 160) break;
9999
}
100+
const last = firstLine.charCodeAt(158);
101+
const end = last >= 0xd800 && last <= 0xdbff ? 158 : 159;
100102
return {
101-
summary: firstLine.length <= 160 ? firstLine : `${firstLine.slice(0, 159).trimEnd()}…`,
103+
summary: firstLine.length <= 160 ? firstLine : `${firstLine.slice(0, end).trimEnd()}…`,
102104
truncated: true,
103105
};
104106
}

0 commit comments

Comments
 (0)