eyaltoledano/claude-task-master · error

Cannot complete COMMIT phase with test results. Use commit()

Error message

Cannot complete COMMIT phase with test results. Use commit() instead.

What it means

completePhase(testResults) handles RED and GREEN transitions only. When the current TDD phase is COMMIT, test results are meaningless because the RED-GREEN cycle already finished; the workflow expects a commit via commit(). The library throws this explicit redirect so agents do not try to 'complete' the COMMIT phase with results.

Source

Thrown at packages/tm-core/src/modules/workflow/services/workflow.service.ts:443

			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(
					'Cannot complete COMMIT phase with test results. Use commit() instead.'
				);
			default:
				throw new Error(`Unknown TDD phase: ${tddPhase}`);
		}

		return this.getStatus();
	}

	/**
	 * Commit current changes and advance workflow
	 */
	async commit(): Promise<WorkflowStatus> {
		if (!this.orchestrator) {
			throw new Error('No active workflow. Start or resume a workflow first.');
		}

		const tddPhase = this.orchestrator.getCurrentTDDPhase();

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Check the phase first and call commit() when tddPhase === 'COMMIT' instead of completePhase()
  2. Use getNextAction(); when it returns action 'commit_changes', invoke commit()
  3. Stop resubmitting test results after a successful GREEN completion; the same results transitioned you already
  4. Catch the error and route to commit() in agent loops

Example fix

// before
await workflowService.completePhase(results); // throws in COMMIT
// after
const tdd = workflowService.getStatus().tddPhase;
if (tdd === 'COMMIT') {
  await workflowService.commit();
} else {
  await workflowService.completePhase(results);
}
Defensive patterns

Strategy: validation

Validate before calling

const tdd = workflowService.getStatus().tddPhase;
if (tdd === 'COMMIT') {
  await workflowService.commit();
} else {
  await workflowService.completePhase(results);
}

Type guard

function isCommitPhase(e: unknown): e is Error {
  return e instanceof Error && e.message.includes('Cannot complete COMMIT phase');
}

Try / catch

try {
  await workflowService.completePhase(results);
} catch (e) {
  if (isCommitPhase(e)) {
    await workflowService.commit();
  } else throw e;
}

Prevention

When it happens

Trigger: Calling completePhase() while orchestrator.getCurrentTDDPhase() === 'COMMIT' — e.g. after GREEN already completed and the machine advanced to COMMIT; an automation loop that keeps posting test results each cycle without checking the phase.

Common situations: An AI agent running autopilot_complete_phase in a loop and overshooting into COMMIT; test-runner webhooks re-delivering results after the phase advanced; scripted pipelines that always call completePhase after tests regardless of phase.

Related errors


AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29). Data as JSON: /api/errors/31efd9967337637c. Report an issue: GitHub.