Skip to content

bug: issue with the task-master AI response parsing in claude-code #1223

@PabloAraya6

Description

@PabloAraya6

Description

task-master fails in CLAUDE CODE when updating or expanding a task because the model output is not valid JSON.
Instead of returning a strict JSON object, the response starts with natural language text (e.g., "I'll analy..."), which breaks the parser.


Steps to Reproduce

  1. Open a terminal on macOS 15.6.1 (24G90) with Node.js v23.11.0 and Task Master 0.26.0 installed.
  2. Run:
   task-master expand --id=2
  1. Alternatively:
   task-master update-task --id=2 --prompt="Break this task into 7 implementation subtasks: 1) Create worker-signup route and page structure 2) Implement Step 1 - …"
  1. Observe the parsing error.

Expected Behavior

  • The CLI should receive and parse a valid JSON object without any extra preamble or prose.
  • The task update/expansion should succeed and display the new subtasks.

Actual Behavior

  • The LLM returns additional text before the JSON object (e.g., "I'll analy...").

  • The CLI fails with a JSON parse error:

    Error: Failed to parse JSON response object: Unexpected token 'I', "I'll analy"... is not valid JSON
    

Screenshots or Logs

⏺ Bash(task-master update-task --id=2 --prompt="Break this task into 7 implementation subtasks: ...")
  ⎿  Error: - Updating task...

     Error: Failed to parse JSON response object: Unexpected token 'I', "I'll analy"... is not valid JSON
         at parseUpdatedTaskFromText (file:///opt/homebrew/lib/node_modules/task-master-ai/scripts/modules/task-manager/update-task-by-id.js:179:9)
         at updateTaskById (file:///opt/homebrew/lib/node_modules/task-master-ai/scripts/modules/task-manager/update-task-by-id.js:604:24)
         at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
⏺ Bash(task-master expand --id=2)
  ⎿  Error: - Generating 7 subtasks...

     Error: Failed to parse JSON response object after both simple and advanced attempts: Unexpected token 'I', "I'll analy"... is not valid JSON
         at parseSubtasksFromText (file:///opt/homebrew/lib/node_modules/task-master-ai/scripts/modules/task-manager/expand-task.js:207:10)
         at expandTask (file:///opt/homebrew/lib/node_modules/task-master-ai/scripts/modules/task-manager/expand-task.js:571:24)

Environment

  • Task Master version: 0.26.0
  • IA: claude-code
  • Node.js version: v23.11.0
  • Operating system: macOS 15.6.1 (24G90)
  • IDE (if applicable): Claude Code

Additional Context

  • The issue is reproducible with both update-task and expand commands.
  • It appears the CLI expects a strict JSON response but does not handle extra prose from the model.
  • A more tolerant JSON parser (extracting the first valid JSON object) or structured output enforcement would likely resolve this.
  • config-file:
{
  "models": {
    "main": {
      "provider": "claude-code",
      "modelId": "sonnet",
      "maxTokens": 32000,
      "temperature": 0.1
    },
    "research": {
      "provider": "claude-code",
      "modelId": "sonnet",
      "maxTokens": 64000,
      "temperature": 0.1
    },
    "fallback": {
      "provider": "claude-code",
      "modelId": "sonnet",
      "maxTokens": 64000,
      "temperature": 0.2
    }
  },
  "global": {
    "logLevel": "debug",
    "debug": true,
    "defaultNumTasks": 10,
    "defaultSubtasks": 7,
    "defaultPriority": "medium",
    "projectName": "Taskmaster",
    "ollamaBaseURL": "http://localhost:11434/api",
    "bedrockBaseURL": "https://bedrock.us-east-1.amazonaws.com",
    "responseLanguage": "English",
    "enableCodebaseAnalysis": true,
    "defaultTag": "master",
    "azureOpenaiBaseURL": "https://your-endpoint.openai.azure.com/",
    "userId": "1234567890",
    "enforceJsonOutput": true,
    "jsonRepairMode": true
  },
  "claudeCode": {
    "maxTurns": 5,
    "customSystemPrompt": "You are a helpful assistant focused on code quality",
    "appendSystemPrompt": "Always follow coding best practices",
    "permissionMode": "default",
    "allowedTools": ["Read", "LS"],
    "disallowedTools": ["Write", "Edit"],
    "mcpServers": {
      "mcp-server-name": {
        "command": "npx",
        "args": ["-y", "mcp-serve"],
        "env": {
        }
      }
    }
  },
  "commandSpecific": {
    "parse-prd": {
      "maxTurns": 10,
      "customSystemPrompt": "You are a task breakdown specialist"
    },
    "analyze-complexity": {
      "maxTurns": 3,
      "customSystemPrompt": "CRITICAL: You must output ONLY valid JSON. No explanations, no 'I will', no 'I'll analyze', no text before or after JSON. Your response must start with '[' and end with ']'. The output will be parsed with JSON.parse() and any non-JSON content will cause system failure.",
      "appendSystemPrompt": "JSON ONLY. Format: [{\"task\":\"string\",\"complexity\":\"low|medium|high\",\"bottlenecks\":[\"string\"]}]. Start immediately with '['."
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:ai-modelsAI model integration and configurationarea:cliCLI functionalityarea:task-managementCore task management featuresbugSomething isn't workinghigh-priorityUrgent issue requiring immediate attentionprovider:claude-codeClaude Code integrated models

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions