3. modularize session context - #2190
Conversation
|
Macroscope skipped reviewing this pull request. Per-review cost limit exceeded (workspace setting). This review would cost an estimated $11.06, 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:
|
Refs ENG-5938
Refs ENG-5938
Refs ENG-5938
d68c7af to
827d1d4
Compare
Prime Agent performance — completedPR Overall: 0 regressed · 0 improved · 17 no clear change.
Python runtime
Sandbox cost: ~$0.0954 — no inference calls. Methodology and samplesMain resolved at 2026-09-10T23:42:51.727337+00:00. Harness
|
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 827d1d4. Configure here.
| AutoRefineReviewer, | ||
| AutoRefineReviewRequest, | ||
| SerializedBackgroundPlanResult, | ||
| } from "../session/refinement.js"; |
There was a problem hiding this comment.
Internal type re-exported without consumers
Low Severity
SerializedBackgroundPlanResult is re-exported from AgentSession after the move, but nothing outside SessionRefinement and its tests imports that type. AutoRefineReviewer still needs a public export; this internal plan result does not.
Triggered by project rule: Review rules
Reviewed by Cursor Bugbot for commit 827d1d4. Configure here.


src/session/. AgentSession falls from 11,028 to 8,990 lines and keeps public coordination. Stacked on 2. modularize session runtime #2185; tracks ENG-5938.npm run check, andgit diff --checkpass atd1fba70304e4a1af1000e32ff13986ba649458a6. Independent static review verified the refinement corrections. Separate Astra Prime Sandbox validation and benchmarks must assess this exact head againstdc66f163d1a7e809e962f649f2825f4b857d2b48; earlier71bfevidence is diagnostic. Macroscope skipped the earlier review because of its cost cap.Note
Modularize
AgentSessioninto compaction, refinement, and continuation ownersSessionCompaction,SessionRefinement,AutoRefinement,RefinementExecution,SessionContinuation, andperformSessionCompactioninto dedicated modules under packages/coding-agent/src/session/, each with its own host interfacerefinement.execution,refinement.auto,compaction,continuation) instead of flat private fields, and adds boundary/regression tests for ownership, cancellation, and orderingAgentSessionno longer exposes flat internal fields like in-flight refinement promises or compaction abort controllers; out-of-tree tests or integrations reading those private paths will break. TheRefineSkippedErrorandCompactionSkippedErrortypes are re-exported from new module locationsMacroscope summarized 827d1d4.
Note
High Risk
Large move of concurrency-sensitive compaction, refinement, and continuation logic; regressions in cancellation, ordering, or persistence would affect core agent turns without changing the public API surface much.
Overview
Pulls compaction, refinement, and post-compaction continuation out of
AgentSessioninto dedicatedsession/owners, wired through typed host callbacks for model/auth, persistence, extensions, scheduling, and events.AgentSessionnow composesSessionCompaction,SessionRefinement(withAutoRefinement+ execution helpers), andSessionContinuation, and delegates public methods likecompact(),refine(), hostcompact.*/refine.*requests, and threshold checks instead of keeping large private state machines inline.Behavior is intended to stay the same: manual/automatic compaction lifecycle, overflow recovery, semantic-edge ordering before transcript commit, serialized vs interactive auto-refine, and continuation settlement/cancellation rules are documented in README and implemented in the new modules (
performSessionCompaction, continuation commit-fence release, refinement apply barriers). Types and events are re-exported from the new locations (CompactionReason,CompactionSkippedError,RefineSkippedError, compaction events) so external callers keep stable imports from the session facade.Docs and tests add a session-context module map, boundary preservation notes, and coverage pointers for owner-level lifecycle tests.
Reviewed by Cursor Bugbot for commit 827d1d4. Bugbot is set up for automated code reviews on this repo. Configure here.