mirror of
https://github.com/TencentCloud/TencentDB-Agent-Memory
synced 2026-07-10 12:34:27 +00:00
feat(recall): cap injected memory context (#71)
- Add `recall.maxCharsPerMemory` and `recall.maxTotalRecallChars` with defaults of `0`, which do not alter existing behavior. Users can opt in by setting positive values to cap injected memory context. - Apply the budget after L1 search and before `<relevant-memories>` injection, preserving score order while truncating oversized entries and dropping overflow. - Document the new guards in README, README_CN, and `openclaw.plugin.json`.
This commit is contained in:
@@ -80,6 +80,10 @@ export interface RecallConfig {
|
||||
enabled: boolean;
|
||||
/** Max results to return (default: 5) */
|
||||
maxResults: number;
|
||||
/** Max characters injected for a single recalled L1 memory. 0 disables the per-memory limit. */
|
||||
maxCharsPerMemory: number;
|
||||
/** Max total characters injected for all recalled L1 memories. 0 disables the total limit. */
|
||||
maxTotalRecallChars: number;
|
||||
/** Minimum score threshold (default: 0.3) */
|
||||
scoreThreshold: number;
|
||||
/** Search strategy (default: "hybrid") */
|
||||
@@ -486,6 +490,8 @@ export function parseConfig(raw: Record<string, unknown> | undefined): MemoryTda
|
||||
recall: {
|
||||
enabled: bool(recallGroup, "enabled") ?? true,
|
||||
maxResults: num(recallGroup, "maxResults") ?? 5,
|
||||
maxCharsPerMemory: num(recallGroup, "maxCharsPerMemory") ?? 0,
|
||||
maxTotalRecallChars: num(recallGroup, "maxTotalRecallChars") ?? 0,
|
||||
scoreThreshold: num(recallGroup, "scoreThreshold") ?? 0.3,
|
||||
strategy: validateStrategy(str(recallGroup, "strategy")) ?? "hybrid",
|
||||
timeoutMs: num(recallGroup, "timeoutMs") ?? 5000,
|
||||
|
||||
Reference in New Issue
Block a user