惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

量子位
F
Fortinet All Blogs
J
Java Code Geeks
Y
Y Combinator Blog
Stack Overflow Blog
Stack Overflow Blog
V
Visual Studio Blog
M
MIT News - Artificial intelligence
腾讯CDC
Last Week in AI
Last Week in AI
The Cloudflare Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Jina AI
Jina AI
Microsoft Security Blog
Microsoft Security Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
P
Proofpoint News Feed
博客园 - 叶小钗
Recent Announcements
Recent Announcements
T
Tailwind CSS Blog
Engineering at Meta
Engineering at Meta
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
人人都是产品经理
人人都是产品经理
L
LangChain Blog
博客园 - 司徒正美
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
refactor(agents): remove unused runtime tool-result trunc...
vincentkoc · 2026-06-19 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -17,7 +17,6 @@ let calculateMaxToolResultCharsWithCap: typeof import("./tool-result-truncation.

1717

let resolveAutoLiveToolResultMaxChars: typeof import("./tool-result-truncation.js").resolveAutoLiveToolResultMaxChars;

1818

let getToolResultTextLength: typeof import("./tool-result-truncation.js").getToolResultTextLength;

1919

let truncateOversizedToolResultsInMessages: typeof import("./tool-result-truncation.js").truncateOversizedToolResultsInMessages;

20-

let truncateOversizedToolResultsInRuntimeTranscript: typeof import("./tool-result-truncation.js").truncateOversizedToolResultsInRuntimeTranscript;

2120

let truncateOversizedToolResultsInSession: typeof import("./tool-result-truncation.js").truncateOversizedToolResultsInSession;

2221

let sessionLikelyHasOversizedToolResults: typeof import("./tool-result-truncation.js").sessionLikelyHasOversizedToolResults;

2322

let estimateToolResultReductionPotential: typeof import("./tool-result-truncation.js").estimateToolResultReductionPotential;

@@ -36,7 +35,6 @@ async function loadFreshToolResultTruncationModuleForTest() {

3635

resolveAutoLiveToolResultMaxChars,

3736

getToolResultTextLength,

3837

truncateOversizedToolResultsInMessages,

39-

truncateOversizedToolResultsInRuntimeTranscript,

4038

truncateOversizedToolResultsInSession,

4139

sessionLikelyHasOversizedToolResults,

4240

estimateToolResultReductionPotential,

@@ -442,25 +440,6 @@ describe("truncateOversizedToolResultsInMessages", () => {

442440

});

443441
444442

describe("truncateOversizedToolResultsInSession", () => {

445-

it("does not create session metadata for missing runtime transcripts", async () => {

446-

const dir = await createTmpDir();

447-

const storePath = path.join(dir, "sessions.json");

448-

await fs.writeFile(storePath, "{}\n", "utf8");

449-
450-

const result = await truncateOversizedToolResultsInRuntimeTranscript({

451-

scope: {

452-

agentId: "main",

453-

sessionId: "missing-session",

454-

sessionKey: "agent:main:missing",

455-

storePath,

456-

},

457-

contextWindowTokens: 100,

458-

});

459-
460-

expect(result.truncated).toBe(false);

461-

expect(await fs.readFile(storePath, "utf8")).toBe("{}\n");

462-

});

463-
464443

it("readably truncates aggregate medium tool results in a session file", async () => {

465444

// Persisted truncation rewrites JSONL directly and emits the transcript

466445

// update event instead of reopening through SessionManager internals.

Original file line numberDiff line numberDiff line change

@@ -25,10 +25,6 @@ import {

2525

rewriteTranscriptEntriesInSessionManager,

2626

rewriteTranscriptEntriesInState,

2727

} from "./transcript-rewrite.js";

28-

import {

29-

resolveRuntimeTranscriptReadTarget,

30-

type RuntimeTranscriptScope,

31-

} from "./transcript-runtime-state.js";

3228
3329

/**

3430

* Maximum share of the context window a single tool result should occupy.

@@ -822,47 +818,7 @@ export function truncateOversizedToolResultsInSessionManager(params: {

822818

}

823819
824820

/**

825-

* Truncates oversized tool results for a runtime transcript scope.

826-

*/

827-

export async function truncateOversizedToolResultsInRuntimeTranscript(params: {

828-

scope: RuntimeTranscriptScope;

829-

contextWindowTokens: number;

830-

maxCharsOverride?: number;

831-

aggregateMaxCharsOverride?: number;

832-

config?: SessionWriteLockAcquireTimeoutConfig;

833-

}): Promise<{ truncated: boolean; truncatedCount: number; reason?: string }> {

834-

let sessionLock: Awaited<ReturnType<typeof acquireSessionWriteLock>> | undefined;

835-
836-

try {

837-

const target = await resolveRuntimeTranscriptReadTarget(params.scope);

838-

sessionLock = await acquireSessionWriteLock({

839-

sessionFile: target.sessionFile,

840-

...resolveSessionWriteLockOptions(params.config),

841-

});

842-

const state = await readTranscriptFileState(target.sessionFile);

843-

return await truncateOversizedToolResultsInTranscriptState({

844-

state,

845-

contextWindowTokens: params.contextWindowTokens,

846-

maxCharsOverride: params.maxCharsOverride,

847-

aggregateMaxCharsOverride: params.aggregateMaxCharsOverride,

848-

sessionFile: target.sessionFile,

849-

sessionId: target.sessionId,

850-

sessionKey: target.sessionKey,

851-

agentId: target.agentId,

852-

config: params.config,

853-

});

854-

} catch (err) {

855-

const errMsg = formatErrorMessage(err);

856-

log.warn(`[tool-result-truncation] Failed to truncate: ${errMsg}`);

857-

return { truncated: false, truncatedCount: 0, reason: errMsg };

858-

} finally {

859-

await sessionLock?.release();

860-

}

861-

}

862-
863-

/**

864-

* Truncates a named transcript file artifact. Runtime callers should prefer

865-

* truncateOversizedToolResultsInRuntimeTranscript with agent/session scope.

821+

* Truncates a named transcript file artifact.

866822

*/

867823

export async function truncateOversizedToolResultsInSession(params: {

868824

sessionFile: string;