Skip to content

Commit baf54d8

Browse files
committed
chore: drop bootstrap digest cache change
1 parent 32edc68 commit baf54d8

1 file changed

Lines changed: 2 additions & 24 deletions

File tree

‎src/agents/embedded-agent-helpers/bootstrap.ts‎

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/**
22
* Builds and sanitizes bootstrap context inserted into embedded-agent sessions.
33
*/
4-
import { createHash } from "node:crypto";
54
import fs from "node:fs/promises";
65
import path from "node:path";
76
import { normalizeOptionalString } from "@openclaw/normalization-core/string-coerce";
@@ -118,13 +117,6 @@ type PolicyDigest = {
118117
omittedLines: number;
119118
};
120119

121-
let lastAgentsPolicyDigestCache:
122-
| {
123-
key: string;
124-
digest: PolicyDigest;
125-
}
126-
| undefined;
127-
128120
export function resolveBootstrapMaxChars(cfg?: OpenClawConfig, agentId?: string | null): number {
129121
const raw =
130122
cfg && agentId
@@ -183,25 +175,11 @@ function normalizePolicyDigestLine(line: string): string {
183175
return `${truncateUtf16Safe(normalized, AGENTS_POLICY_DIGEST_MAX_LINE_CHARS - 1)}…`;
184176
}
185177

186-
function agentsPolicyDigestCacheKey(content: string, budget: number): string {
187-
return `${budget}:${content.length}:${createHash("sha256").update(content).digest("base64url")}`;
188-
}
189-
190-
function rememberAgentsPolicyDigest(key: string, digest: PolicyDigest): PolicyDigest {
191-
lastAgentsPolicyDigestCache = { key, digest };
192-
return digest;
193-
}
194-
195178
function buildAgentsPolicyDigest(content: string, budget: number): PolicyDigest {
196179
if (budget <= 0) {
197180
return { text: "", omittedLines: 0 };
198181
}
199182

200-
const cacheKey = agentsPolicyDigestCacheKey(content, budget);
201-
if (lastAgentsPolicyDigestCache?.key === cacheKey) {
202-
return lastAgentsPolicyDigestCache.digest;
203-
}
204-
205183
const candidates = content
206184
.split(/\r?\n/u)
207185
.map((line, index) => ({ index, line: normalizePolicyDigestLine(line) }))
@@ -234,10 +212,10 @@ function buildAgentsPolicyDigest(content: string, budget: number): PolicyDigest
234212
.filter((candidate) => selected.has(candidate.index))
235213
.toSorted((a, b) => a.index - b.index)
236214
.map((candidate) => candidate.line);
237-
return rememberAgentsPolicyDigest(cacheKey, {
215+
return {
238216
text: lines.join("\n"),
239217
omittedLines: Math.max(0, candidates.length - lines.length),
240-
});
218+
};
241219
}
242220

243221
function trimAgentsBootstrapContent(content: string, maxChars: number): TrimBootstrapResult {

0 commit comments

Comments
 (0)