Fix Claude Code & Codex CLI Provider Failures
Hey everyone! We've stumbled upon a pretty annoying bug when using the task-master parse-prd command, specifically when setting up claude-code as the main model and codex-cli as the fallback. It seems like both of these providers are throwing API errors, and the command only manages to complete by defaulting to the research model, which is definitely not what we want, guys. Let's dive into what's happening and how we can get this sorted.
The Problem: Providers Failing Left and Right
So, the main issue here is that when you try to run task-master parse-prd with a specific model setup, things go south pretty quickly. You're supposed to be able to use claude-code/Opus for generating tasks, and if that hits a snag, codex-cli/Gpt 5 Codex is supposed to jump in and save the day. However, in this scenario, both of them are failing with API errors. The first one, Claude Code, fails with a general AI_APICallError, exiting with code 1. Then, the fallback, Codex CLI, also fails, but with a more specific validation error: "Error: unknown variant xhigh, expected one of minimal, low, medium, high in model_reasoning_effort." Because both of these intended models are bailing, task-master is being forced to use the research model, which happens to be perplexity/sonar-pro in this setup, and *that* one works. While it's good that we have a working fallback, it's not the *intended* fallback, and it defeats the purpose of setting up specific primary and secondary models for this task. We need claude-code or codex-cli to do their jobs properly!
This bug is a bit of a showstopper if you were planning on leveraging claude-code or codex-cli for your PRD parsing needs. The expectation is a smooth workflow where the primary model handles the request, and the secondary model is there as a robust backup. When both fail, it points to a deeper integration issue within task-master itself, or perhaps with the versions of the CLIs being invoked. The logs clearly show the sequence of failures, with Claude Code bailing first, followed by Codex CLI's validation error, and then the eventual, albeit unwanted, success with the research model. It's crucial for us to get to the bottom of why these specific providers are not performing as expected. We're talking about core functionality here, and having reliable model providers is key to an efficient development process. This isn't just a minor inconvenience; it's a bug that prevents users from utilizing their preferred or configured models for a critical task like parsing Product Requirements Documents. We need to ensure that the integrations are solid and that the parameters passed to these models are correctly validated and supported by the respective CLI tools. The error message from Codex CLI, specifically mentioning an unknown variant for `model_reasoning_effort`, is a significant clue that we'll explore further.
How to Reproduce the Bug
Reproducing this bug is pretty straightforward, guys. If you want to see this happen on your end, just follow these steps precisely:
- First off, run the command
task-master models --setup. This is the initial setup step to configure your model providers within Task Master. - When prompted, you'll need to select
claude-code/Opusas your main model. This is the model you want Task Master to try and use primarily for tasks. - Next, for the research model, go ahead and select
perplexity/Perplexity Sonar Pro. This one is often used for different types of queries, but in this setup, it ends up being the only thing that works. - Now, crucially, set
codex-cli/Gpt 5 Codexas your fallback model. This is the backup that's supposed to kick in if the main model fails. - With the setup complete, run the command
task-master parse-prd. This is the command that triggers the PRD parsing process. - When you're prompted to choose between parsing locally or using a model, select "Parse locally". This usually involves further model interaction.
- Finally, if you're asked to confirm overwriting existing tasks, just give it a confirmation. This step doesn't usually affect the model provider errors, but it's part of the full reproduction sequence.
After following these steps, you should observe the described behavior where both claude-code and codex-cli fail, forcing the use of the research model. It's important to have these specific models selected because the bug seems to be tied to the interaction between task-master and these particular AI providers, especially when one is designated as the primary and the other as the fallback for the parse-prd function. This sequence allows us to isolate the problem to the specific configuration and command that's causing the issue. We want to make sure that when we set up our preferred models, they actually work as intended, and this bug is preventing that. So, if you're experiencing this, you're not alone, and these steps should help you replicate it to understand the scope of the problem. It’s about ensuring that the tools we rely on are robust and that the configurations we set up actually function as expected, providing a seamless workflow rather than unexpected errors.
Expected Behavior: A Smooth Workflow
When everything is working correctly, the task-master parse-prd command should behave in a very predictable and helpful manner, guys. The primary goal is to leverage the power of your chosen AI models to parse your Product Requirements Documents (PRDs) efficiently. So, in the ideal scenario, when you run the command after setting up your models (as described in the reproduction steps, with claude-code/Opus as main and codex-cli/Gpt 5 Codex as fallback), the parse-prd command should successfully utilize the claude-code/Opus model. This main model is expected to process the PRD and generate the necessary tasks without any hiccups. It should handle the request smoothly, interpret the document, and output the structured task information as designed.
However, we all know that sometimes AI models can hit temporary issues – maybe a brief API outage, a rate limit, or some other transient problem. That's precisely why a fallback model is so important. In the expected behavior, if the claude-code/Opus model were to fail for any reason, the system should gracefully switch over to the configured fallback model, which in this case is codex-cli/Gpt 5 Codex. The expectation is that this fallback model would then successfully take over the task, process the PRD, and generate the required output. This ensures that the overall process isn't derailed by a single model's failure. The user should ideally not even notice that the fallback was triggered, aside from perhaps a slight delay. The key is that the task is completed successfully using one of the configured AI providers. The research model, perplexity/sonar-pro, should only be used if *both* the main and fallback models are explicitly unavailable or if it's designated as a tertiary option, not as the default outcome when the primary and secondary options fail. We're aiming for a robust pipeline where the PRD parsing can be completed reliably, regardless of minor issues with individual model providers.
Actual Behavior: Errors and Unintended Fallbacks
Alright, so here's the not-so-fun part, guys. What's actually happening when we run task-master parse-prd with the setup we discussed is a cascade of failures. Instead of smoothly parsing the PRD, we're hitting roadblocks. First, the Claude Code provider, intended as our main model, fails spectacularly. It exits with a code 1 and throws an AI_APICallError. This means it couldn't even get the job started properly, and we don't get any useful output from it. This is already a problem because our primary choice is out of the picture.
But wait, it gets worse! When Claude Code fails, Task Master is supposed to pivot to our fallback model, Codex CLI. However, Codex CLI isn't faring any better. It also fails, exiting with code 1, but this time with a very specific and telling validation error: "Error: unknown variant xhigh, expected one of minimal, low, medium, high in model_reasoning_effort." This error message is super important because it suggests that Task Master is trying to pass a parameter value (xhigh) to Codex CLI that the current version or integration of Codex CLI doesn't recognize. It's expecting a different set of values for how much effort the model should put into its reasoning, and xhigh isn't on the approved list according to Task Master's validation layer, even though the standalone Codex CLI might support it.
Because both the primary (Claude Code) and the fallback (Codex CLI) models are failing, the command is ultimately forced to seek out another option. In this specific configuration, it ends up falling back *again* to the research model, perplexity/sonar-pro. This research model *does* succeed in completing the task. While success is good, it's not the intended workflow at all. We configured Claude Code and Codex CLI for a reason, and having it default to a completely different type of model isn't the desired outcome. This situation highlights two distinct issues: the initial failure of Claude Code, which needs more investigation, and the parameter validation error with Codex CLI, which seems to be an integration mismatch. We need to fix both of these to restore the intended functionality.
Screenshots or Logs: The Evidence
To really drive home what's happening, let's look at the actual logs and error messages we're seeing. This is the concrete proof of the failures we've been discussing, guys. Pay close attention to these snippets:
First, we see the initial failure from the main provider:
[ERROR] Claude Code object generation failed: Claude Code process exited with code 1 {"error":{"name":"AI_APICallError","url":"claude-code-cli://command","requestBodyValues":{"prompt":"You are an AI assistant specialized in analyzing Product Requirements Documents..."},"isRetryable":false}}
[WARN] Attempt 1 failed for role main (generateObject / claude-code): Claude Code API error during object generation: Claude Code process exited with code 1
This clearly indicates that Claude Code is exiting with a non-zero status code and an AI_APICallError. The details about the prompt show it was trying to do its job, but something went wrong internally.
Then, after attempting to fall back, we hit the issue with the secondary provider:
[ERROR] Codex CLI object generation failed: Codex CLI exited with code 1 {"error":{"name":"AI_APICallError","url":"codex-cli://exec","requestBodyValues":{"prompt":"..."},"isRetryable":false,"data":{"exitCode":1,"stderr":"Error: unknown variant `xhigh`, expected one of `minimal`, `low`, `medium`, `high`\nin `model_reasoning_effort`\n\n"}}}
[WARN] Attempt 1 failed for role fallback (generateObject / codex-cli): Codex CLI API error during object generation: Codex CLI exited with code 1
This is the critical part: the Codex CLI failure message is explicit. It tells us that the value xhigh for model_reasoning_effort is not recognized. Task Master is trying to use it, but the Codex CLI integration within Task Master is throwing a validation error because it's expecting one of the other options (minimal, low, medium, high). This is a strong indicator of a mismatch in parameter handling between Task Master and the Codex CLI tool.
Finally, because both failed, we see the system resorting to the research model:
(Implicitly, the task eventually succeeds using perplexity/sonar-pro, although logs for this specific success are not shown here, the context implies it.)
These logs paint a clear picture: the primary model fails, the fallback model fails due to an invalid parameter value being passed, and the system then defaults to a different, unintended model to achieve completion. We need to address both the initial Claude Code error and the Codex CLI parameter issue.
Environment Details
To help diagnose this bug effectively, guys, here's the environment information where we're seeing these issues:
- Task Master version: v0.37.2
- Node.js version: (Please run
node --versionin your terminal and fill this in!) - Operating system: macOS
- IDE: VS Code
Having this information is super helpful because software behavior can sometimes vary across different versions and operating systems. For instance, the way Task Master interacts with CLIs might be slightly different on Windows versus macOS, or a specific Node.js version could introduce subtle changes. We're specifically running on macOS with Task Master version 0.37.2. If you're encountering the same bug, please double-check your Task Master version and Node.js version and report them if they differ. This helps us narrow down whether the issue is specific to this exact configuration or more widespread. The fact that it's happening on macOS with VS Code provides a solid baseline for debugging efforts. We need to ensure that the code execution environment is understood to rule out any environment-specific quirks.
Root Cause Analysis and Suggested Fixes
Let's break down what's likely causing these issues, guys, and propose some solutions. We've got two main suspects here, stemming from the error logs.
Codex CLI Parameter Mismatch
The most concrete error message comes from the Codex CLI provider. It explicitly states: "Error: unknown variant xhigh, expected one of minimal, low, medium, high in model_reasoning_effort."
Now, here's the interesting part: we've confirmed that the standalone Codex CLI version 0.71.0 *does* support xhigh as a valid reasoning effort level. You can even verify this by running the codex command directly and checking its options; it shows gpt-5.1-codex-max xhigh as a supported configuration. This leads us to believe that the problem isn't with the Codex CLI tool itself, but rather with how Task Master is integrating with or validating the parameters for Codex CLI.
It seems like Task Master might be using an outdated or overly restrictive schema for validating the model_reasoning_effort parameter. Alternatively, it might be invoking the Codex CLI command in a way that doesn't correctly pass through this specific parameter value. Essentially, Task Master's internal logic is rejecting xhigh, even though the Codex CLI tool it's calling is perfectly capable of handling it.
Suggested Fix for Codex CLI: The most direct fix here would be to update Task Master's integration with the Codex CLI provider. Specifically, we need to ensure that the validation rules within Task Master recognize xhigh as a legitimate value for model_reasoning_effort, aligning it with the capabilities of Codex CLI v0.71.0 and newer.
Claude Code Provider Failure
The failure of the Claude Code provider is less specific. It simply fails with exit code 1 and an AI_APICallError. This could be due to a number of reasons:
- Authentication issues: Task Master might not be correctly authenticated with the Claude Code API.
- Rate limits: The API might be throttling requests.
- Version incompatibility: There might be an incompatibility between the version of the Claude Code CLI Task Master is trying to use and the actual Claude Code service.
- Configuration errors: Incorrect API keys, endpoints, or other configurations specific to the Claude Code provider within Task Master.
- Internal errors within Claude Code: The issue might lie entirely within the Claude Code service itself.
Suggested Fix for Claude Code: Diagnosing this requires more information. We need:
- Enhanced Logging: Task Master should ideally provide more detailed error information when the Claude Code provider fails. This could include specific error codes from the Claude API or more context about the failure.
- Verify Authentication: Double-check that the API keys and any necessary authentication tokens for Claude Code are correctly configured and valid within Task Master's settings.
- Check API Status and Limits: Ensure there are no ongoing issues with the Claude Code API service and that requests aren't exceeding rate limits.
- Test Claude Code Standalone: Try running the Claude Code CLI directly from the command line (outside of Task Master) with a similar prompt to see if it works, which can help isolate whether the issue is with Task Master's integration or the provider itself.
By addressing the clear parameter validation issue with Codex CLI and gathering more information to debug the Claude Code provider's generic failure, we should be able to get the task-master parse-prd command working reliably with the intended model providers again. It's all about fine-tuning those integrations and ensuring the tools are speaking the same language, folks!