Skip to content

feat(context-engine): report compaction successors as typed session targets#101182

Merged
jalehman merged 1 commit into
mainfrom
b62.7/delegate-session-target
Jul 7, 2026
Merged

feat(context-engine): report compaction successors as typed session targets#101182
jalehman merged 1 commit into
mainfrom
b62.7/delegate-session-target

Conversation

@jalehman

@jalehman jalehman commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Context engines that own compaction report their post-compaction successor session to the host through CompactResult.result.sessionFile — a raw file-path string. A bare path cannot say which agent/session it belongs to or what storage mode backs it, so every consumer re-infers identity from a path, and the contract cannot describe non-file-backed sessions.

Why This Change Was Made

Adds a typed successor contract: CompactResult.result.sessionTarget ({ kind: "file", agentId?, sessionId, sessionKey?, sessionFile }) makes storage mode explicit and carries precise identity. The delegate populates it; host consumers (adoptCompactionTranscript, runOwnsCompactionAfterHook, queued-compaction rotation detection) read target-first with the raw-field fallback centralized in one helper (resolveCompactionSuccessorTranscript). This matches the direction main already took for runtime params in run-session-target.ts.

CompactResult is a shipped plugin-SDK surface (exported via plugin-sdk/index.ts, present in release tag v2026.6.11, documented in docs/concepts/context-engine.md for third-party engine authors), so sessionFile stays populated and is marked @deprecated naming that shipped contract, with removal planned once typed targets are the only successor contract.

User Impact

None for existing plugins — sessionFile keeps working unchanged. Engine authors get a typed, documented successor contract; docs updated accordingly.

Evidence

  • Consumer map verified: all in-scope CompactResult.sessionFile readers migrated (run.ts adoption paths, compact.queued.ts rotation detection, delegate producer); the four look-alike readers of the runtime EmbeddedAgentCompactResult type confirmed out of scope at each site.
  • context-engine.test.ts updated bridge test + 2 new tests; 206/206 tests pass across the five suites exercising compaction adoption paths.
  • Plugin SDK API baseline regenerated via the sanctioned plugin-sdk:api:gen for the intentional surface addition; pnpm build green (SDK export checks pass).
  • oxfmt/oxlint clean; structured review (codex/gpt-5.5) clean, zero findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Jul 6, 2026
@jalehman
jalehman force-pushed the b62.7/delegate-session-target branch from 8546206 to f57a3a4 Compare July 6, 2026 20:31
@jalehman

jalehman commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

ClawSweeper status: review started.

I am starting a fresh review of this pull request: feat(context-engine): report compaction successors as typed session targets This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 6, 2026
@clawsweeper

clawsweeper Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 6, 2026, 9:37 PM ET / 01:37 UTC.

Summary
Adds ContextEngineSessionTarget and CompactResult.result.sessionTarget, migrates compaction successor consumers to prefer it, and updates docs, tests, and SDK surface metadata.

PR surface: Source +67, Tests +70, Docs +3, Generated 0, Other 0. Total +140 across 9 files.

Reproducibility: not applicable. this is an additive SDK/API feature rather than a bug report. Source inspection confirms current main and v2026.6.11 lack the typed successor target while the PR adds and tests it.

Review metrics: 1 noteworthy metric.

  • Plugin SDK API surface: 1 exported type added, 1 CompactResult.result field added, 0 removals. This is a public plugin contract change, so maintainers should review compatibility and API direction beyond ordinary CI results.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦪 silver shellfish
Patch quality: 🦞 diamond lobster
Result: blocked until real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add redacted terminal output, live logs, or an artifact from a real context-engine compaction returning sessionTarget and the host adopting the successor.
  • Refresh or revalidate against current main after the maintainer API direction is accepted.

Proof guidance:

  • [P1] Needs real behavior proof before merge: Missing: the PR body and comments list tests/CI but no redacted real plugin compaction output or logs showing sessionTarget returned and adopted; the contributor should update the PR body with redacted terminal/log/live proof so ClawSweeper can re-review.

Risk before merge

  • [P1] Merging publishes a new plugin-SDK CompactResult field and exported type, so maintainers need to accept sessionTarget as the public successor API and the sessionFile deprecation direction.
  • [P1] The contributor still has not provided after-fix real behavior proof showing a context engine returning sessionTarget and the host adopting that successor in a real setup.
  • [P1] The PR has the protected maintainer label and is based on an older base SHA than current main, so it needs human handling and exact-head/base-refresh confidence before merge.

