AI Agents SDE Task Viewer
      • Pr description
  1. Home
  2. AgentSDE
  3. agent-core
  4. gh-232
  5. changes
  6. pr_description.md
pr_description.md(1.8 KB)· Apr 2, 2026· 1 min read
  • Problem
  • Task / Link
  • Changes
  • Notes
  • Testing

feat(#232): add /agent replan directive#

Problem#

No directive existed to reset a task's full phase state, close any open PR/branch, and restart from refinement. /agent restart was blocked on active tasks; /agent replan is needed for a clean slate restart regardless of task state.

Task / Link#

Closes #232

Changes#

  • Add 'replan' to ALLOWED_DIRECTIVES in directive.dto.ts
  • Add closePR() and deleteBranch() to GitHubService (404/422 treated as success)
  • Add cleanupLabelsForReplan() to PhaseHooksService (removes refined, in-review, agent-blocked; adds in-refinement)
  • Implement full replan handler in DirectiveService: validates state, closes PR/branch, resets phases, records event, cleans labels, enqueues refine
  • Wire replan into PhaseRouterService: VALID_DIRECTIVES, resolvePhase() (returns 'refine'), directive handling block (no active-process rejection)
  • Update DirectiveModule to import GitHubModule, EventModule, PhaseHooksModule

Notes#

  • In-flight Claude runs are not force-killed on replan (PIDs not tracked across service boundary). The phase-router's active-phase guard prevents double-execution; old processes time out naturally.
  • Replan on already-in-active-refine tasks is a no-op with an explanatory comment.
  • Replan on terminal tasks (succeeded, failed, complete) is rejected with an explanatory comment.

Testing#

  • Unit tests added: replan in DirectiveService (normal path, no-PR path, already-in-refine guard, terminal-state rejection, PR-close failure tolerance)
  • Unit tests added: closePR and deleteBranch in GitHubService (happy path, 404/422 as success, non-404/422 rethrow)
  • Unit tests added: resolvePhase with replan directive in PhaseRouterService
  • npm run lint — 0 errors, 0 new warnings
  • npm run test — 661/661 passing
  • npm run build — clean
PrdAgent-runner