Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(acp): cap plain-string and Text tool output like stdout #23682

Closedonly21mil(GitHub profile, opens in a new tab)wants to merge 4 commits intomain fromrefs/pull/23682/headopened View on GitHub

Showing 2 changed files with 83 additions and 18 deletions.

x
0 of 2 viewed, 2 left
48 additions and 0 deletionspackages/provider-acp/src/server/runtimeModel.test.tsModified
View file
@@ -476,6 +476,35 @@
expect(JSON.stringify(event).length).toBeLessThan(hugeText.length);
});
​
+ it.each([
+ { form: "string", wrap: (text: string): unknown => text },
+ { form: "Text", wrap: (text: string): unknown => ({ type: "Text", text }) },
+ { form: "stdout", wrap: (text: string): unknown => ({ stdout: text }) },
+ ])("bounds an oversized $form rawOutput to the same tail window", ({ wrap }) => {
+ const hugeText = Array.from({ length: 2_000 }, (_, i) => `line ${i}: ${"x".repeat(50)}`).join(
+ "\n",
+ );
+ const result = parseSessionUpdateEvent({
+ sessionId: "session-1",
+ update: {
+ sessionUpdate: "tool_call_update",
+ toolCallId: "tool-1",
+ status: "in_progress",
+ rawOutput: wrap(hugeText),
+ },
+ } satisfies EffectAcpSchema.SessionNotification);
+​
+ const event = result.events[0];
+ if (event?._tag !== "ToolCallUpdated") {
+ throw new Error("expected a ToolCallUpdated event");
+ }
+ const bounded = wrap(`[Earlier output truncated]\n\n${hugeText.slice(-8_000)}`);
+ expect(event.toolCall.data.rawOutput).toEqual(bounded);
+ const rawUpdate = (event.rawPayload as { readonly update: { readonly rawOutput: unknown } })
+ .update;