Skip to content

Commit eb2f9be

Browse files
committed
fix(agents): persist spill metadata for elision recovery
Preserve fullOutputPath plus partial-spill metadata when oversized tool-result details are summarized for persistence. This keeps aggregate elision from relabeling capped or source-truncated web_fetch spill files as complete after reload.
1 parent 235f18d commit eb2f9be

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/agents/session-tool-result-guard.tool-result-persist-hook.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,8 @@ describe("tool_result_persist hook", () => {
437437
cwd: "/tmp/".concat("workspace/".repeat(400)),
438438
name: "oversized fallback command ".repeat(200),
439439
fullOutputPath: "/tmp/".concat("output/".repeat(400)),
440+
spilledChars: 2_000_000,
441+
spillTruncated: true,
440442
aggregated: "x".repeat(120_000),
441443
tail: "tail ".repeat(800),
442444
sessions: Array.from({ length: 10 }, (_, i) => ({
@@ -453,6 +455,8 @@ describe("tool_result_persist hook", () => {
453455
expect(details.persistedDetailsTruncated).toBe(true);
454456
expect(details.finalDetailsTruncated).toBe(true);
455457
expect(details.status?.token).toBe("***");
458+
expect(details.spilledChars).toBe(2_000_000);
459+
expect(details.spillTruncated).toBe(true);
456460
expect(serialized).not.toContain(tokenValue);
457461
});
458462

src/agents/session-tool-result-guard.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,17 @@ function buildPersistedDetailsFallback(
344344
}
345345
if (src) {
346346
fallback.originalDetailKeys = redactedOriginalDetailKeys(src, redactionConfig);
347-
for (const key of ["status", "sessionId", "pid", "exitCode", "exitSignal", "truncated"]) {
347+
for (const key of [
348+
"status",
349+
"sessionId",
350+
"pid",
351+
"exitCode",
352+
"exitSignal",
353+
"truncated",
354+
"fullOutputPath",
355+
"spilledChars",
356+
"spillTruncated",
357+
]) {
348358
const field = src[key];
349359
if (field !== undefined) {
350360
fallback[key] = redactPersistedSummaryField(
@@ -470,6 +480,8 @@ function sanitizeToolResultDetailsForPersistence(
470480
"totalChars",
471481
"truncated",
472482
"fullOutputPath",
483+
"spilledChars",
484+
"spillTruncated",
473485
"truncation",
474486
]) {
475487
const field = src[key];

0 commit comments

Comments
 (0)