Maintainer options:

  1. Accept the additive SDK surface after proof (recommended)
    Accept the public sessionTarget direction once the branch is current and redacted real behavior proof shows production-style adoption.
  2. Keep the target resolver internal
    Ask for a focused change that keeps target-first host consumption but removes the public SDK field and export until API direction is approved.
  3. Pause until storage direction is settled
    Pause or close this PR if maintainers do not want a file-only public target union before non-file-backed sessions are designed.

Next step before merge

  • [P1] Human review is needed for the public plugin-SDK API direction, protected maintainer label, and contributor proof gate; there is no narrow code defect for automated repair.

Maintainer decision needed

  • Question: Should OpenClaw accept CompactResult.result.sessionTarget as the next public compaction-successor contract now, while preserving deprecated sessionFile compatibility for shipped plugins?
  • Rationale: The patch is additive and appears compatible in source review, but choosing a permanent public plugin-SDK field and deprecation path is a maintainer API decision rather than an automation-only call.
  • Likely owner: jalehman — They own the most directly related context-engine and run-session-target history and are already assigned to this PR.
  • Options:
    • Accept typed target after proof (recommended): Proceed with sessionTarget as the preferred SDK contract, keep sessionFile compatibility, and require real behavior proof plus refreshed validation before merge.
    • Keep resolver internal first: Ask for a narrower patch that centralizes host successor resolution without exposing a new plugin-SDK field until the API direction is approved.
    • Pause API expansion: Defer or close this direction until maintainers settle the broader non-file-backed session storage contract.

Security
Cleared: The diff changes TypeScript SDK/runtime types, docs, tests, and a surface-budget constant; I found no concrete security or supply-chain regression.

Review details

Best possible solution:

Land the additive SDK contract only after maintainer acceptance, redacted live/log proof, and branch refresh or exact-head validation, while preserving deprecated sessionFile compatibility for shipped plugins.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this is an additive SDK/API feature rather than a bug report. Source inspection confirms current main and v2026.6.11 lack the typed successor target while the PR adds and tests it.

Is this the best way to solve the issue?

Yes, conditionally: centralizing target-first resolution while preserving raw sessionFile fallback is the narrowest compatible implementation I found. The remaining blockers are public SDK direction and real behavior proof, not a concrete code defect.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 349d3547ccd1.

Label changes

Label justifications:

  • P3: This is a small additive SDK ergonomics feature with limited immediate user impact, not an urgent runtime regression.
  • merge-risk: 🚨 compatibility: Merging publishes a new plugin-SDK CompactResult field and deprecates the old successor path, which affects third-party engine contracts beyond green CI.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦪 silver shellfish and patch quality is 🦞 diamond lobster.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Missing: the PR body and comments list tests/CI but no redacted real plugin compaction output or logs showing sessionTarget returned and adopted; the contributor should update the PR body with redacted terminal/log/live proof so ClawSweeper can re-review.
Evidence reviewed

PR surface:

Source +67, Tests +70, Docs +3, Generated 0, Other 0. Total +140 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 5 80 13 +67
Tests 1 78 8 +70
Docs 1 5 2 +3
Config 0 0 0 0
Generated 1 2 2 0
Other 1 1 1 0
Total 9 166 26 +140

What I checked:

  • Repository policy applied: Root and scoped AGENTS files were read; plugin-SDK compatibility guidance applies because this PR adds a public context-engine result field and export. (AGENTS.md:29, 349d3547ccd1)
  • Current main behavior: Current main CompactResult.result exposes sessionId and sessionFile only; no typed compaction successor target exists on main. (src/context-engine/types.ts:128, 349d3547ccd1)
  • Shipped SDK contract: Latest release v2026.6.11 shipped CompactResult.result.sessionFile through the context-engine type surface, so preserving that field is a compatibility requirement. (src/context-engine/types.ts:126, e085fa1a3ffd)
  • Typed successor addition: The PR head adds ContextEngineSessionTarget, CompactResult.result.sessionTarget, and resolveCompactionSuccessorTranscript() with target-first raw-field fallback. (src/context-engine/types.ts:135, f4575619e1b3)
  • Delegate producer path: The delegate now constructs a file-backed sessionTarget while keeping deprecated raw sessionFile populated for existing plugin-SDK readers. (src/context-engine/delegate.ts:59, f4575619e1b3)
  • Runtime consumer path: The embedded run adoption path and queued compaction rotation detection both resolve successor identity through the new helper. (src/agents/embedded-agent-runner/run.ts:1865, f4575619e1b3)

