[Feature]: Compaction should still work for bypassed sessions (delegate to runtime or summarize without storage)
Problem Statement
bypassSessionPatterns lets the OpenClaw plugin exclude sessions (e.g. subagent sessions agent::subagent:) from OpenViking entirely — no capture, no recall, no commit, no session-history storage, no memory extraction. That works for storage, but it breaks context compaction for those sessions:
Because the plugin declares ownsCompaction: true, OpenClaw delegates compaction to the plugin's compact(). For a bypassed session, compactOpenVikingSession() returns:
{ ok: true, compacted: false, reason: "session_bypassed" } OpenClaw does not treat session_bypassed as a benign skip (benign = below_threshold / already_compacted / no_compactable_entries, see compact-reasons.ts). Consequence:
Preflight compaction (auto, near context limit): throws "Preflight compaction required but failed: session_bypassed" — the turn hard-fails instead of compacting. Manual /compact: reports "Compaction skipped" — nothing is compacted. So a bypassed session can never be compacted: it grows until it errors, or must be manually reset.
Proposed Solution
For bypassed sessions, compaction should still happen without persisting history or extracting memory:
Delegate to OpenClaw runtime — compact() signals delegation (e.g. reason: "delegated_to_runtime" or a delegateToRuntime field); OpenClaw falls back to its native compactor (summarize older turns, keep recent tail in host transcript store), zero OV writes. OpenClaw already has the concept (DEFERRED_CONTEXT_ENGINE_COMPACTION_REASON in compact-reasons.ts). OV-side compaction without storage — for bypassed sessions, compress the in-memory session and return a summary assemble() can inject, but skip writing history/archive_NNN/, .abstract.md/.overview.md, and skip memory extraction. Minimal acceptable mitigation: classify session_bypassed as benign skip so it stops hard-failing (no real compaction, but no turn failure).
Alternatives Considered
Don't bypass subagent sessions — works, but defeats the purpose (OV DB bloat + memory pollution). Manual retirement via DELETE /api/v1/sessions/{id} — cleanup only, doesn't solve live context growth. Benign-skip classification only — avoids failure, still no compaction.
Feature Area
Session Management
Use Case
OpenClaw + OpenViking context engine. Subagent sessions (agent:
Example API (Optional)
{
plugins: { entries: { openviking: { config: {
bypassSessionPatterns: ["agent:*:subagent:*"],
// "delegate-runtime" (default) | "ov-memory-only" | "none"
bypassSessionCompaction: "delegate-runtime"
} } } }
}
Additional Context
Plugin refs: config.ts (bypassSessionPatterns, default []), text-utils.ts (glob→regex, *=one segment/**=multi, matched against sessionKey then sessionId), context-lifecycle-service.ts:1027 (bypass return), context-engine.ts (ownsCompaction: true). Host refs (OpenClaw): compact-reasons.ts (benign bucket), agent-runner-memory.ts:945-963 (preflight throw), commands-compact.ts:317 (manual skip label). Latest release v0.4.13 (2026-08-06): "Session Auto Commit v2" adds per-session auto_commit_policy (token/message/idle triggers) — controls when stored sessions commit, not whether a session is stored. The gap remains. Today's only mitigation is manual cleanup — the plugin never calls deleteSession().
Contribution
- [ ] I am willing to contribute to implementing this feature
I verified this remains open and unclaimed, but the safe implementation depends on the host contract rather than an OpenViking-only behavior change.
Proposed narrow scope for maintainer confirmation:
- For a matched
bypassSessionPatternssession, return the same deferred/delegation reason already recognized by the supported OpenClaw runtime (DEFERRED_CONTEXT_ENGINE_COMPACTION_REASON) instead of introducing another benign skip. - Keep
ownsCompaction: truefor normal sessions and keep all capture/recall/commit/history writes bypassed for matched sessions. - Add a contract test proving a bypassed session requests host compaction and performs zero OpenViking writes; preserve existing compaction tests for normal sessions.
- Gate the behavior on the minimum OpenClaw version that recognizes the deferred reason, or retain the current result for older hosts if runtime version detection already exists.
Could maintainers confirm (1) the exact wire reason/field OpenViking should return and (2) the minimum supported OpenClaw version? Without those two decisions, an OpenViking-only PR could either keep hard-failing older hosts or silently skip real compaction.
Confirming the shape of option (a) before implementing it on the plugin side: the OV-side fix is small — compactOpenVikingSession's bypass branch (context-lifecycle-service.ts, returns {ok: true, compacted: false, reason: "session_bypassed"}) would instead return whatever signal OpenClaw's runtime maps to "fall back to the native compactor". The blocker is that the contract literal lives in OpenClaw's compact-reasons.ts (DEFERRED_CONTEXT_ENGINE_COMPACTION_REASON), which isn't mirrored in this repo.
Two questions to pin the contract:
- What exact value does
DEFERRED_CONTEXT_ENGINE_COMPACTION_REASONexpect — a specificreasonstring, adelegateToRuntimeboolean, or a member of the benign-skip set (below_threshold/already_compacted/no_compactable_entries)? If it's just "addsession_bypassedto the benign set", that's a one-line OpenClaw-side change and the OV plugin needs nothing. - Is emitting the delegation signal conditional on an OpenClaw version (older runtimes would treat an unknown reason as failure again)? If so the plugin should gate on a capability probe rather than assume.
With the literal confirmed, the plugin-side diff is ~5 lines in the bypass branch plus a test; happy to land it immediately.
got it, need a fix.
probably should fallback to normal openclaw compact when it's excluded.