1. modularize /goal logic - #2184
Conversation
Prime Agent performance — completedPR Overall: 0 regressed · 0 improved · 17 no clear change.
Python runtime
Sandbox cost: ~$0.0907 — no inference calls. Methodology and samplesMain resolved at 2026-09-10T23:42:48.640022+00:00. Harness
|
Refs: ENG-5938 fixes #2184
Refs: ENG-5938
Refs: ENG-5938 fixes #2184
caee21d to
120516e
Compare
npm run checkpass.Note
Medium Risk
Large refactor of goal lifecycle wiring in
AgentSession; behavior depends on preserved ordering for accounting, completion cleanup, and continuation rollback clocks.Overview
Pulls goal state, accounting, persistence, and
/goalparsing out ofAgentSessioninto a dedicatedgoals/feature:GoalControllerowns transitions, token/time accounting, continuation checkpoints, and assistant usage dedup;persistence.tswraps branch load/save and CLI seed eligibility;commands.tsholds slash-command parsing.AgentSessionnow wires aGoalControllerwith session persistence andgoal_updateemissions, delegating start/pause/resume/clear/complete/fail, budget limiting, continuation increment/rollback, and branch reload. Host completion passes a callback so stale budget-limit contexts are cleared before completion is persisted. Continuation races restore state viacheckpoint/restore(with optional clock preservation after deferred RLM work).Adds
src/README.mddocumenting the extraction pattern and ordering invariants. Addstest/goals/controller.test.tsand updates continuation quiescence tests to use a controller-backed harness.core/goals.tstypes andthread_goal_stateformat are unchanged.Reviewed by Cursor Bugbot for commit 120516e. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Extract
/goallogic fromAgentSessionintoGoalControllerand supporting modulesAgentSessioninto a newgoals/package containing controller.ts, persistence.ts, and commands.ts.GoalControllerowns all goal lifecycle operations (start, pause, resume, fail, complete, rollback, assistant-usage accounting) using an injected persistence adapter and clock for deterministic time accounting.AgentSessionconstructs the controller and delegates to it; the publicgoalStategetter now returns the controller's clock-accounted snapshot.src/organization and goal ownership boundaries.createGoalPersistence; out-of-tree consumers relying on broader seed eligibility may need updating.Macroscope summarized 120516e.