eyaltoledano/claude-task-master · error
Not in active TDD phase
Error message
Not in active TDD phase
What it means
completePhase() requires the workflow to currently be inside an active TDD phase (RED, GREEN, or COMMIT) of the SUBTASK_LOOP. getCurrentTDDPhase() returns undefined when the workflow is in PREFLIGHT, BRANCH_SETUP, FINALIZE, COMPLETE, or otherwise not mid-cycle, and the method throws 'Not in active TDD phase'. Unlike the no-orchestrator error, the workflow exists here; it is just in a phase where test results cannot be applied.
Source
Thrown at packages/tm-core/src/modules/workflow/services/workflow.service.ts:425
action: 'unknown',
description: 'Unknown TDD phase',
nextSteps: 'Use autopilot_status to check workflow state.'
};
}
}
/**
* Complete current TDD phase with test results
*/
async completePhase(testResults: TestResult): Promise<WorkflowStatus> {
if (!this.orchestrator) {
throw new Error('No active workflow. Start or resume a workflow first.');
}
const tddPhase = this.orchestrator.getCurrentTDDPhase();
if (!tddPhase) {
throw new Error('Not in active TDD phase');
}
// Transition based on current phase
switch (tddPhase) {
case 'RED':
await this.orchestrator.transition({
type: 'RED_PHASE_COMPLETE',
testResults
});
break;
case 'GREEN':
await this.orchestrator.transition({
type: 'GREEN_PHASE_COMPLETE',
testResults
});
break;
case 'COMMIT':
throw new Error(View on GitHub (pinned to c0c98d367c)
Solutions
- Check status first: only call completePhase() when status.phase === 'SUBTASK_LOOP' and status.tddPhase is RED or GREEN
- Wait for startWorkflow() to fully finish (it transitions through PREFLIGHT and BRANCH_CREATED) before reporting results
- Use getNextAction(); if action is 'unknown' or 'finalize_workflow', the workflow is not in a phase that accepts test results
- Guard with getCurrentTDDPhase()/status.tddPhase before calling completePhase()
Example fix
// before
await workflowService.completePhase(results); // throws outside RED/GREEN
// after
const s = workflowService.getStatus();
if (s.phase === 'SUBTASK_LOOP' && (s.tddPhase === 'RED' || s.tddPhase === 'GREEN')) {
await workflowService.completePhase(results);
} Defensive patterns
Strategy: validation
Validate before calling
const s = workflowService.getStatus();
if (s.phase !== 'SUBTASK_LOOP' || !s.tddPhase) {
throw new Error(`Cannot completePhase in phase ${s.phase}`);
} Type guard
function isInActiveTddPhase(s: { phase: string; tddPhase?: string }): boolean {
return s.phase === 'SUBTASK_LOOP' && (s.tddPhase === 'RED' || s.tddPhase === 'GREEN' || s.tddPhase === 'COMMIT');
} Try / catch
try {
await workflowService.completePhase(results);
} catch (e) {
if (e instanceof Error && e.message === 'Not in active TDD phase') {
const s = workflowService.getStatus();
// wait for SUBTASK_LOOP or route to commit()/finalize as appropriate
} else throw e;
} Prevention
- Wait for startWorkflow() to fully return before reporting results (PREFLIGHT/BRANCH_SETUP must finish)
- Check getStatus().phase === 'SUBTASK_LOOP' before every completePhase() call
- Do not double-fire completePhase for the same cycle; each call advances the state machine
- Use getNextAction() to confirm the expected action before transitioning
When it happens
Trigger: Calling completePhase() right after startWorkflow() while still in PREFLIGHT/BRANCH_SETUP (BRANCH_CREATED transition not yet processed); calling it during FINALIZE or COMPLETE; calling it twice in a row when the first call already advanced RED->GREEN and results were stale-resubmitted for a non-loop phase.
Common situations: Reporting test results before the subtask loop began; resuming a workflow that was mid-finalize; automation double-firing completePhase so the second call lands in a transition window with no TDD phase.
Related errors
- Invalid transition: RED_PHASE_COMPLETE from non-RED phase
- Invalid transition: GREEN_PHASE_COMPLETE from non-GREEN phas
- Invalid transition: COMMIT_COMPLETE from non-COMMIT phase
- Cannot commit in ${tddPhase} phase. Complete RED and GREEN p
- Workflow has been aborted
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/0ff0276668fd4f8f.
Report an issue: GitHub.