Repository navigation
fix(agents): preserve context engine session ownership - #124376
Conversation
Unbound legacy context-engine hooks no longer execute LLM calls under the default agent. Explicit, agent-scoped, main-alias, and persisted session ownership remain supported.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 15, 2026, 11:36 PM ET / August 16, 2026, 03:36 UTC. ClawSweeper reviewWhat this changesThe branch carries the original explicit session owner through context-engine maintenance and compaction so unbound legacy session keys cannot invoke LLM work as the default agent. Merge readinessThis remains necessary: current main still forwards fallback-selected ownership into context-engine LLM capability creation. The PR preserves the original explicit owner across lifecycle paths and appears correct, but the intentional fail-closed compatibility boundary requires maintainer confirmation. Priority: P1 Review scores
Verification
How this fits togetherEmbedded agent runs select a session and may perform after-turn maintenance or compaction through a context-engine plugin. That plugin receives an LLM capability which must be bound to the original session owner before it can select credentials and a model. flowchart LR
A[Incoming agent run] --> B[Session resolution]
B --> C[Capture original explicit owner]
C --> D[Maintenance and compaction lifecycle]
D --> E[Bound ownership check]
E --> F[Context-engine LLM call]
E --> G[Reject unbound legacy key]
Decision needed
Why: The change narrows a credential and model-selection authority boundary; source establishes the bug and repair, but accepting the user-visible compatibility break is an owner decision. Before merge
Agent review detailsSecurityNone. PR surfaceSource +35, Tests +220. Total +255 across 21 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one pre-fallback ownership fact as the canonical authority input, merge only if maintainers accept the fail-closed legacy behavior, and require green exact-head checks. Do we have a high-confidence way to reproduce the issue? Yes. Current main’s after-turn capability path supplies the fallback active agent, while the PR’s focused lifecycle tests encode the same unbound-key scenario; this read-only review did not run the tests locally. Is this the best way to solve the issue? Yes. Capturing the original explicit owner before fallback resolution and carrying it to the existing authority gate is safer than adding consumer-side checks after a fallback has already been accepted. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a0498f7a9c8a. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Land-ready on exact head ClawSweeper before-merge items and rank-up move:
Proof:
Production LOC: +55/-20 (net +35). Tests: +258/-38 (net +220). Known proof gap: no live provider/channel run was used; this is a deterministic internal authorization-boundary repair with focused owner-boundary tests, and ClawSweeper classified real-behavior proof as not applicable. |
|
Merged via squash.
|
* fix(agents): preserve context engine session ownership Unbound legacy context-engine hooks no longer execute LLM calls under the default agent. Explicit, agent-scoped, main-alias, and persisted session ownership remain supported. * test(ci): avoid scheduler pid file race
* fix(agents): preserve context engine session ownership Unbound legacy context-engine hooks no longer execute LLM calls under the default agent. Explicit, agent-scoped, main-alias, and persisted session ownership remain supported. * test(ci): avoid scheduler pid file race (cherry picked from commit a6cb2fb)
Related: #123222
AI-assisted: yes (Codex).
What Problem This Solves
Fixes an issue where unbound legacy context-engine hooks could execute LLM calls as the configured default agent after runtime or compaction code replaced missing session ownership with a fallback agent. This completes the ownership repair begun in #123222 and addresses the failure exposed by the beta2 prerelease run.
Why This Change Was Made
The runtime now captures only the original pre-fallback explicit owner and original authority session key, then carries those facts through after-turn maintenance, queued and overflow compaction, recovery, post-compaction, and finalization. The context-engine LLM boundary remains the canonical authority resolver: explicit ownership, agent-scoped keys, the main alias, and persisted bindings resolve normally, while an arbitrary legacy key whose only agent came from default/fallback selection fails closed.
This adds 35 net production lines (+55/-20) to preserve and transport the ownership fact across the existing lifecycle boundary; tests add 220 net lines (+258/-38), including a bounded repair for a PID-file readiness race exposed by the first CI run. No config, protocol, storage schema, dependency, or changelog surface changes.
User Impact
Unbound legacy context-engine hooks no longer execute LLM calls under the default agent. Explicit, agent-scoped, main-alias, and persisted session ownership remain supported across normal turns, maintenance, queued compaction, overflow recovery, and finalization.
Evidence
node scripts/check-changed.mjs --dry-runselected onlycoreandcoreTests.node scripts/check-changed.mjspassed after rebase, including core production/test typechecks, targeted oxfmt and oxlint, max-lines ratchet (911 grandfathered suppressions), dead-export scan, plugin boundaries, database-first guard, runtime import cycles, and the remaining selected architecture guards. The remote fast-CI provider was unavailable, so the repository wrapper completed the gate through its supported local fallback.test/scripts/docker-all-scheduler.test.ts: the test waited for PID-file existence but could read between open/truncate and content write. The follow-up waits for a complete positive PID at both affected sites;node scripts/run-vitest.mjs test/scripts/docker-all-scheduler.test.tsthen passed all 46 tests, and targeted oxfmt/oxlint passed.git diff --check origin/main...HEADpassed on exact head82e6228e7ce7949d7ea98982f53809efa5dd8f5e.Release-note context: unbound legacy context-engine hooks no longer execute LLM calls under the default agent; explicit/scoped/persisted ownership remains supported.