6. consolidate session feature ownership - #2249
Conversation
Preserve existing public and historical module exports through explicit compatibility facades. Keep compaction, refinement, and shared context implementations with their session owners. closes #2190
Refs ENG-5934 and ENG-5938.
Prime Agent performance — partialPR Overall: 1 regressed · 0 improved · 12 no clear change · 4 unavailable.
Python runtime
Sandbox cost: ~$0.1629 — no inference calls. Methodology and samplesMain resolved at 2026-09-12T06:55:55.904723+00:00. Harness
Failures:
|
|
Macroscope skipped reviewing this pull request. Per-review cost limit exceeded (workspace setting). This review would cost an estimated $50.47, which exceeds your per-review limit of $10.00. The top 3 files driving up this estimate:
Tip To get this pull request reviewed, you can:
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c7b0f53. Configure here.
Remove only the pull-request base branch filter while preserving the contributor gate and existing jobs. Refs ENG-5934; closes #2249.
|
Hi — downstream line here (we run a fork with ~100 reliability commits on your 0.9.x; full context in Discussion #2239). We've been studying this refactor stack in detail because our fixes will need re-homing once it lands. The stack's shape is genuinely helpful for that. Four seams would make the re-home purely additive on our side, if they fit your plans:
And one heads-up in return: the stack's current tip still carries the waitForIdle spin defect you fixed in #2151 — Happy to share our implementations of any of the four (each has regression tests). Thanks for doing this split — the god object needed to go. |
|
hey @Dmatut7! Sorry for the inconvenience here-- we were shipping really fast, but now I'm taking the time to clean up the codebase, especially starting with the agent-session class 😅 I'll take a look at your 4 suggestions and see if we can add to the stack or a future PR. Thanks for reaching out! and would love to hop on a call and learn about your usecases with Prime Agent if you're available :) |

Context
This continues the coding-agent cleanup stack by finishing feature ownership after the earlier session extractions. Compaction, refinement and input still had implementations split between core and session, making related behavior difficult to find and change together.
Changes
Consolidates context algorithms, refinement planning and persistence, input actions, autonomy and child request contracts under their session owners. Separates daemon residency policy from the action queue and model search/shell requests from child handling. Public exports and historical import paths remain available through explicit compatibility exports. Validation rules, autonomous argument parsing, persistence, protocol and session behavior are preserved. Adds reusable refactoring conventions and the remaining migration ledger. The CI trigger now accepts stacked PR targets with its existing contributor checks and jobs unchanged.
Validation
Full repository checks and the complete GitHub CI matrix pass at c3311d9. The combined session suite passed 343 tests. Paired Prime Sandboxes exercised installed TUI input, CLI/daemon refinement ordering, real Python execution/interrupt/snapshot/restore, SDK exports and historical declarations against the pinned base. Independent review found no actionable regression. Initial SDK-name and missing-goal-interpreter fixture failures are retained in the evidence; separate corrections passed, including the unchanged goal assertions at the final stack head. Two live-provider compaction cases remain intentionally unexecuted.
The sandbox-tested product pin is c7b0f53; c3311d9 changes only the CI trigger. All sandbox resources were deleted. Current-head Bugbot passes and its compatibility-alias thread was resolved with the required compatibility rationale. Macroscope skipped at its cost cap, no new-head CodeQL check is present, and the automated benchmark report is complete. It flags +0.14 MB compressed artifacts (+1.22%) against then-current main b53c2e9; the other 16 metrics show no clear change under the harness thresholds. This compares the cumulative stack against main, not this follow-up in isolation. No performance improvement is claimed.
ENG-5934, ENG-5938. Stacked on #2194; kernel/runtime ownership follows in #2250.
Note
Consolidate session feature ownership by relocating core modules into session subpackages
core/into their canonicalsession/subpackages; core modules become compatibility facades that re-export from the session owners.core/facades must stay in sync with session exports or compatibility tests will fail.Macroscope summarized 3e96f9e.
Note
High Risk
Large refactor of session orchestration, input scheduling, and compaction/refinement boundaries with compatibility facades; incorrect wiring could affect ordering, idle/passivation, or legacy import paths.
Overview
This PR finishes session feature ownership after earlier extractions by moving compaction, refinement, context, input, autonomy, and child contracts into canonical
session/modules whilecore/paths become thin re-export facades (including shrinkingcore/agent-session.tsto forwardsession/agent-session.ts).Related splits include
ActionStorequeue logic vs daemon worker residency/eviction inmodes/daemon/workers/residency-policy.ts, refinement planning vs lightweight formatting to break import cycles, and child model search / bash host requests out of the old combined RLM module.Contributor docs add
docs/refactoring.md, an expandedsource-organization-plan.md, and updated architecture/source-map guidance. CI now runs on all pull requests (drops thepull_request→mainbranch filter) so stacked branches get checks.A separate fix stops session idle waits from spinning CPU when the input pump is blocked on bash, compaction, or retry work.
Reviewed by Cursor Bugbot for commit 3e96f9e. Bugbot is set up for automated code reviews on this repo. Configure here.