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

Title#

fix: replan/restart must invalidate cached plan and PR association

Problem#

When /agent replan or /agent restart fires, stale plan artefacts and PR associations were reused on the next run. replan did not clear plan files; restart did not clear prNumber/prBranch at all.

Task / Link#

Closes #234

Changes#

  • Added replanAttempt integer column (default 0) to TaskEntity
  • Added resetForReplan() to TaskStateService: resets all phases, nullifies prNumber/prBranch, increments replanAttempt
  • Added clearPlanArtefacts(taskDir) to ArtefactsService: removes plan.md, context.json, prd.json from the plan directory
  • Updated DirectiveService replan handler: uses resetForReplan(), calls clearPlanArtefacts(), records replan_attempt telemetry, posts superseded comment before closing PR
  • Updated DirectiveService restart handler: clears prNumber/prBranch, closes open PR with superseded comment
  • Added unit tests covering all new behaviours and no-op edge cases

Notes#

  • clearPlanArtefacts is a no-op when the plan directory is absent (idempotent)
  • restart previously did not touch PR state; this is a deliberate behavioural change required by the issue
  • TypeORM synchronize mode handles the new column; no explicit migration needed

Testing#

  • Unit tests: resetForReplan() clears PR fields and increments counter; replan clears plan artefacts; restart clears PR state; replan_attempt telemetry recorded; no-op with no prior state
  • npm run lint — passes (pre-existing ws-gateway errors unrelated)
  • npm run test — 675 tests pass, 1 pre-existing failure in ws-gateway (missing @nestjs/websockets dev dep)
PrdAgent-runner