AI Agents SDE Task Viewer
      • Context
      • Plan
      • Prd
  1. Home
  2. AgentSDE
  3. agent-core
  4. gh-233
  5. plan
  6. plan.md
plan.md(2.0 KB)· Apr 2, 2026· 2 min read
  • Summary
  • Files
  • Steps
  • Verification
  • Risks

Plan: Fix /agent refine no-op for non-gated tasks#

Summary#

Add pre-validation to the refine directive in DirectiveService.applyDirective() so it only executes for gated tasks and posts explicit rejection comments for all other states — eliminating the misleading confirmation comment that currently appears even when no phase transition occurs.

Files#

FileActionDescription
src/directive/directive.service.tsmodifyAdd refine guard block before generic handler (lines 96–121)
src/directive/directive.service.spec.tsmodifyAdd tests for gated/non-gated/terminal refine scenarios

Steps#

  1. Add refine pre-validation block in directive.service.ts — Insert a new if (directive === 'refine') block after the restart handler (line 89) and before the generic handler (line 96). Check terminal states (succeeded, failed) → post rejection with terminal message. Check task.status !== 'gated' → post rejection with status message. For gated tasks: clear gate via taskStateService.clearGate(task), save, enqueue refine phase via internalAdapterService.enqueuePhase(), post confirmation, return.
  2. Update directive.service.spec.ts with refine test cases — Replace the existing refine: sets directive and dispatches test (line 143) with a describe('refine directive') block containing: (a) gated task succeeds — clears gate, enqueues refine phase, posts confirmation; (b) active task → posts rejection, no dispatch; (c) succeeded task → posts terminal rejection, no dispatch; (d) failed task → posts terminal rejection; (e) refine does not overwrite task.directive (preserves existing careful/auto).

Verification#

  • npm run test — all unit tests pass including new refine scenarios
  • npm run lint — zero warnings
  • npm run build — compiles cleanly

Risks#

  • The clearGate method must be called before enqueuing to prevent re-gating; this mirrors the pattern used by resetForRetry/resetForRestart in the existing retry/restart handlers.
ContextPrd