Repository navigation
fix(agents): resolve authoritative session keys for delegated compaction - #120047
Merged
Merged
Conversation
Closed
14 of 28 tasks
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Aug 7, 2026
…ion (openclaw#120047) * fix(agents): resolve authoritative session keys for delegated compaction * refactor(agents): keep session-target resolution error class module-local
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
When a plugin owns the
contextEngineslot and delegates compaction back to the runtime, every LLM compaction fails asoutcome=failed reason=unknown. Two independent defects: the sessionId UUID was silently substituted for a missing sessionKey (three layers deep), so the sqlite transcript write matched no row; and the failed append collapsed into a generic no-cause error, leaving the operator zero diagnostic signal.Fixes #119018 (reported by @abacha).
Why This Change Was Made
Provenance:
4273ca9dbd9b3added the baresessionIdfallback inrun-session-target.ts;40dafc5c332dadded the compatibility projection that stripssessionKey/sessionTargetfor undeclared engines — together they let a UUID masquerade as a session key.The repair establishes two explicit ownership boundaries instead of patching the symptom:
resolveAgentRunSessionTargetnow requires explicit intent —missingSessionKey: "create" | "resolve-existing". Only new-run admission (runEmbeddedAgent, whose public input legitimately permits an omitted key) may mint a canonical agent-scoped key. Every keyed-store consumer (compaction, persistence, locks, successor paths) resolves the authoritative key through the session store or throws a typedsession-key-missingerror. All compaction-side?? sessionIdsentinels were removed (queued/direct compaction, hooks, CLI compaction, recovery targets, transcript rewrites, deferred maintenance).appendSqliteTranscriptEventSyncreturnsResult<boolean, TranscriptEventAppendError>: missing-row and rebound-row outcomes carry typed codes and identity details; duplicate appends remain the load-bearingok(false)no-op. SessionManager attaches the typed result asError.cause, and compaction reportsreason=transcript_persistence_failedinstead ofunknown.Sibling surfaces checked: queued/manual, direct/delegated, overflow/timeout recovery, non-delegated engines (shared repaired seam), post-compaction maintenance, gateway manual compaction, Codex native compaction (separate keyed path, unaffected), Copilot (session-ID-owned lookup unaffected), ACPX (covered).
User Impact
Delegated context-engine compaction works. When transcript persistence genuinely fails, operators see a typed reason with row-identity detail instead of
reason=unknown.Evidence
9fdae501before implementation.OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree node scripts/run-vitest.mjs src/agents/run-session-target.test.ts src/config/sessions/session-accessor.test.ts src/agents/sessions/session-manager.test.ts src/agents/embedded-agent-runner/compact-reasons.test.ts src/agents/embedded-agent-runner/compaction-runtime-context.test.ts src/agents/embedded-agent-runner/compact.hooks.test.ts— 5 shards, 319 tests passed (re-verified independently after review).pnpm tsgo:core,pnpm tsgo:core:test, targeted oxlint, plugin SDK API baseline: all passed.gpt-5.6-sol, high), run twice (worker closeout + independent coordinator pass on the frozen diff): clean both times, no accepted/actionable findings.