Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Move recall's max_chars bound beside boundFactLines (facts.ts stays under the 1500 unlisted cap after the master merge)
garrytanbe1ba18eb700
diff --git a/src/core/ops/facts.ts b/src/core/ops/facts.tsindex a79e67907c..8928a52940 100644--- a/src/core/ops/facts.ts+++ b/src/core/ops/facts.ts@@ -29,7 +29,7 @@ import { OperationError, opError, verbError } from './contract.ts';import { invalidParam, paramUse } from './op-fix.ts';import { parseSourceIdParam, sourceScopeOpts, stampEvidenceSafe } from './context.ts';import { parseSourceIdsParam, requestSourceScope, SOURCE_IDS_PARAM } from './search-source-scope.ts';-import { boundFactLines, MEMORY_RECALL_MAX_CHARS, parseMaxChars } from './qm-memory.ts';+import { boundRecallChars, MEMORY_RECALL_MAX_CHARS, parseMaxChars } from './qm-memory.ts';import { markKeywordHits } from '../search/evidence.ts';import { hybridSearchCached, stampContentFlags, type HybridSearchOpts } from '../search/hybrid.ts';import { dedupResults } from '../search/dedup.ts';@@ -668,18 +668,6 @@ const recall: Operation = {},};-/**- * GST-900: recall's max_chars, memory_recall's bound on recall's text: the fact texts, then the results' chunk texts,- * one per line, keep the whole items that fit; the first item that would cross the cap ends both lists, with no- * marker. `truncated` says whether anything was cut and `total` counts the facts kept.- */-function boundRecallChars<T extends { facts: Array<{ fact: string }>; total: number; results?: Array<{ chunk?: unknown }> }>(out: T, maxChars: number): T & { truncated: boolean } {- const lines = [...out.facts.map(f => f.fact), ...(out.results ?? []).map(r => String(r.chunk ?? ''))];- const { kept } = boundFactLines(lines, maxChars);- const facts = out.facts.slice(0, kept);- return { ...out, facts, total: facts.length, ...(out.results ? { results: out.results.slice(0, Math.max(0, kept - out.facts.length)) } : {}), truncated: kept < lines.length };-}-/*** One source's facts about an entity, read under every slug they may be saved* under (the page, its identity siblings and its bare subject slug,diff --git a/src/core/ops/qm-memory.ts b/src/core/ops/qm-memory.tsindex b73e73d702..41d9dd1518 100644--- a/src/core/ops/qm-memory.ts+++ b/src/core/ops/qm-memory.ts@@ -331,3 +331,15 @@ export function unlinkedRecallResult(): { content: Array<{ type: 'text'; text: s}export const qmMemoryOperations: Operation[] = [memory_recall, memory_write];++/**+ * GST-900: recall's max_chars, memory_recall's bound on recall's text: the fact texts, then the results' chunk texts,+ * one per line, keep the whole items that fit; the first item that would cross the cap ends both lists, with no+ * marker. `truncated` says whether anything was cut and `total` counts the facts kept.+ */+export function boundRecallChars<T extends { facts: Array<{ fact: string }>; total: number; results?: Array<{ chunk?: unknown }> }>(out: T, maxChars: number): T & { truncated: boolean } {+ const lines = [...out.facts.map(f => f.fact), ...(out.results ?? []).map(r => String(r.chunk ?? ''))];+ const { kept } = boundFactLines(lines, maxChars);+ const facts = out.facts.slice(0, kept);+ return { ...out, facts, total: facts.length, ...(out.results ? { results: out.results.slice(0, Math.max(0, kept - out.facts.length)) } : {}), truncated: kept < lines.length };+}