Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions examples/openclaw-plugin/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export type MemoryOpenVikingConfig = {
timeoutMs?: number;
autoCapture?: boolean;
captureMode?: "semantic" | "keyword";
/** Minimum sanitized text length (chars) required to trigger auto-capture. Default 50. */
captureMinLength?: number;
captureMaxLength?: number;
autoRecall?: boolean;
recallLimit?: number;
Expand All @@ -41,6 +43,7 @@ const DEFAULT_PORT = 1933;
const DEFAULT_TARGET_URI = "viking://user/memories";
const DEFAULT_TIMEOUT_MS = 15000;
const DEFAULT_CAPTURE_MODE = "semantic";
const DEFAULT_CAPTURE_MIN_LENGTH = 50;
const DEFAULT_CAPTURE_MAX_LENGTH = 24000;
const DEFAULT_RECALL_LIMIT = 6;
const DEFAULT_RECALL_SCORE_THRESHOLD = 0.15;
Expand Down Expand Up @@ -131,6 +134,7 @@ export const memoryOpenVikingConfigSchema = {
"timeoutMs",
"autoCapture",
"captureMode",
"captureMinLength",
"captureMaxLength",
"autoRecall",
"recallLimit",
Expand Down Expand Up @@ -185,6 +189,10 @@ export const memoryOpenVikingConfigSchema = {
timeoutMs: Math.max(1000, Math.floor(toNumber(cfg.timeoutMs, DEFAULT_TIMEOUT_MS))),
autoCapture: cfg.autoCapture !== false,
captureMode: captureMode ?? DEFAULT_CAPTURE_MODE,
captureMinLength: Math.max(
1,
Math.min(1000, Math.floor(toNumber(cfg.captureMinLength, DEFAULT_CAPTURE_MIN_LENGTH))),
),
captureMaxLength: Math.max(
200,
Math.min(200_000, Math.floor(toNumber(cfg.captureMaxLength, DEFAULT_CAPTURE_MAX_LENGTH))),
Expand Down Expand Up @@ -290,6 +298,12 @@ export const memoryOpenVikingConfigSchema = {
advanced: true,
help: '"semantic" captures all eligible user text and relies on OpenViking extraction; "keyword" uses trigger regex first.',
},
captureMinLength: {
label: "Capture Min Length",
placeholder: String(DEFAULT_CAPTURE_MIN_LENGTH),
advanced: true,
help: "Minimum sanitized text length (chars) required to trigger auto-capture. Shorter messages are skipped to save VLM tokens.",
},
captureMaxLength: {
label: "Capture Max Length",
placeholder: String(DEFAULT_CAPTURE_MAX_LENGTH),
Expand Down
4 changes: 2 additions & 2 deletions examples/openclaw-plugin/text-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export function pickRecentUniqueTexts(texts: string[], limit: number): string[]
return picked.reverse();
}

export function getCaptureDecision(text: string, mode: CaptureMode, captureMaxLength: number): {
export function getCaptureDecision(text: string, mode: CaptureMode, captureMinLength: number, captureMaxLength: number): {
shouldCapture: boolean;
reason: string;
normalizedText: string;
Expand All @@ -223,7 +223,7 @@ export function getCaptureDecision(text: string, mode: CaptureMode, captureMaxLe
}

const compactText = normalizedText.replace(/\s+/g, "");
const minLength = resolveCaptureMinLength(compactText);
const minLength = Math.max(resolveCaptureMinLength(compactText), captureMinLength);
if (compactText.length < minLength || normalizedText.length > captureMaxLength) {
return {
shouldCapture: false,
Expand Down
6 changes: 5 additions & 1 deletion openviking/server/routers/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,13 @@ async def get_session_context(
_ctx: RequestContext = Depends(get_request_context),
):
"""Get assembled session context."""
from openviking_cli.exceptions import NotFoundError
service = get_service()
session = service.sessions.session(_ctx, session_id)
await session.load()
try:
await session.load()
except NotFoundError:
session = await service.sessions.create(_ctx, session_id)
result = await session.get_session_context(token_budget=token_budget)
return Response(status="ok", result=_to_jsonable(result))

Expand Down
Loading