Likely related people:

  • jalehman: Authored the original custom context-management plugin support, exposed the compaction delegate helper, and added the adjacent embedded run session-target seam this PR extends. (role: feature owner and recent area contributor; confidence: high; commits: fee91fefceb4, 7f0f8dd26802, 0dfa22c6e0fc; files: src/context-engine/types.ts, src/context-engine/delegate.ts, src/agents/run-session-target.ts)
  • steipete: Recent history shows broad embedded-agent runtime internalization and plugin-SDK boundary cleanup touching adjacent runtime and SDK surfaces. (role: adjacent runtime and SDK contributor; confidence: medium; commits: bb46b79d3c14, f2bd76cd1a4b; files: src/agents/embedded-agent-runner/run.ts, src/plugin-sdk/index.ts)
  • openperf: Authored the merged delegate bridge fix that forwarded abort signals through delegateCompactionToRuntime, making them relevant for delegate result contract review. (role: recent delegate bridge contributor; confidence: medium; commits: e0d7776fff86; files: src/context-engine/delegate.ts, src/context-engine/context-engine.test.ts)
  • DaevMithran: Authored a recent merged fix exporting missing context-engine types through the plugin SDK, adjacent to this public type export change. (role: plugin-SDK export contributor; confidence: medium; commits: 03be4c2489c8; files: src/plugin-sdk/index.ts, src/context-engine/types.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (2 earlier review cycles)
  • reviewed 2026-07-06T21:19:49.870Z sha f57a3a4 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-06T23:22:24.714Z sha 71d3c75 :: needs real behavior proof before merge. :: none

@jalehman
jalehman force-pushed the b62.7/delegate-session-target branch from f57a3a4 to 71d3c75 Compare July 6, 2026 22:57
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Jul 6, 2026
@jalehman jalehman self-assigned this Jul 7, 2026
@jalehman
jalehman force-pushed the b62.7/delegate-session-target branch from 71d3c75 to f457561 Compare July 7, 2026 01:17
@jalehman
jalehman force-pushed the b62.7/delegate-session-target branch from f457561 to e8897aa Compare July 7, 2026 04:59
@jalehman
jalehman merged commit 5d9a2b1 into main Jul 7, 2026
103 checks passed
@jalehman
jalehman deleted the b62.7/delegate-session-target branch July 7, 2026 05:14
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 7, 2026
jalehman added a commit that referenced this pull request Jul 7, 2026
Squash-and-replay of sqlite/sessions-transcripts-storage-flip (361 commits,
old head 7766516) onto main @ 21f2512, per the prep-series plan:
Phase 0/1 accessor-prep PRs (#101178-#101182, #101688, #101699) landed the
seam on main first, so this rebase reduces to the SQLite storage
implementation behind the session accessor.

Beyond the flip branch content, this merge:
- implements findTranscriptEvent (reverse-seq), recordInboundSessionMeta and
  updateSessionLastRoute over SQLite (deriveLastRoutePatch shared with the
  file-era store for doctor paths)
- adds cross-agent fork support (targetStorePath) so worktree/cross-agent
  sessions.create forks land child transcript rows in the target agent DB
- keeps main's newer behavior across the conflict surface (work admission,
  archive-gated deletes, preflight overflow budgeting, model fallback,
  replyOptions dispatch shape, lifecycle-header ordering)
- adopts the storage-neutral ContextEngineSessionTarget while preserving the
  deprecated CompactResult.sessionFile for shipped plugin readers

Known remainder (tracked for follow-up commits on this PR): ~415 test-case
failures across 43 files, dominated by stale vi.mock factories missing
main-side exports; prod typecheck, full build, and boundary ratchet are green.

Co-Authored-By: Claude Fable 5 <[email protected]>
sheyanmin pushed a commit to sheyanmin/openclaw that referenced this pull request Jul 8, 2026
jalehman added a commit that referenced this pull request Jul 8, 2026
Squash-and-replay of sqlite/sessions-transcripts-storage-flip (361 commits,
old head 7766516) onto main @ 21f2512, per the prep-series plan:
Phase 0/1 accessor-prep PRs (#101178-#101182, #101688, #101699) landed the
seam on main first, so this rebase reduces to the SQLite storage
implementation behind the session accessor.

Beyond the flip branch content, this merge:
- implements findTranscriptEvent (reverse-seq), recordInboundSessionMeta and
  updateSessionLastRoute over SQLite (deriveLastRoutePatch shared with the
  file-era store for doctor paths)
- adds cross-agent fork support (targetStorePath) so worktree/cross-agent
  sessions.create forks land child transcript rows in the target agent DB
- keeps main's newer behavior across the conflict surface (work admission,
  archive-gated deletes, preflight overflow budgeting, model fallback,
  replyOptions dispatch shape, lifecycle-header ordering)
- adopts the storage-neutral ContextEngineSessionTarget while preserving the
  deprecated CompactResult.sessionFile for shipped plugin readers

Known remainder (tracked for follow-up commits on this PR): ~415 test-case
failures across 43 files, dominated by stale vi.mock factories missing
main-side exports; prod typecheck, full build, and boundary ratchet are green.

Co-Authored-By: Claude Fable 5 <[email protected]>
giodl73-repo pushed a commit to giodl73-repo/openclaw that referenced this pull request Jul 8, 2026
jalehman added a commit that referenced this pull request Jul 9, 2026
Squash-and-replay of sqlite/sessions-transcripts-storage-flip (361 commits,
old head 7766516) onto main @ 21f2512, per the prep-series plan:
Phase 0/1 accessor-prep PRs (#101178-#101182, #101688, #101699) landed the
seam on main first, so this rebase reduces to the SQLite storage
implementation behind the session accessor.

Beyond the flip branch content, this merge:
- implements findTranscriptEvent (reverse-seq), recordInboundSessionMeta and
  updateSessionLastRoute over SQLite (deriveLastRoutePatch shared with the
  file-era store for doctor paths)
- adds cross-agent fork support (targetStorePath) so worktree/cross-agent
  sessions.create forks land child transcript rows in the target agent DB
- keeps main's newer behavior across the conflict surface (work admission,
  archive-gated deletes, preflight overflow budgeting, model fallback,
  replyOptions dispatch shape, lifecycle-header ordering)
- adopts the storage-neutral ContextEngineSessionTarget while preserving the
  deprecated CompactResult.sessionFile for shipped plugin readers

Known remainder (tracked for follow-up commits on this PR): ~415 test-case
failures across 43 files, dominated by stale vi.mock factories missing
main-side exports; prod typecheck, full build, and boundary ratchet are green.

Co-Authored-By: Claude Fable 5 <[email protected]>
jalehman added a commit that referenced this pull request Jul 9, 2026
Squash-and-replay of sqlite/sessions-transcripts-storage-flip (361 commits,
old head 7766516) onto main @ 21f2512, per the prep-series plan:
Phase 0/1 accessor-prep PRs (#101178-#101182, #101688, #101699) landed the
seam on main first, so this rebase reduces to the SQLite storage
implementation behind the session accessor.

Beyond the flip branch content, this merge:
- implements findTranscriptEvent (reverse-seq), recordInboundSessionMeta and
  updateSessionLastRoute over SQLite (deriveLastRoutePatch shared with the
  file-era store for doctor paths)
- adds cross-agent fork support (targetStorePath) so worktree/cross-agent
  sessions.create forks land child transcript rows in the target agent DB
- keeps main's newer behavior across the conflict surface (work admission,
  archive-gated deletes, preflight overflow budgeting, model fallback,
  replyOptions dispatch shape, lifecycle-header ordering)
- adopts the storage-neutral ContextEngineSessionTarget while preserving the
  deprecated CompactResult.sessionFile for shipped plugin readers

Known remainder (tracked for follow-up commits on this PR): ~415 test-case
failures across 43 files, dominated by stale vi.mock factories missing
main-side exports; prod typecheck, full build, and boundary ratchet are green.

Co-Authored-By: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant