fix(ai): Correctly imports generateText in openai.js, adds specific cause and reason for OpenRouter failures in the openrouter.js catch, performs complexity analysis on all tm tasks, adds new tasks to further improve the maxTokens to take input and output maximum into account. Adjusts default fallback max tokens so 3.5 does not fail.
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
"fallback": {
|
||||
"provider": "anthropic",
|
||||
"modelId": "claude-3-7-sonnet-20250219",
|
||||
"maxTokens": 64000,
|
||||
"maxTokens": 8192,
|
||||
"temperature": 0.2
|
||||
}
|
||||
},
|
||||
|
||||
368
context/chats/max-min-tokens.txt.md
Normal file
368
context/chats/max-min-tokens.txt.md
Normal file
@@ -0,0 +1,368 @@
|
||||
We want to refine how Task Master handles AI model token limits to be more precise, by:
|
||||
|
||||
1. Distinguishing between `maxInputTokens` and `maxOutputTokens` in the configuration.
|
||||
2. Dynamically adjusting the `maxOutputTokens` for an API call based on the actual prompt length to stay within the model's total context window (or respecting separate input/output limits if the API and model support that).
|
||||
3. Ensuring that `ai-services-unified.js` uses these more granular limits.
|
||||
|
||||
This is a good improvement for both cost control and preventing errors.
|
||||
|
||||
Here's a plan:
|
||||
|
||||
**Phase 1: Configuration and Core Logic Updates**
|
||||
|
||||
1. **Update `.taskmasterconfig` Structure:**
|
||||
- I'll modify the `models` section in your `.taskmasterconfig`. For each role (`main`, `research`, `fallback`), `maxTokens` will be replaced with `maxInputTokens` and `maxOutputTokens`.
|
||||
- We'll need to decide on reasonable default values for these new fields. We can look at the current `maxTokens` and the model's known limits to make an initial guess.
|
||||
2. **Update `MODEL_MAP` in `ai-services-unified.js`:**
|
||||
- This array already stores cost data. We need to ensure it also stores the _absolute_ maximum input and output tokens for each model listed (e.g., `model_max_input_tokens`, `model_max_output_tokens`). If these fields are not present, they will need to be added. The values in `.taskmasterconfig` will then represent user-defined operational limits, which should ideally be validated against these absolute maximums.
|
||||
3. **Update `config-manager.js`:**
|
||||
- Getter functions like `getParametersForRole` will be updated to fetch `maxInputTokens` and `maxOutputTokens` instead of the singular `maxTokens`.
|
||||
- New getters might be needed if we want to access the model's absolute limits directly from `MODEL_MAP` via `config-manager.js`.
|
||||
4. **Update `ai-services-unified.js` (`_unifiedServiceRunner`):**
|
||||
- **Token Counting:** This is a crucial step. Before an API call, we need to estimate the token count of the combined `systemPrompt` and `userPrompt`.
|
||||
- The Vercel AI SDK or the individual provider SDKs might offer utilities for this. For example, some SDKs expose a `tokenizer` or a way to count tokens for a given string.
|
||||
- If a direct utility isn't available through the Vercel SDK for the specific provider, we might need to use a library like `tiktoken` for OpenAI/Anthropic models or investigate provider-specific tokenization. This could be complex as tokenization varies between models.
|
||||
- For now, let's assume we can get a reasonable estimate.
|
||||
- **Dynamic Output Token Calculation & Validation:**
|
||||
- Retrieve `configured_max_input_tokens` and `configured_max_output_tokens` from `config-manager.js` for the current role.
|
||||
- Retrieve `model_absolute_max_input_tokens` and `model_absolute_max_output_tokens` from `MODEL_MAP`.
|
||||
- Let `prompt_tokens = countTokens(systemPrompt + userPrompt)`.
|
||||
- **Input Validation:** If `prompt_tokens > configured_max_input_tokens` OR `prompt_tokens > model_absolute_max_input_tokens`, throw an error. (We might also consider auto-truncation strategies in the future, but an error is safer to start).
|
||||
- **Output Calculation:** The `max_tokens` parameter sent to the API (which typically refers to the _max number of tokens to generate_) should be `configured_max_output_tokens`. We also need to ensure this doesn't violate the model's absolute output limit.
|
||||
- Some models have a _total_ context window (input + output). If this is the case for a model, the `max_tokens` parameter for the API call might need to be `min(configured_max_output_tokens, model_absolute_total_tokens - prompt_tokens)`. However, many modern APIs handle separate input and output limits, simplifying this. We'll aim to pass `configured_max_output_tokens` as the API's `max_tokens` parameter, assuming the input validation has passed.
|
||||
- **API Call Parameter:** Update the `callParams` to use the correctly determined `max_tokens` for generation (which will be our `configured_max_output_tokens`).
|
||||
|
||||
**Phase 2: Error Handling and Refinements**
|
||||
|
||||
1. **Enhanced Error Handling:** Provide clear error messages if prompt tokens exceed input limits, or if API calls fail due to token issues despite our calculations.
|
||||
2. **Validation:** Add validation (perhaps in `config-manager.js` or when `task-master models --setup` is run) to ensure `configured_max_input_tokens` and `configured_max_output_tokens` in `.taskmasterconfig` do not exceed the `model_absolute_max_input_tokens` and `model_absolute_max_output_tokens` from `MODEL_MAP`.
|
||||
|
||||
Let's start by inspecting `scripts/modules/config-manager.js` to see how parameters and `MODEL_MAP` are currently handled. This will inform the changes needed for `.taskmasterconfig` and `ai-services-unified.js`.
|
||||
|
||||
I will now read `scripts/modules/config-manager.js`.
|
||||
|
||||
Okay, I've reviewed `scripts/modules/config-manager.js`. Here's what I've gathered and how it impacts the plan:
|
||||
|
||||
- **`MODEL_MAP` Source:** `MODEL_MAP` is loaded from `supported-models.json`. This is excellent, as it means we can update the model capabilities (including new token limits) in a structured JSON file.
|
||||
- **Configuration Loading:** `_loadAndValidateConfig` handles loading `.taskmasterconfig` and merging it with `DEFAULTS`.
|
||||
- **Getters:** There are specific getters for `maxTokens` for each role (e.g., `getMainMaxTokens`). We will need to update these.
|
||||
- **`getParametersForRole`:** This function already exists and is a good candidate for returning the new `maxInputTokens` and `maxOutputTokens`.
|
||||
|
||||
Here's the refined plan:
|
||||
|
||||
**Phase 1: Configuration and Data Structures**
|
||||
|
||||
1. **Update `supported-models.json`:**
|
||||
|
||||
- For each model entry in `supported-models.json`, we need to add `maxInputTokens` and `maxOutputTokens` fields. These should reflect the _absolute maximums_ for that specific model.
|
||||
- Example entry change:
|
||||
|
||||
```json
|
||||
// Before
|
||||
{
|
||||
"id": "claude-3-7-sonnet-20250219",
|
||||
"name": "Claude 3.7 Sonnet (Preview)",
|
||||
"context_window": 200000, // This might be total context
|
||||
"cost_per_1m_tokens": { "input": 3, "output": 15, "currency": "USD" }
|
||||
}
|
||||
|
||||
// After (assuming 200k is total, and we make a reasonable split or find official numbers)
|
||||
{
|
||||
"id": "claude-3-7-sonnet-20250219",
|
||||
"name": "Claude 3.7 Sonnet (Preview)",
|
||||
"maxInputTokens": 190000, // Example
|
||||
"maxOutputTokens": 8192, // Example, often smaller for generation
|
||||
"cost_per_1m_tokens": { "input": 3, "output": 15, "currency": "USD" }
|
||||
}
|
||||
```
|
||||
|
||||
- I will need to find the official input/output token limits for the models currently in your `MODEL_MAP`. If you have this information handy, it would speed things up. Otherwise, I can make educated guesses or search for them.
|
||||
|
||||
2. **Update `.taskmasterconfig` (Defaults and User File):**
|
||||
- In `scripts/modules/config-manager.js`, modify the `DEFAULTS` object. For each role (`main`, `research`, `fallback`), replace `maxTokens` with:
|
||||
- `maxInputTokens`: A sensible default (e.g., a large portion of the model's capability, but user-configurable).
|
||||
- `maxOutputTokens`: A sensible default for generation (e.g., 4096 or 8192).
|
||||
- You will then need to manually update your existing `.taskmasterconfig` file to reflect this new structure. I can provide the snippet for you to paste.
|
||||
3. **Update `config-manager.js`:**
|
||||
- Modify `getParametersForRole(role, explicitRoot = null)`:
|
||||
- It currently fetches `maxTokens` and `temperature`.
|
||||
- Update it to fetch `maxInputTokens`, `maxOutputTokens`, and `temperature` from the loaded config for the given role.
|
||||
- Remove the role-specific `getMaxTokens` functions (e.g., `getMainMaxTokens`, `getResearchMaxTokens`, `getFallbackMaxTokens`). The `getParametersForRole` will be the central way to get these.
|
||||
- (Optional, for later validation) Consider adding a new function `getModelCapabilities(providerName, modelId)` that reads from `MODEL_MAP` to return the absolute `maxInputTokens` and `maxOutputTokens` for a given model. This would be useful for validating the user's settings in `.taskmasterconfig`.
|
||||
|
||||
**Phase 2: Core Logic in `ai-services-unified.js`**
|
||||
|
||||
1. **Token Counting (`_unifiedServiceRunner`):**
|
||||
|
||||
- This is the most complex part. We need a reliable way to count tokens for the prompts.
|
||||
- **Strategy 1 (Ideal):** Leverage Vercel AI SDK. The SDK might provide a way to get a tokenizer for the active model or a utility function. We'll need to investigate its capabilities.
|
||||
- **Strategy 2 (Fallback):** Use a library like `tiktoken` for models compatible with OpenAI's tokenization (many are, including some Anthropic models). For other models, we might need provider-specific tokenizers or make estimations (less ideal).
|
||||
- **Initial Approach:** Let's try to find a Vercel AI SDK utility first. If not, we'll start with `tiktoken` as a common case and acknowledge that other models might need specific handling later.
|
||||
- The function `_unifiedServiceRunner` will call this token counting utility:
|
||||
|
||||
```javascript
|
||||
// Placeholder for token counting
|
||||
function countTokens(text, modelId /* or providerName */) {
|
||||
// ... implementation using SDK or library ...
|
||||
// This is a simplification; actual tokenization is model-specific.
|
||||
// For now, a rough estimate might be (text.length / 4) as a placeholder
|
||||
// if a proper tokenizer isn't immediately available.
|
||||
if (!text) return 0;
|
||||
return Math.ceil(text.length / 3.5); // Very rough general estimate
|
||||
}
|
||||
|
||||
const promptTokens = countTokens(systemPrompt) + countTokens(prompt);
|
||||
```
|
||||
|
||||
2. **Dynamic Output Token Calculation & Validation (`_unifiedServiceRunner`):**
|
||||
|
||||
- Fetch parameters using the updated `getParametersForRole` from `config-manager.js`:
|
||||
```javascript
|
||||
const roleParams = getParametersForRole(
|
||||
currentRole,
|
||||
effectiveProjectRoot
|
||||
);
|
||||
// roleParams will now contain { maxInputTokens, maxOutputTokens, temperature }
|
||||
```
|
||||
- Fetch model's absolute limits from `MODEL_MAP` (we'll need a helper in `config-manager.js` or do it directly in `ai-services-unified.js` for now):
|
||||
```javascript
|
||||
// Simplified; ideally use a robust getter from config-manager
|
||||
const modelInfo = MODEL_MAP[providerName?.toLowerCase()]?.find(
|
||||
(m) => m.id === modelId
|
||||
);
|
||||
const modelAbsoluteMaxInput = modelInfo?.maxInputTokens || Infinity;
|
||||
const modelAbsoluteMaxOutput =
|
||||
modelInfo?.maxOutputTokens || roleParams.maxOutputTokens; // Fallback to configured if not in map
|
||||
```
|
||||
- **Input Validation:**
|
||||
```javascript
|
||||
if (promptTokens > roleParams.maxInputTokens) {
|
||||
throw new Error(
|
||||
`Prompt (${promptTokens} tokens) exceeds configured max input tokens (${roleParams.maxInputTokens}) for role '${currentRole}'.`
|
||||
);
|
||||
}
|
||||
if (promptTokens > modelAbsoluteMaxInput) {
|
||||
throw new Error(
|
||||
`Prompt (${promptTokens} tokens) exceeds model's absolute max input tokens (${modelAbsoluteMaxInput}) for ${modelId}.`
|
||||
);
|
||||
}
|
||||
```
|
||||
- **API Call Parameter (`max_tokens` for generation):**
|
||||
The `max_tokens` parameter passed to the provider's API call should be `roleParams.maxOutputTokens`. We must also ensure this doesn't exceed the model's absolute output capability.
|
||||
|
||||
```javascript
|
||||
const apiMaxOutputTokens = Math.min(
|
||||
roleParams.maxOutputTokens,
|
||||
modelAbsoluteMaxOutput
|
||||
);
|
||||
|
||||
const callParams = {
|
||||
apiKey,
|
||||
modelId,
|
||||
// Use apiMaxOutputTokens for the actual API call
|
||||
maxTokens: apiMaxOutputTokens, // This usually means max tokens to GENERATE
|
||||
temperature: roleParams.temperature,
|
||||
messages,
|
||||
baseUrl,
|
||||
...(serviceType === 'generateObject' && { schema, objectName }),
|
||||
...restApiParams
|
||||
};
|
||||
```
|
||||
|
||||
3. **Update `logAiUsage`:**
|
||||
- The cost calculation in `logAiUsage` seems correct as it already uses `inputCost` and `outputCost` per 1M tokens. This part should remain compatible.
|
||||
|
||||
**Next Steps:**
|
||||
|
||||
1. **Modify `supported-models.json`:** I need the content of this file to propose the new `maxInputTokens` and `maxOutputTokens` fields. Please provide it.
|
||||
2. **Decide on Tokenizer Strategy:** What are your thoughts on the token counting? Are you aware of any utilities within Vercel AI SDK for this, or should we plan to integrate `tiktoken` initially?
|
||||
|
||||
Once I have the content of `supported-models.json`, I can draft the changes for it and then proceed to `config-manager.js` and `.taskmasterconfig`.
|
||||
|
||||
```json
|
||||
// Before
|
||||
{
|
||||
"id": "claude-3-7-sonnet-20250219",
|
||||
"name": "Claude 3.7 Sonnet (Preview)",
|
||||
"context_window": 200000, // This might be total context
|
||||
"cost_per_1m_tokens": { "input": 3, "output": 15, "currency": "USD" }
|
||||
}
|
||||
|
||||
// After (assuming 200k is total, and we make a reasonable split or find official numbers)
|
||||
{
|
||||
"id": "claude-3-7-sonnet-20250219",
|
||||
"name": "Claude 3.7 Sonnet (Preview)",
|
||||
"maxInputTokens": 190000, // Example
|
||||
"maxOutputTokens": 8192, // Example, often smaller for generation
|
||||
"cost_per_1m_tokens": { "input": 3, "output": 15, "currency": "USD" }
|
||||
}
|
||||
```
|
||||
|
||||
```javascript
|
||||
// Placeholder for token counting
|
||||
function countTokens(text, modelId /* or providerName */) {
|
||||
// ... implementation using SDK or library ...
|
||||
// This is a simplification; actual tokenization is model-specific.
|
||||
// For now, a rough estimate might be (text.length / 4) as a placeholder
|
||||
// if a proper tokenizer isn't immediately available.
|
||||
if (!text) return 0;
|
||||
return Math.ceil(text.length / 3.5); // Very rough general estimate
|
||||
}
|
||||
|
||||
const promptTokens = countTokens(systemPrompt) + countTokens(prompt);
|
||||
```
|
||||
|
||||
```javascript
|
||||
const roleParams = getParametersForRole(currentRole, effectiveProjectRoot);
|
||||
// roleParams will now contain { maxInputTokens, maxOutputTokens, temperature }
|
||||
```
|
||||
|
||||
```javascript
|
||||
// Simplified; ideally use a robust getter from config-manager
|
||||
const modelInfo = MODEL_MAP[providerName?.toLowerCase()]?.find(
|
||||
(m) => m.id === modelId
|
||||
);
|
||||
const modelAbsoluteMaxInput = modelInfo?.maxInputTokens || Infinity;
|
||||
const modelAbsoluteMaxOutput =
|
||||
modelInfo?.maxOutputTokens || roleParams.maxOutputTokens; // Fallback to configured if not in map
|
||||
```
|
||||
|
||||
```javascript
|
||||
if (promptTokens > roleParams.maxInputTokens) {
|
||||
throw new Error(
|
||||
`Prompt (${promptTokens} tokens) exceeds configured max input tokens (${roleParams.maxInputTokens}) for role '${currentRole}'.`
|
||||
);
|
||||
}
|
||||
if (promptTokens > modelAbsoluteMaxInput) {
|
||||
throw new Error(
|
||||
`Prompt (${promptTokens} tokens) exceeds model's absolute max input tokens (${modelAbsoluteMaxInput}) for ${modelId}.`
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
```javascript
|
||||
const apiMaxOutputTokens = Math.min(
|
||||
roleParams.maxOutputTokens,
|
||||
modelAbsoluteMaxOutput
|
||||
);
|
||||
|
||||
const callParams = {
|
||||
apiKey,
|
||||
modelId,
|
||||
// Use apiMaxOutputTokens for the actual API call
|
||||
maxTokens: apiMaxOutputTokens, // This usually means max tokens to GENERATE
|
||||
temperature: roleParams.temperature,
|
||||
messages,
|
||||
baseUrl,
|
||||
...(serviceType === 'generateObject' && { schema, objectName }),
|
||||
...restApiParams
|
||||
};
|
||||
```
|
||||
|
||||
Okay, I have the contents of `supported-models.json`.
|
||||
|
||||
It seems many models have a `max_tokens` field, which I assume is the _total context window_. Some don't have it, and for others (like OpenAI `gpt-4o`), the listed `max_tokens` (16384) is known to be its _output_ token limit when using the Chat Completions API, while the context window is much larger (128k). This highlights the complexity: `max_tokens` in `supported-models.json` is used inconsistently.
|
||||
|
||||
**Revised Plan for `supported-models.json` and Token Definitions:**
|
||||
|
||||
To bring clarity, we'll introduce two new fields and ensure their meaning is consistent:
|
||||
|
||||
- `contextWindowTokens`: The total number of tokens the model can process (input + output). This would replace the current ambiguous `max_tokens`.
|
||||
- `maxOutputTokens`: The maximum number of tokens the model can _generate_ in a single response. This is often smaller than the total context window, especially for larger models.
|
||||
|
||||
If a model _only_ specifies a total context window, we'll have to make a reasonable assumption for `maxOutputTokens` (e.g., 4096 or 8192, or a fraction of the total context window). If it only specifies an output token limit (like some OpenAI models in certain API modes), we'll need to find its total context window.
|
||||
|
||||
**Updated `supported-models.json` Structure (Example):**
|
||||
|
||||
```json
|
||||
// For a model like Anthropic Claude 3.7 Sonnet (Preview)
|
||||
{
|
||||
"id": "claude-3-7-sonnet-20250219",
|
||||
"swe_score": 0.623,
|
||||
"cost_per_1m_tokens": { "input": 3.0, "output": 15.0 },
|
||||
"allowed_roles": ["main", "fallback"],
|
||||
"contextWindowTokens": 200000, // From Anthropic's documentation
|
||||
"maxOutputTokens": 8192 // Anthropic default, user can override in .taskmasterconfig
|
||||
}
|
||||
|
||||
// For a model like OpenAI GPT-4o
|
||||
{
|
||||
"id": "gpt-4o",
|
||||
"swe_score": 0.332,
|
||||
"cost_per_1m_tokens": { "input": 2.5, "output": 10.0 },
|
||||
"allowed_roles": ["main", "fallback"],
|
||||
"contextWindowTokens": 128000, // Official context window
|
||||
"maxOutputTokens": 16384 // Max output for chat completions is 16k for gpt-4o (used to be 4k/8k for older gpt-4)
|
||||
// but the model card mentions 128k total. The API call parameter for `max_tokens` sets this output cap.
|
||||
}
|
||||
```
|
||||
|
||||
I will proceed to generate the updated `supported-models.json` content. This will be a significant change. I will make my best effort to find the correct `contextWindowTokens` and `maxOutputTokens` for each model. If official numbers are ambiguous or not readily available, I'll use sensible defaults and add a comment.
|
||||
|
||||
**Regarding Tokenizer Strategy:**
|
||||
|
||||
- **Vercel AI SDK:** The `ai` package (Vercel AI SDK) itself is a lightweight wrapper. Tokenization is usually handled by the underlying provider-specific SDKs (e.g., `@anthropic-ai/sdk`, `openai`). The Vercel SDK doesn't provide a universal tokenizer.
|
||||
- **Provider SDKs:**
|
||||
- `@anthropic-ai/sdk`: Does not expose a public tokenizer directly. Anthropic recommends counting based on their guidelines (roughly 3.5 chars/token for English).
|
||||
- `openai` (for Node.js): The `gpt-3-encoder` or `tiktoken` libraries are commonly used. `tiktoken` is more current.
|
||||
- **`tiktoken`:** This is a good general-purpose library for OpenAI models and those that use compatible tokenization (many models fine-tuned from Llama, etc., might be close). It supports various encodings.
|
||||
- **Recommendation:**
|
||||
1. Start by integrating `tiktoken`. We can select the encoding based on the provider or even specific model if needed (e.g., `cl100k_base` for gpt-4, gpt-3.5-turbo, DALL-E models).
|
||||
2. For providers where `tiktoken` is not accurate (e.g., Google's Gemini, Perplexity if they have proprietary tokenizers), we might have to rely on character-based estimations (e.g., `length / N`) as a rougher guide or investigate if their specific SDKs offer token counting.
|
||||
3. The Vercel AI SDK's `experimental_streamObject` and other functions _might_ internally handle some aspects of token counting for request preparation, but we need explicit counting for our logic _before_ the call.
|
||||
|
||||
For now, let's assume we'll add a `countTokens` utility that uses `tiktoken` for OpenAI and Anthropic (as Anthropic's guidance is character-based but `cl100k_base` is often a decent proxy for their tokenization for rough estimates, though not perfect), and a character-based fallback for others.
|
||||
|
||||
I will now generate the proposed changes for `scripts/modules/supported-models.json`. This will be a large diff.
|
||||
|
||||
After this, we'll move to:
|
||||
|
||||
1. Updating `.taskmasterconfig` defaults in `config-manager.js` and providing you the snippet for your user file.
|
||||
2. Updating `config-manager.js` getters.
|
||||
3. Implementing the logic in `ai-services-unified.js`.
|
||||
|
||||
```json
|
||||
// For a model like Anthropic Claude 3.7 Sonnet (Preview)
|
||||
{
|
||||
"id": "claude-3-7-sonnet-20250219",
|
||||
"swe_score": 0.623,
|
||||
"cost_per_1m_tokens": { "input": 3.0, "output": 15.0 },
|
||||
"allowed_roles": ["main", "fallback"],
|
||||
"contextWindowTokens": 200000, // From Anthropic's documentation
|
||||
"maxOutputTokens": 8192 // Anthropic default, user can override in .taskmasterconfig
|
||||
}
|
||||
|
||||
// For a model like OpenAI GPT-4o
|
||||
{
|
||||
"id": "gpt-4o",
|
||||
"swe_score": 0.332,
|
||||
"cost_per_1m_tokens": { "input": 2.5, "output": 10.0 },
|
||||
"allowed_roles": ["main", "fallback"],
|
||||
"contextWindowTokens": 128000, // Official context window
|
||||
"maxOutputTokens": 16384 // Max output for chat completions is 16k for gpt-4o (used to be 4k/8k for older gpt-4)
|
||||
// but the model card mentions 128k total. The API call parameter for `max_tokens` sets this output cap.
|
||||
}
|
||||
```
|
||||
|
||||
```json
|
||||
// For a model like Anthropic Claude 3.7 Sonnet (Preview)
|
||||
{
|
||||
"id": "claude-3-7-sonnet-20250219",
|
||||
"swe_score": 0.623,
|
||||
"cost_per_1m_tokens": { "input": 3.0, "output": 15.0 },
|
||||
"allowed_roles": ["main", "fallback"],
|
||||
"contextWindowTokens": 200000, // From Anthropic's documentation
|
||||
"maxOutputTokens": 8192 // Anthropic default, user can override in .taskmasterconfig
|
||||
}
|
||||
|
||||
// For a model like OpenAI GPT-4o
|
||||
{
|
||||
"id": "gpt-4o",
|
||||
"swe_score": 0.332,
|
||||
"cost_per_1m_tokens": { "input": 2.5, "output": 10.0 },
|
||||
"allowed_roles": ["main", "fallback"],
|
||||
"contextWindowTokens": 128000, // Official context window
|
||||
"maxOutputTokens": 16384 // Max output for chat completions is 16k for gpt-4o (used to be 4k/8k for older gpt-4)
|
||||
// but the model card mentions 128k total. The API call parameter for `max_tokens` sets this output cap.
|
||||
}
|
||||
```
|
||||
@@ -1,283 +1,331 @@
|
||||
{
|
||||
"meta": {
|
||||
"generatedAt": "2025-05-08T23:29:42.699Z",
|
||||
"tasksAnalyzed": 34,
|
||||
"thresholdScore": 5,
|
||||
"projectName": "Taskmaster",
|
||||
"usedResearch": false
|
||||
},
|
||||
"complexityAnalysis": [
|
||||
{
|
||||
"taskId": 24,
|
||||
"taskTitle": "Implement AI-Powered Test Generation Command",
|
||||
"complexityScore": 7,
|
||||
"recommendedSubtasks": 5,
|
||||
"expansionPrompt": "Break down the implementation of the AI-powered test generation command into detailed subtasks, including API integration with Claude, test file generation logic, command structure, and error handling. For each subtask, provide specific implementation details and testing approaches.",
|
||||
"reasoning": "This task involves complex AI integration with Claude API, test generation logic, and file system operations. It requires understanding both the testing framework (Jest) and AI prompt engineering. The existing 3 subtasks are a good start but could benefit from additional subtasks for error handling, documentation, and integration with existing commands."
|
||||
},
|
||||
{
|
||||
"taskId": 26,
|
||||
"taskTitle": "Implement Context Foundation for AI Operations",
|
||||
"complexityScore": 6,
|
||||
"recommendedSubtasks": 4,
|
||||
"expansionPrompt": "Break down the implementation of the context foundation for AI operations into detailed subtasks, focusing on the file-based context integration, cursor rules integration, context extraction utilities, and command handler updates. For each subtask, provide specific implementation steps and testing approaches.",
|
||||
"reasoning": "This task involves adding context capabilities to AI operations, which requires modifications to multiple command handlers and creating utility functions. The existing 4 subtasks cover the main components well, but each could benefit from more detailed implementation steps. The complexity is moderate as it builds on existing AI integration but requires careful handling of different context sources."
|
||||
},
|
||||
{
|
||||
"taskId": 27,
|
||||
"taskTitle": "Implement Context Enhancements for AI Operations",
|
||||
"complexityScore": 7,
|
||||
"recommendedSubtasks": 5,
|
||||
"expansionPrompt": "Break down the implementation of context enhancements for AI operations into detailed subtasks, focusing on code context extraction, task history context, PRD context integration, and context formatting. For each subtask, provide specific implementation steps, technical challenges, and testing approaches.",
|
||||
"reasoning": "This task builds upon Task #26 but adds more sophisticated context handling including code parsing, task history analysis, and PRD integration. The existing 4 subtasks cover the main areas but lack detail on implementation specifics. The complexity is high due to the need for intelligent parsing of different file types, context prioritization, and token optimization."
|
||||
},
|
||||
{
|
||||
"taskId": 28,
|
||||
"taskTitle": "Implement Advanced ContextManager System",
|
||||
"complexityScore": 8,
|
||||
"recommendedSubtasks": 6,
|
||||
"expansionPrompt": "Break down the implementation of the Advanced ContextManager System into detailed subtasks, focusing on the core class structure, context optimization algorithms, command interface integration, AI service integration, and performance monitoring. For each subtask, provide specific implementation details, technical challenges, and testing approaches.",
|
||||
"reasoning": "This task represents the most complex phase of the context implementation, requiring a sophisticated class architecture, intelligent optimization algorithms, and integration with multiple systems. The existing 5 subtasks cover the main components but would benefit from more detailed implementation steps. The complexity is high due to the need for context prioritization, token budgeting, and caching mechanisms."
|
||||
},
|
||||
{
|
||||
"taskId": 40,
|
||||
"taskTitle": "Implement 'plan' Command for Task Implementation Planning",
|
||||
"complexityScore": 5,
|
||||
"recommendedSubtasks": 4,
|
||||
"expansionPrompt": "Break down the implementation of the 'plan' command into detailed subtasks, focusing on task content retrieval, AI integration for plan generation, XML formatting, and command interface development. For each subtask, provide specific implementation steps and testing approaches.",
|
||||
"reasoning": "This task involves creating a new command that leverages AI to generate implementation plans for tasks. The existing 4 subtasks cover the main components well. The complexity is moderate as it builds on existing AI integration patterns but requires specific formatting and task manipulation logic."
|
||||
},
|
||||
{
|
||||
"taskId": 41,
|
||||
"taskTitle": "Implement Visual Task Dependency Graph in Terminal",
|
||||
"complexityScore": 8,
|
||||
"recommendedSubtasks": 8,
|
||||
"expansionPrompt": "Break down the implementation of the visual task dependency graph feature into detailed subtasks, focusing on graph layout algorithms, ASCII/Unicode rendering, color coding, circular dependency detection, filtering capabilities, and accessibility features. For each subtask, provide specific implementation details and testing approaches.",
|
||||
"reasoning": "This task involves complex graph visualization algorithms, terminal rendering, and layout optimization. The existing 10 subtasks are comprehensive but could be consolidated into 8 more focused areas. The complexity is high due to the need for sophisticated graph layout algorithms, handling of complex dependency chains, and terminal rendering constraints."
|
||||
},
|
||||
{
|
||||
"taskId": 42,
|
||||
"taskTitle": "Implement MCP-to-MCP Communication Protocol",
|
||||
"complexityScore": 9,
|
||||
"recommendedSubtasks": 10,
|
||||
"expansionPrompt": "Break down the implementation of the MCP-to-MCP communication protocol into detailed subtasks, focusing on protocol design, adapter pattern implementation, client module development, reference implementations, mode switching, security considerations, and documentation. For each subtask, provide specific implementation details, technical challenges, and testing approaches.",
|
||||
"reasoning": "This task involves designing and implementing a complex communication protocol between different MCP tools and servers. The existing 8 subtasks provide a good foundation but lack detail on security, error handling, and specific implementation challenges. The complexity is very high due to the need for a standardized protocol, authentication mechanisms, and support for different operational modes."
|
||||
},
|
||||
{
|
||||
"taskId": 44,
|
||||
"taskTitle": "Implement Task Automation with Webhooks and Event Triggers",
|
||||
"complexityScore": 8,
|
||||
"recommendedSubtasks": 8,
|
||||
"expansionPrompt": "Break down the implementation of task automation with webhooks and event triggers into detailed subtasks, focusing on webhook registration, event system design, trigger definition interface, authentication mechanisms, rate limiting, payload templating, and integration with existing task management. For each subtask, provide specific implementation details and testing approaches.",
|
||||
"reasoning": "This task involves creating a comprehensive webhook and event trigger system, which requires careful design of event handling, security mechanisms, and integration with external services. The existing 7 subtasks cover most aspects but could benefit from additional focus on security and testing. The complexity is high due to the need for robust authentication, rate limiting, and handling of external service interactions."
|
||||
},
|
||||
{
|
||||
"taskId": 45,
|
||||
"taskTitle": "Implement GitHub Issue Import Feature",
|
||||
"complexityScore": 5,
|
||||
"recommendedSubtasks": 5,
|
||||
"expansionPrompt": "Break down the implementation of the GitHub issue import feature into detailed subtasks, focusing on URL parsing, GitHub API integration, data mapping, error handling, and command interface development. For each subtask, provide specific implementation details and testing approaches.",
|
||||
"reasoning": "This task involves integrating with the GitHub API to import issues as tasks. The existing 5 subtasks cover the main components well. The complexity is moderate as it requires API integration, authentication handling, and data mapping between GitHub issues and internal task structure."
|
||||
},
|
||||
{
|
||||
"taskId": 46,
|
||||
"taskTitle": "Implement ICE Analysis Command for Task Prioritization",
|
||||
"complexityScore": 6,
|
||||
"recommendedSubtasks": 5,
|
||||
"expansionPrompt": "Break down the implementation of the ICE analysis command into detailed subtasks, focusing on the scoring algorithm, AI integration for evaluation, report generation, CLI rendering, and integration with existing complexity reports. For each subtask, provide specific implementation details and testing approaches.",
|
||||
"reasoning": "This task involves creating a new analysis command for task prioritization using the ICE methodology. The existing 5 subtasks cover the main components well. The complexity is moderate as it builds on existing analysis patterns but requires specific scoring algorithms and AI integration for evaluation."
|
||||
},
|
||||
{
|
||||
"taskId": 47,
|
||||
"taskTitle": "Enhance Task Suggestion Actions Card Workflow",
|
||||
"complexityScore": 6,
|
||||
"recommendedSubtasks": 6,
|
||||
"expansionPrompt": "Break down the enhancement of the task suggestion actions card workflow into detailed subtasks, focusing on the task expansion phase, context addition phase, task management phase, and UI/UX improvements. For each subtask, provide specific implementation details and testing approaches.",
|
||||
"reasoning": "This task involves redesigning the suggestion actions card to implement a structured workflow. The existing 6 subtasks cover the main components well. The complexity is moderate as it requires UI/UX design considerations, state management, and integration with existing task management functionality."
|
||||
},
|
||||
{
|
||||
"taskId": 48,
|
||||
"taskTitle": "Refactor Prompts into Centralized Structure",
|
||||
"complexityScore": 4,
|
||||
"recommendedSubtasks": 3,
|
||||
"expansionPrompt": "Break down the refactoring of prompts into a centralized structure into detailed subtasks, focusing on directory structure creation, prompt extraction, and function updates. For each subtask, provide specific implementation details and testing approaches.",
|
||||
"reasoning": "This task involves refactoring existing prompt definitions into a centralized structure. The existing 3 subtasks cover the main components well. The complexity is relatively low as it's primarily a code organization task, though it requires careful handling to maintain functionality across the application."
|
||||
},
|
||||
{
|
||||
"taskId": 49,
|
||||
"taskTitle": "Implement Code Quality Analysis Command",
|
||||
"complexityScore": 7,
|
||||
"recommendedSubtasks": 6,
|
||||
"expansionPrompt": "Break down the implementation of the code quality analysis command into detailed subtasks, focusing on pattern recognition algorithms, best practice verification, AI integration for recommendations, task generation, and reporting interfaces. For each subtask, provide specific implementation details and testing approaches.",
|
||||
"reasoning": "This task involves creating a sophisticated code analysis system with AI integration for recommendations. The existing 6 subtasks cover the main components well. The complexity is high due to the need for pattern recognition algorithms, code parsing, and integration with AI services for quality assessment."
|
||||
},
|
||||
{
|
||||
"taskId": 50,
|
||||
"taskTitle": "Implement Test Coverage Tracking System by Task",
|
||||
"complexityScore": 8,
|
||||
"recommendedSubtasks": 5,
|
||||
"expansionPrompt": "Break down the implementation of the test coverage tracking system into detailed subtasks, focusing on data structure design, coverage report parsing, tracking and update mechanisms, CLI commands, and AI test generation. For each subtask, provide specific implementation details, technical challenges, and testing approaches.",
|
||||
"reasoning": "This task involves creating a comprehensive test coverage tracking system that maps tests to specific tasks. The existing 5 subtasks are well-defined but could benefit from more detailed implementation steps. The complexity is high due to the need for coverage report parsing, bidirectional mapping between tests and tasks, and AI-powered test generation."
|
||||
},
|
||||
{
|
||||
"taskId": 51,
|
||||
"taskTitle": "Implement Perplexity Research Command",
|
||||
"complexityScore": 5,
|
||||
"recommendedSubtasks": 5,
|
||||
"expansionPrompt": "Break down the implementation of the Perplexity research command into detailed subtasks, focusing on API client service, context extraction, CLI interface, results processing, and caching mechanisms. For each subtask, provide specific implementation details and testing approaches.",
|
||||
"reasoning": "This task involves creating a new command for research using Perplexity AI. The existing 5 subtasks cover the main components well. The complexity is moderate as it requires API integration, context handling, and results formatting, but follows established patterns for command implementation."
|
||||
},
|
||||
{
|
||||
"taskId": 52,
|
||||
"taskTitle": "Implement Task Suggestion Command for CLI",
|
||||
"complexityScore": 6,
|
||||
"recommendedSubtasks": 5,
|
||||
"expansionPrompt": "Break down the implementation of the task suggestion command for CLI into detailed subtasks, focusing on data collection, AI integration, interactive interface, suggestion selection, and configuration options. For each subtask, provide specific implementation details and testing approaches.",
|
||||
"reasoning": "This task involves creating a new CLI command for generating task suggestions. The existing 5 subtasks cover the main components well. The complexity is moderate as it requires AI integration for generating contextually relevant suggestions and an interactive CLI interface for user interaction."
|
||||
},
|
||||
{
|
||||
"taskId": 53,
|
||||
"taskTitle": "Implement Subtask Suggestion Feature for Parent Tasks",
|
||||
"complexityScore": 6,
|
||||
"recommendedSubtasks": 6,
|
||||
"expansionPrompt": "Break down the implementation of the subtask suggestion feature into detailed subtasks, focusing on parent task validation, context gathering, AI integration, interactive CLI interface, subtask linking, and comprehensive testing. For each subtask, provide specific implementation details and testing approaches.",
|
||||
"reasoning": "This task involves creating a feature to suggest contextually relevant subtasks for existing parent tasks. The existing 6 subtasks cover the main components well. The complexity is moderate as it requires AI integration for generating relevant subtask suggestions and careful integration with the existing task management system."
|
||||
},
|
||||
{
|
||||
"taskId": 55,
|
||||
"taskTitle": "Implement Positional Arguments Support for CLI Commands",
|
||||
"complexityScore": 5,
|
||||
"recommendedSubtasks": 5,
|
||||
"expansionPrompt": "Break down the implementation of positional arguments support for CLI commands into detailed subtasks, focusing on argument parsing structure analysis, specification format design, core parsing logic, edge case handling, and documentation updates. For each subtask, provide specific implementation details and testing approaches.",
|
||||
"reasoning": "This task involves modifying the command parsing logic to support positional arguments alongside the existing flag-based syntax. The existing 5 subtasks cover the main components well. The complexity is moderate as it requires careful handling of argument parsing and maintaining backward compatibility."
|
||||
},
|
||||
{
|
||||
"taskId": 57,
|
||||
"taskTitle": "Enhance Task-Master CLI User Experience and Interface",
|
||||
"complexityScore": 7,
|
||||
"recommendedSubtasks": 6,
|
||||
"expansionPrompt": "Break down the enhancement of the Task-Master CLI user experience into detailed subtasks, focusing on log management, visual enhancements, interactive elements, output formatting, help documentation, and accessibility features. For each subtask, provide specific implementation details and testing approaches.",
|
||||
"reasoning": "This task involves improving the CLI's user experience through various enhancements. The existing 6 subtasks cover the main components well. The complexity is moderate to high as it requires implementing various UI improvements, log management, and interactive elements while maintaining functionality in different environments."
|
||||
},
|
||||
{
|
||||
"taskId": 60,
|
||||
"taskTitle": "Implement Mentor System with Round-Table Discussion Feature",
|
||||
"complexityScore": 8,
|
||||
"recommendedSubtasks": 7,
|
||||
"expansionPrompt": "Break down the implementation of the mentor system with round-table discussion feature into detailed subtasks, focusing on mentor management, round-table discussion mechanics, task integration, LLM integration for mentor simulation, output formatting, and comprehensive testing. For each subtask, provide specific implementation details and testing approaches.",
|
||||
"reasoning": "This task involves creating a sophisticated mentor system with simulated round-table discussions. The existing 7 subtasks cover the main components well. The complexity is high due to the need for realistic mentor simulation using LLMs, managing multiple simulated personalities, and integrating with the task system."
|
||||
},
|
||||
{
|
||||
"taskId": 62,
|
||||
"taskTitle": "Add --simple Flag to Update Commands for Direct Text Input",
|
||||
"complexityScore": 4,
|
||||
"recommendedSubtasks": 8,
|
||||
"expansionPrompt": "Break down the implementation of the --simple flag for update commands into detailed subtasks, focusing on command parser updates, conditional logic for AI processing, timestamp formatting, visual indicators, storage integration, help documentation, testing, and final validation. For each subtask, provide specific implementation details and testing approaches.",
|
||||
"reasoning": "This task involves adding a simple flag option to update commands for direct text input without AI processing. The existing 8 subtasks are very detailed and cover all aspects of the implementation. The complexity is relatively low as it's primarily a feature addition to existing commands, though it requires careful integration with the existing update logic."
|
||||
},
|
||||
{
|
||||
"taskId": 63,
|
||||
"taskTitle": "Add pnpm Support for the Taskmaster Package",
|
||||
"complexityScore": 5,
|
||||
"recommendedSubtasks": 8,
|
||||
"expansionPrompt": "Break down the implementation of pnpm support for the Taskmaster package into detailed subtasks, focusing on documentation updates, package script compatibility, lockfile generation, installation testing, CI/CD integration, dependency resolution, and init script verification. For each subtask, provide specific implementation details and testing approaches.",
|
||||
"reasoning": "This task involves ensuring the Taskmaster package works correctly with pnpm as a package manager. The existing 8 subtasks cover the main components well. The complexity is moderate as it requires testing across different environments and ensuring compatibility with the existing npm installation process."
|
||||
},
|
||||
{
|
||||
"taskId": 64,
|
||||
"taskTitle": "Add Yarn Support for Taskmaster Installation",
|
||||
"complexityScore": 5,
|
||||
"recommendedSubtasks": 9,
|
||||
"expansionPrompt": "Break down the implementation of Yarn support for Taskmaster installation into detailed subtasks, focusing on package.json updates, Yarn-specific configuration, script and CLI testing, documentation updates, package manager detection, installation UI consistency, init script verification, binary linking, and website account setup testing. For each subtask, provide specific implementation details and testing approaches.",
|
||||
"reasoning": "This task involves adding support for Yarn as a package manager for Taskmaster. The existing 9 subtasks cover the main components well. The complexity is moderate as it requires testing across different environments and ensuring compatibility with the existing npm and pnpm installation processes."
|
||||
},
|
||||
{
|
||||
"taskId": 65,
|
||||
"taskTitle": "Add Bun Support for Taskmaster Installation",
|
||||
"complexityScore": 6,
|
||||
"recommendedSubtasks": 6,
|
||||
"expansionPrompt": "Break down the implementation of Bun support for Taskmaster installation into detailed subtasks, focusing on compatibility research, installation script updates, Bun-specific installation path, cross-platform testing, functionality verification, and documentation updates. For each subtask, provide specific implementation details and testing approaches.",
|
||||
"reasoning": "This task involves adding support for Bun as a package manager for Taskmaster. The existing 6 subtasks cover the main components well. The complexity is moderate to high as Bun is a newer package manager with potential compatibility issues and requires testing across different environments."
|
||||
},
|
||||
{
|
||||
"taskId": 67,
|
||||
"taskTitle": "Add CLI JSON output and Cursor keybindings integration",
|
||||
"complexityScore": 5,
|
||||
"recommendedSubtasks": 5,
|
||||
"expansionPrompt": "Break down the implementation of CLI JSON output and Cursor keybindings integration into detailed subtasks, focusing on core JSON output logic, schema consistency, keybinding command structure, file handling, and keybinding configuration. For each subtask, provide specific implementation details and testing approaches.",
|
||||
"reasoning": "This task involves adding JSON output capability to CLI commands and creating a new command for Cursor keybindings integration. The existing 5 subtasks cover the main components well. The complexity is moderate as it requires modifying multiple command handlers and implementing OS-specific file operations."
|
||||
},
|
||||
{
|
||||
"taskId": 68,
|
||||
"taskTitle": "Ability to create tasks without parsing PRD",
|
||||
"complexityScore": 3,
|
||||
"recommendedSubtasks": 4,
|
||||
"expansionPrompt": "Break down the implementation of task creation without PRD parsing into detailed subtasks, focusing on task creation form design, data validation, storage functionality, and integration with existing task management. For each subtask, provide specific implementation details and testing approaches.",
|
||||
"reasoning": "This task involves enabling task creation without requiring a PRD document. The existing 2 subtasks are minimal and could benefit from additional subtasks for data validation and integration. The complexity is relatively low as it's primarily extending existing task creation functionality to work without a PRD."
|
||||
},
|
||||
{
|
||||
"taskId": 69,
|
||||
"taskTitle": "Enhance Analyze Complexity for Specific Task IDs",
|
||||
"complexityScore": 5,
|
||||
"recommendedSubtasks": 4,
|
||||
"expansionPrompt": "Break down the enhancement of analyze-complexity for specific task IDs into detailed subtasks, focusing on core logic modification, CLI interface updates, MCP tool integration, and comprehensive testing. For each subtask, provide specific implementation details and testing approaches.",
|
||||
"reasoning": "This task involves modifying the existing analyze-complexity feature to support analyzing specific task IDs. The existing 4 subtasks cover the main components well. The complexity is moderate as it requires modifying existing functionality while maintaining backward compatibility and ensuring proper report merging."
|
||||
},
|
||||
{
|
||||
"taskId": 70,
|
||||
"taskTitle": "Implement 'diagram' command for Mermaid diagram generation",
|
||||
"complexityScore": 6,
|
||||
"recommendedSubtasks": 4,
|
||||
"expansionPrompt": "Break down the implementation of the 'diagram' command for Mermaid diagram generation into detailed subtasks, focusing on command interface design, diagram generation core functionality, output handling, and documentation. For each subtask, provide specific implementation details and testing approaches.",
|
||||
"reasoning": "This task involves creating a new command for generating Mermaid diagrams to visualize task dependencies. The existing 4 subtasks cover the main components well. The complexity is moderate as it requires implementing graph visualization algorithms and integrating with the existing task management system."
|
||||
},
|
||||
{
|
||||
"taskId": 72,
|
||||
"taskTitle": "Implement PDF Generation for Project Progress and Dependency Overview",
|
||||
"complexityScore": 7,
|
||||
"recommendedSubtasks": 6,
|
||||
"expansionPrompt": "Break down the implementation of PDF generation for project progress and dependency overview into detailed subtasks, focusing on PDF library selection, template design, data collection, dependency visualization integration, core functionality, and export options. For each subtask, provide specific implementation details and testing approaches.",
|
||||
"reasoning": "This task involves creating a feature to generate PDF reports summarizing project progress and visualizing task dependencies. The existing 6 subtasks cover the main components well. The complexity is high due to the need for PDF generation, data visualization, and integration with the existing diagram command."
|
||||
},
|
||||
{
|
||||
"taskId": 75,
|
||||
"taskTitle": "Integrate Google Search Grounding for Research Role",
|
||||
"complexityScore": 4,
|
||||
"recommendedSubtasks": 4,
|
||||
"expansionPrompt": "Break down the integration of Google Search Grounding for the research role into detailed subtasks, focusing on AI service layer modification, research role detection, model configuration updates, and comprehensive testing. For each subtask, provide specific implementation details and testing approaches.",
|
||||
"reasoning": "This task involves updating the AI service layer to enable Google Search Grounding specifically for the research role. The existing 4 subtasks cover the main components well. The complexity is relatively low as it's primarily a conditional feature enablement based on the AI role and provider."
|
||||
},
|
||||
{
|
||||
"taskId": 76,
|
||||
"taskTitle": "Develop E2E Test Framework for Taskmaster MCP Server (FastMCP over stdio)",
|
||||
"complexityScore": 8,
|
||||
"recommendedSubtasks": 7,
|
||||
"expansionPrompt": "Break down the development of the E2E test framework for Taskmaster MCP server into detailed subtasks, focusing on architecture design, server launcher implementation, message protocol handling, request/response correlation, assertion framework, test case implementation, and CI integration. For each subtask, provide specific implementation details and testing approaches.",
|
||||
"reasoning": "This task involves designing and implementing a comprehensive end-to-end test framework for the Taskmaster MCP server. The existing 7 subtasks cover the main components well. The complexity is high due to the need for subprocess management, protocol handling, and robust test assertion capabilities."
|
||||
},
|
||||
{
|
||||
"taskId": 77,
|
||||
"taskTitle": "Implement AI Usage Telemetry for Taskmaster (with external analytics endpoint)",
|
||||
"complexityScore": 7,
|
||||
"recommendedSubtasks": 17,
|
||||
"expansionPrompt": "Break down the implementation of AI usage telemetry for Taskmaster into detailed subtasks, focusing on telemetry utility development, secure transmission, user consent mechanisms, command integration, usage summary display, and provider-specific implementations. For each subtask, provide specific implementation details and testing approaches.",
|
||||
"reasoning": "This task involves implementing a comprehensive telemetry system for tracking AI usage in Taskmaster. The existing 17 subtasks are very detailed and cover all aspects of the implementation across different commands and providers. The complexity is high due to the need for accurate token counting, cost calculation, and integration across multiple commands and AI providers."
|
||||
},
|
||||
{
|
||||
"taskId": 80,
|
||||
"taskTitle": "Implement Unique User ID Generation and Storage During Installation",
|
||||
"complexityScore": 4,
|
||||
"recommendedSubtasks": 5,
|
||||
"expansionPrompt": "Break down the implementation of unique user ID generation and storage during installation into detailed subtasks, focusing on post-install script structure, UUID generation, config file handling, integration, and documentation. For each subtask, provide specific implementation details and testing approaches.",
|
||||
"reasoning": "This task involves implementing a mechanism to generate and store a unique user identifier during the npm installation process. The existing 5 subtasks cover the main components well. The complexity is relatively low as it primarily involves UUID generation and configuration file management."
|
||||
},
|
||||
{
|
||||
"taskId": 81,
|
||||
"taskTitle": "Task #81: Implement Comprehensive Local Telemetry System with Future Server Integration Capability",
|
||||
"complexityScore": 8,
|
||||
"recommendedSubtasks": 6,
|
||||
"expansionPrompt": "Break down the implementation of the comprehensive local telemetry system into detailed subtasks, focusing on additional data collection points, local storage system, server transmission architecture, privacy controls, debugging tools, and user-facing benefits. For each subtask, provide specific implementation details, technical challenges, and testing approaches.",
|
||||
"reasoning": "This task involves expanding the existing telemetry infrastructure to provide more comprehensive insights while storing data locally until a server endpoint becomes available. The existing 6 subtasks cover the main components well. The complexity is high due to the need for robust local storage, data aggregation, privacy controls, and designing for future server integration."
|
||||
}
|
||||
]
|
||||
}
|
||||
"meta": {
|
||||
"generatedAt": "2025-05-17T22:29:22.179Z",
|
||||
"tasksAnalyzed": 40,
|
||||
"thresholdScore": 5,
|
||||
"projectName": "Taskmaster",
|
||||
"usedResearch": false
|
||||
},
|
||||
"complexityAnalysis": [
|
||||
{
|
||||
"taskId": 24,
|
||||
"taskTitle": "Implement AI-Powered Test Generation Command",
|
||||
"complexityScore": 7,
|
||||
"recommendedSubtasks": 5,
|
||||
"expansionPrompt": "Break down the implementation of the AI-powered test generation command into detailed subtasks covering: command structure setup, AI prompt engineering, test file generation logic, integration with Claude API, and comprehensive error handling.",
|
||||
"reasoning": "This task involves complex integration with an AI service (Claude), requires sophisticated prompt engineering, and needs to generate structured code files. The existing 3 subtasks are a good start but could be expanded to include more detailed steps for AI integration, error handling, and test file formatting."
|
||||
},
|
||||
{
|
||||
"taskId": 26,
|
||||
"taskTitle": "Implement Context Foundation for AI Operations",
|
||||
"complexityScore": 6,
|
||||
"recommendedSubtasks": 4,
|
||||
"expansionPrompt": "The current 4 subtasks for implementing the context foundation appear comprehensive. Consider if any additional subtasks are needed for testing, documentation, or integration with existing systems.",
|
||||
"reasoning": "This task involves creating a foundation for context integration with several well-defined components. The existing 4 subtasks cover the main implementation areas (context-file flag, cursor rules integration, context extraction utility, and command handler updates). The complexity is moderate as it requires careful integration with existing systems but has clear requirements."
|
||||
},
|
||||
{
|
||||
"taskId": 27,
|
||||
"taskTitle": "Implement Context Enhancements for AI Operations",
|
||||
"complexityScore": 7,
|
||||
"recommendedSubtasks": 4,
|
||||
"expansionPrompt": "The current 4 subtasks for implementing context enhancements appear well-structured. Consider if any additional subtasks are needed for testing, documentation, or performance optimization.",
|
||||
"reasoning": "This task builds upon the foundation from Task #26 and adds more sophisticated context handling features. The 4 existing subtasks cover the main implementation areas (code context extraction, task history context, PRD context integration, and context formatting). The complexity is higher than the foundation task due to the need for intelligent context selection and optimization."
|
||||
},
|
||||
{
|
||||
"taskId": 28,
|
||||
"taskTitle": "Implement Advanced ContextManager System",
|
||||
"complexityScore": 8,
|
||||
"recommendedSubtasks": 5,
|
||||
"expansionPrompt": "The current 5 subtasks for implementing the advanced ContextManager system appear comprehensive. Consider if any additional subtasks are needed for testing, documentation, or backward compatibility with previous context implementations.",
|
||||
"reasoning": "This task represents the most complex phase of the context implementation, requiring a sophisticated class design, optimization algorithms, and integration with multiple systems. The 5 existing subtasks cover the core implementation areas, but the complexity is high due to the need for intelligent context prioritization, token management, and performance monitoring."
|
||||
},
|
||||
{
|
||||
"taskId": 40,
|
||||
"taskTitle": "Implement 'plan' Command for Task Implementation Planning",
|
||||
"complexityScore": 5,
|
||||
"recommendedSubtasks": 4,
|
||||
"expansionPrompt": "The current 4 subtasks for implementing the 'plan' command appear well-structured. Consider if any additional subtasks are needed for testing, documentation, or integration with existing task management workflows.",
|
||||
"reasoning": "This task involves creating a new command that leverages AI to generate implementation plans. The existing 4 subtasks cover the main implementation areas (retrieving task content, generating plans with AI, formatting in XML, and error handling). The complexity is moderate as it builds on existing patterns for task updates but requires careful AI integration."
|
||||
},
|
||||
{
|
||||
"taskId": 41,
|
||||
"taskTitle": "Implement Visual Task Dependency Graph in Terminal",
|
||||
"complexityScore": 8,
|
||||
"recommendedSubtasks": 10,
|
||||
"expansionPrompt": "The current 10 subtasks for implementing the visual task dependency graph appear comprehensive. Consider if any additional subtasks are needed for performance optimization with large graphs or additional visualization options.",
|
||||
"reasoning": "This task involves creating a sophisticated visualization system for terminal display, which is inherently complex due to layout algorithms, ASCII/Unicode rendering, and handling complex dependency relationships. The 10 existing subtasks cover all major aspects of implementation, from CLI interface to accessibility features."
|
||||
},
|
||||
{
|
||||
"taskId": 42,
|
||||
"taskTitle": "Implement MCP-to-MCP Communication Protocol",
|
||||
"complexityScore": 9,
|
||||
"recommendedSubtasks": 8,
|
||||
"expansionPrompt": "The current 8 subtasks for implementing the MCP-to-MCP communication protocol appear well-structured. Consider if any additional subtasks are needed for security hardening, performance optimization, or comprehensive documentation.",
|
||||
"reasoning": "This task involves designing and implementing a complex communication protocol between different MCP tools and servers. It requires sophisticated adapter patterns, client-server architecture, and handling of multiple operational modes. The complexity is very high due to the need for standardization, security, and backward compatibility."
|
||||
},
|
||||
{
|
||||
"taskId": 44,
|
||||
"taskTitle": "Implement Task Automation with Webhooks and Event Triggers",
|
||||
"complexityScore": 8,
|
||||
"recommendedSubtasks": 7,
|
||||
"expansionPrompt": "The current 7 subtasks for implementing task automation with webhooks appear comprehensive. Consider if any additional subtasks are needed for security testing, rate limiting implementation, or webhook monitoring tools.",
|
||||
"reasoning": "This task involves creating a sophisticated event system with webhooks for integration with external services. The complexity is high due to the need for secure authentication, reliable delivery mechanisms, and handling of various webhook formats and protocols. The existing subtasks cover the main implementation areas but security and monitoring could be emphasized more."
|
||||
},
|
||||
{
|
||||
"taskId": 45,
|
||||
"taskTitle": "Implement GitHub Issue Import Feature",
|
||||
"complexityScore": 6,
|
||||
"recommendedSubtasks": 5,
|
||||
"expansionPrompt": "The current 5 subtasks for implementing the GitHub issue import feature appear well-structured. Consider if any additional subtasks are needed for handling GitHub API rate limiting, caching, or supporting additional issue metadata.",
|
||||
"reasoning": "This task involves integrating with the GitHub API to import issues as tasks. The complexity is moderate as it requires API authentication, data mapping, and error handling. The existing 5 subtasks cover the main implementation areas from design to end-to-end implementation."
|
||||
},
|
||||
{
|
||||
"taskId": 46,
|
||||
"taskTitle": "Implement ICE Analysis Command for Task Prioritization",
|
||||
"complexityScore": 7,
|
||||
"recommendedSubtasks": 5,
|
||||
"expansionPrompt": "The current 5 subtasks for implementing the ICE analysis command appear comprehensive. Consider if any additional subtasks are needed for visualization of ICE scores or integration with other prioritization methods.",
|
||||
"reasoning": "This task involves creating an AI-powered analysis system for task prioritization using the ICE methodology. The complexity is high due to the need for sophisticated scoring algorithms, AI integration, and report generation. The existing subtasks cover the main implementation areas from algorithm design to integration with existing systems."
|
||||
},
|
||||
{
|
||||
"taskId": 47,
|
||||
"taskTitle": "Enhance Task Suggestion Actions Card Workflow",
|
||||
"complexityScore": 6,
|
||||
"recommendedSubtasks": 6,
|
||||
"expansionPrompt": "The current 6 subtasks for enhancing the task suggestion actions card workflow appear well-structured. Consider if any additional subtasks are needed for user testing, accessibility improvements, or performance optimization.",
|
||||
"reasoning": "This task involves redesigning the UI workflow for task expansion and management. The complexity is moderate as it requires careful UX design and state management but builds on existing components. The 6 existing subtasks cover the main implementation areas from design to testing."
|
||||
},
|
||||
{
|
||||
"taskId": 48,
|
||||
"taskTitle": "Refactor Prompts into Centralized Structure",
|
||||
"complexityScore": 4,
|
||||
"recommendedSubtasks": 3,
|
||||
"expansionPrompt": "The current 3 subtasks for refactoring prompts into a centralized structure appear appropriate. Consider if any additional subtasks are needed for prompt versioning, documentation, or testing.",
|
||||
"reasoning": "This task involves a straightforward refactoring to improve code organization. The complexity is relatively low as it primarily involves moving code rather than creating new functionality. The 3 existing subtasks cover the main implementation areas from directory structure to integration."
|
||||
},
|
||||
{
|
||||
"taskId": 49,
|
||||
"taskTitle": "Implement Code Quality Analysis Command",
|
||||
"complexityScore": 8,
|
||||
"recommendedSubtasks": 6,
|
||||
"expansionPrompt": "The current 6 subtasks for implementing the code quality analysis command appear comprehensive. Consider if any additional subtasks are needed for performance optimization with large codebases or integration with existing code quality tools.",
|
||||
"reasoning": "This task involves creating a sophisticated code analysis system with pattern recognition, best practice verification, and AI-powered recommendations. The complexity is high due to the need for code parsing, complex analysis algorithms, and integration with AI services. The existing subtasks cover the main implementation areas from algorithm design to user interface."
|
||||
},
|
||||
{
|
||||
"taskId": 50,
|
||||
"taskTitle": "Implement Test Coverage Tracking System by Task",
|
||||
"complexityScore": 9,
|
||||
"recommendedSubtasks": 5,
|
||||
"expansionPrompt": "The current 5 subtasks for implementing the test coverage tracking system appear well-structured. Consider if any additional subtasks are needed for integration with CI/CD systems, performance optimization, or visualization tools.",
|
||||
"reasoning": "This task involves creating a complex system that maps test coverage to specific tasks and subtasks. The complexity is very high due to the need for sophisticated data structures, integration with coverage tools, and AI-powered test generation. The existing subtasks are comprehensive and cover the main implementation areas from data structure design to AI integration."
|
||||
},
|
||||
{
|
||||
"taskId": 51,
|
||||
"taskTitle": "Implement Perplexity Research Command",
|
||||
"complexityScore": 6,
|
||||
"recommendedSubtasks": 5,
|
||||
"expansionPrompt": "The current 5 subtasks for implementing the Perplexity research command appear comprehensive. Consider if any additional subtasks are needed for caching optimization, result formatting, or integration with other research tools.",
|
||||
"reasoning": "This task involves creating a new command that integrates with the Perplexity AI API for research. The complexity is moderate as it requires API integration, context extraction, and result formatting. The 5 existing subtasks cover the main implementation areas from API client to caching system."
|
||||
},
|
||||
{
|
||||
"taskId": 52,
|
||||
"taskTitle": "Implement Task Suggestion Command for CLI",
|
||||
"complexityScore": 6,
|
||||
"recommendedSubtasks": 5,
|
||||
"expansionPrompt": "The current 5 subtasks for implementing the task suggestion command appear well-structured. Consider if any additional subtasks are needed for suggestion quality evaluation, user feedback collection, or integration with existing task workflows.",
|
||||
"reasoning": "This task involves creating a new CLI command that generates contextually relevant task suggestions using AI. The complexity is moderate as it requires AI integration, context collection, and interactive CLI interfaces. The existing subtasks cover the main implementation areas from data collection to user interface."
|
||||
},
|
||||
{
|
||||
"taskId": 53,
|
||||
"taskTitle": "Implement Subtask Suggestion Feature for Parent Tasks",
|
||||
"complexityScore": 6,
|
||||
"recommendedSubtasks": 6,
|
||||
"expansionPrompt": "The current 6 subtasks for implementing the subtask suggestion feature appear comprehensive. Consider if any additional subtasks are needed for suggestion quality metrics, user feedback collection, or performance optimization.",
|
||||
"reasoning": "This task involves creating a feature that suggests contextually relevant subtasks for parent tasks. The complexity is moderate as it builds on existing task management systems but requires sophisticated AI integration and context analysis. The 6 existing subtasks cover the main implementation areas from validation to testing."
|
||||
},
|
||||
{
|
||||
"taskId": 55,
|
||||
"taskTitle": "Implement Positional Arguments Support for CLI Commands",
|
||||
"complexityScore": 5,
|
||||
"recommendedSubtasks": 5,
|
||||
"expansionPrompt": "The current 5 subtasks for implementing positional arguments support appear well-structured. Consider if any additional subtasks are needed for backward compatibility testing, documentation updates, or user experience improvements.",
|
||||
"reasoning": "This task involves modifying the command parsing logic to support positional arguments alongside the existing flag-based syntax. The complexity is moderate as it requires careful handling of different argument styles and edge cases. The 5 existing subtasks cover the main implementation areas from analysis to documentation."
|
||||
},
|
||||
{
|
||||
"taskId": 57,
|
||||
"taskTitle": "Enhance Task-Master CLI User Experience and Interface",
|
||||
"complexityScore": 7,
|
||||
"recommendedSubtasks": 6,
|
||||
"expansionPrompt": "The current 6 subtasks for enhancing the CLI user experience appear comprehensive. Consider if any additional subtasks are needed for accessibility testing, internationalization, or performance optimization.",
|
||||
"reasoning": "This task involves a significant overhaul of the CLI interface to improve user experience. The complexity is high due to the breadth of changes (logging, visual elements, interactive components, etc.) and the need for consistent design across all commands. The 6 existing subtasks cover the main implementation areas from log management to help systems."
|
||||
},
|
||||
{
|
||||
"taskId": 60,
|
||||
"taskTitle": "Implement Mentor System with Round-Table Discussion Feature",
|
||||
"complexityScore": 8,
|
||||
"recommendedSubtasks": 7,
|
||||
"expansionPrompt": "The current 7 subtasks for implementing the mentor system appear well-structured. Consider if any additional subtasks are needed for mentor personality consistency, discussion quality evaluation, or performance optimization with multiple mentors.",
|
||||
"reasoning": "This task involves creating a sophisticated mentor simulation system with round-table discussions. The complexity is high due to the need for personality simulation, complex LLM integration, and structured discussion management. The 7 existing subtasks cover the main implementation areas from architecture to testing."
|
||||
},
|
||||
{
|
||||
"taskId": 62,
|
||||
"taskTitle": "Add --simple Flag to Update Commands for Direct Text Input",
|
||||
"complexityScore": 4,
|
||||
"recommendedSubtasks": 8,
|
||||
"expansionPrompt": "The current 8 subtasks for implementing the --simple flag appear comprehensive. Consider if any additional subtasks are needed for user experience testing or documentation updates.",
|
||||
"reasoning": "This task involves adding a simple flag option to bypass AI processing for updates. The complexity is relatively low as it primarily involves modifying existing command handlers and adding a flag. The 8 existing subtasks are very detailed and cover all aspects of implementation from command parsing to testing."
|
||||
},
|
||||
{
|
||||
"taskId": 63,
|
||||
"taskTitle": "Add pnpm Support for the Taskmaster Package",
|
||||
"complexityScore": 5,
|
||||
"recommendedSubtasks": 8,
|
||||
"expansionPrompt": "The current 8 subtasks for adding pnpm support appear comprehensive. Consider if any additional subtasks are needed for CI/CD integration, performance comparison, or documentation updates.",
|
||||
"reasoning": "This task involves ensuring the package works correctly with pnpm as an alternative package manager. The complexity is moderate as it requires careful testing of installation processes and scripts across different environments. The 8 existing subtasks cover all major aspects from documentation to binary verification."
|
||||
},
|
||||
{
|
||||
"taskId": 64,
|
||||
"taskTitle": "Add Yarn Support for Taskmaster Installation",
|
||||
"complexityScore": 5,
|
||||
"recommendedSubtasks": 9,
|
||||
"expansionPrompt": "The current 9 subtasks for adding Yarn support appear comprehensive. Consider if any additional subtasks are needed for performance testing, CI/CD integration, or compatibility with different Yarn versions.",
|
||||
"reasoning": "This task involves ensuring the package works correctly with Yarn as an alternative package manager. The complexity is moderate as it requires careful testing of installation processes and scripts across different environments. The 9 existing subtasks are very detailed and cover all aspects from configuration to testing."
|
||||
},
|
||||
{
|
||||
"taskId": 65,
|
||||
"taskTitle": "Add Bun Support for Taskmaster Installation",
|
||||
"complexityScore": 6,
|
||||
"recommendedSubtasks": 6,
|
||||
"expansionPrompt": "The current 6 subtasks for adding Bun support appear well-structured. Consider if any additional subtasks are needed for handling Bun-specific issues, performance testing, or documentation updates.",
|
||||
"reasoning": "This task involves adding support for the newer Bun package manager. The complexity is slightly higher than the other package manager tasks due to Bun's differences from Node.js and potential compatibility issues. The 6 existing subtasks cover the main implementation areas from research to documentation."
|
||||
},
|
||||
{
|
||||
"taskId": 67,
|
||||
"taskTitle": "Add CLI JSON output and Cursor keybindings integration",
|
||||
"complexityScore": 5,
|
||||
"recommendedSubtasks": 5,
|
||||
"expansionPrompt": "The current 5 subtasks for implementing JSON output and Cursor keybindings appear well-structured. Consider if any additional subtasks are needed for testing across different operating systems, documentation updates, or user experience improvements.",
|
||||
"reasoning": "This task involves two distinct features: adding JSON output to CLI commands and creating a keybindings installation command. The complexity is moderate as it requires careful handling of different output formats and OS-specific file paths. The 5 existing subtasks cover the main implementation areas for both features."
|
||||
},
|
||||
{
|
||||
"taskId": 68,
|
||||
"taskTitle": "Ability to create tasks without parsing PRD",
|
||||
"complexityScore": 3,
|
||||
"recommendedSubtasks": 2,
|
||||
"expansionPrompt": "The current 2 subtasks for implementing task creation without PRD appear appropriate. Consider if any additional subtasks are needed for validation, error handling, or integration with existing task management workflows.",
|
||||
"reasoning": "This task involves a relatively simple modification to allow task creation without requiring a PRD document. The complexity is low as it primarily involves creating a form interface and saving functionality. The 2 existing subtasks cover the main implementation areas of UI design and data saving."
|
||||
},
|
||||
{
|
||||
"taskId": 69,
|
||||
"taskTitle": "Enhance Analyze Complexity for Specific Task IDs",
|
||||
"complexityScore": 5,
|
||||
"recommendedSubtasks": 4,
|
||||
"expansionPrompt": "The current 4 subtasks for enhancing the analyze-complexity feature appear well-structured. Consider if any additional subtasks are needed for performance optimization with large task sets or visualization improvements.",
|
||||
"reasoning": "This task involves modifying the existing analyze-complexity feature to support analyzing specific task IDs and updating reports. The complexity is moderate as it requires careful handling of report merging and filtering logic. The 4 existing subtasks cover the main implementation areas from core logic to testing."
|
||||
},
|
||||
{
|
||||
"taskId": 70,
|
||||
"taskTitle": "Implement 'diagram' command for Mermaid diagram generation",
|
||||
"complexityScore": 6,
|
||||
"recommendedSubtasks": 4,
|
||||
"expansionPrompt": "The current 4 subtasks for implementing the 'diagram' command appear well-structured. Consider if any additional subtasks are needed for handling large dependency graphs, additional output formats, or integration with existing visualization tools.",
|
||||
"reasoning": "This task involves creating a new command that generates Mermaid diagrams to visualize task dependencies. The complexity is moderate as it requires parsing task relationships, generating proper Mermaid syntax, and handling various output options. The 4 existing subtasks cover the main implementation areas from interface design to documentation."
|
||||
},
|
||||
{
|
||||
"taskId": 72,
|
||||
"taskTitle": "Implement PDF Generation for Project Progress and Dependency Overview",
|
||||
"complexityScore": 7,
|
||||
"recommendedSubtasks": 6,
|
||||
"expansionPrompt": "The current 6 subtasks for implementing PDF generation appear comprehensive. Consider if any additional subtasks are needed for handling large projects, additional visualization options, or integration with existing reporting tools.",
|
||||
"reasoning": "This task involves creating a feature to generate PDF reports of project progress and dependency visualization. The complexity is high due to the need for PDF generation, data collection, and visualization integration. The 6 existing subtasks cover the main implementation areas from library selection to export options."
|
||||
},
|
||||
{
|
||||
"taskId": 75,
|
||||
"taskTitle": "Integrate Google Search Grounding for Research Role",
|
||||
"complexityScore": 5,
|
||||
"recommendedSubtasks": 4,
|
||||
"expansionPrompt": "The current 4 subtasks for integrating Google Search Grounding appear well-structured. Consider if any additional subtasks are needed for testing with different query types, error handling, or performance optimization.",
|
||||
"reasoning": "This task involves updating the AI service layer to enable Google Search Grounding for research roles. The complexity is moderate as it requires careful integration with the existing AI service architecture and conditional logic. The 4 existing subtasks cover the main implementation areas from service layer modification to testing."
|
||||
},
|
||||
{
|
||||
"taskId": 76,
|
||||
"taskTitle": "Develop E2E Test Framework for Taskmaster MCP Server (FastMCP over stdio)",
|
||||
"complexityScore": 8,
|
||||
"recommendedSubtasks": 7,
|
||||
"expansionPrompt": "The current 7 subtasks for developing the E2E test framework appear comprehensive. Consider if any additional subtasks are needed for test result reporting, CI/CD integration, or performance benchmarking.",
|
||||
"reasoning": "This task involves creating a sophisticated end-to-end testing framework for the MCP server. The complexity is high due to the need for subprocess management, protocol handling, and robust test case definition. The 7 existing subtasks cover the main implementation areas from architecture to documentation."
|
||||
},
|
||||
{
|
||||
"taskId": 77,
|
||||
"taskTitle": "Implement AI Usage Telemetry for Taskmaster (with external analytics endpoint)",
|
||||
"complexityScore": 7,
|
||||
"recommendedSubtasks": 18,
|
||||
"expansionPrompt": "The current 18 subtasks for implementing AI usage telemetry appear very comprehensive. Consider if any additional subtasks are needed for security hardening, privacy compliance, or user feedback collection.",
|
||||
"reasoning": "This task involves creating a telemetry system to track AI usage metrics. The complexity is high due to the need for secure data transmission, comprehensive data collection, and integration across multiple commands. The 18 existing subtasks are extremely detailed and cover all aspects of implementation from core utility to provider-specific updates."
|
||||
},
|
||||
{
|
||||
"taskId": 80,
|
||||
"taskTitle": "Implement Unique User ID Generation and Storage During Installation",
|
||||
"complexityScore": 4,
|
||||
"recommendedSubtasks": 5,
|
||||
"expansionPrompt": "The current 5 subtasks for implementing unique user ID generation appear well-structured. Consider if any additional subtasks are needed for privacy compliance, security auditing, or integration with the telemetry system.",
|
||||
"reasoning": "This task involves generating and storing a unique user identifier during installation. The complexity is relatively low as it primarily involves UUID generation and configuration file management. The 5 existing subtasks cover the main implementation areas from script structure to documentation."
|
||||
},
|
||||
{
|
||||
"taskId": 81,
|
||||
"taskTitle": "Task #81: Implement Comprehensive Local Telemetry System with Future Server Integration Capability",
|
||||
"complexityScore": 8,
|
||||
"recommendedSubtasks": 6,
|
||||
"expansionPrompt": "The current 6 subtasks for implementing the comprehensive local telemetry system appear well-structured. Consider if any additional subtasks are needed for data migration, storage optimization, or visualization tools.",
|
||||
"reasoning": "This task involves expanding the telemetry system to capture additional metrics and implement local storage with future server integration capability. The complexity is high due to the breadth of data collection, storage requirements, and privacy considerations. The 6 existing subtasks cover the main implementation areas from data collection to user-facing benefits."
|
||||
},
|
||||
{
|
||||
"taskId": 82,
|
||||
"taskTitle": "Update supported-models.json with token limit fields",
|
||||
"complexityScore": 3,
|
||||
"recommendedSubtasks": 1,
|
||||
"expansionPrompt": "This task appears straightforward enough to be implemented without further subtasks. Focus on researching accurate token limit values for each model and ensuring backward compatibility.",
|
||||
"reasoning": "This task involves a simple update to the supported-models.json file to include new token limit fields. The complexity is low as it primarily involves research and data entry. No subtasks are necessary as the task is well-defined and focused."
|
||||
},
|
||||
{
|
||||
"taskId": 83,
|
||||
"taskTitle": "Update config-manager.js defaults and getters",
|
||||
"complexityScore": 4,
|
||||
"recommendedSubtasks": 1,
|
||||
"expansionPrompt": "This task appears straightforward enough to be implemented without further subtasks. Focus on updating the DEFAULTS object and related getter functions while maintaining backward compatibility.",
|
||||
"reasoning": "This task involves updating the config-manager.js module to replace maxTokens with more specific token limit fields. The complexity is relatively low as it primarily involves modifying existing code rather than creating new functionality. No subtasks are necessary as the task is well-defined and focused."
|
||||
},
|
||||
{
|
||||
"taskId": 84,
|
||||
"taskTitle": "Implement token counting utility",
|
||||
"complexityScore": 5,
|
||||
"recommendedSubtasks": 1,
|
||||
"expansionPrompt": "This task appears well-defined enough to be implemented without further subtasks. Focus on implementing accurate token counting for different models and proper fallback mechanisms.",
|
||||
"reasoning": "This task involves creating a utility function to count tokens for different AI models. The complexity is moderate as it requires integration with the tiktoken library and handling different tokenization schemes. No subtasks are necessary as the task is well-defined and focused."
|
||||
},
|
||||
{
|
||||
"taskId": 85,
|
||||
"taskTitle": "Update ai-services-unified.js for dynamic token limits",
|
||||
"complexityScore": 6,
|
||||
"recommendedSubtasks": 1,
|
||||
"expansionPrompt": "This task appears well-defined enough to be implemented without further subtasks. Focus on implementing dynamic token limit adjustment based on input length and model capabilities.",
|
||||
"reasoning": "This task involves modifying the AI service runner to use the new token counting utility and dynamically adjust output token limits. The complexity is moderate to high as it requires careful integration with existing code and handling various edge cases. No subtasks are necessary as the task is well-defined and focused."
|
||||
},
|
||||
{
|
||||
"taskId": 86,
|
||||
"taskTitle": "Update .taskmasterconfig schema and user guide",
|
||||
"complexityScore": 4,
|
||||
"recommendedSubtasks": 1,
|
||||
"expansionPrompt": "This task appears straightforward enough to be implemented without further subtasks. Focus on creating clear migration guidance and updating documentation.",
|
||||
"reasoning": "This task involves creating a migration guide for users to update their configuration files and documenting the new token limit options. The complexity is relatively low as it primarily involves documentation and schema validation. No subtasks are necessary as the task is well-defined and focused."
|
||||
},
|
||||
{
|
||||
"taskId": 87,
|
||||
"taskTitle": "Implement validation and error handling",
|
||||
"complexityScore": 5,
|
||||
"recommendedSubtasks": 1,
|
||||
"expansionPrompt": "This task appears well-defined enough to be implemented without further subtasks. Focus on comprehensive validation and helpful error messages throughout the system.",
|
||||
"reasoning": "This task involves adding validation and error handling for token limits throughout the system. The complexity is moderate as it requires careful integration with multiple components and creating helpful error messages. No subtasks are necessary as the task is well-defined and focused."
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createOpenAI } from '@ai-sdk/openai'; // Using openai provider from Vercel AI SDK
|
||||
import { generateObject } from 'ai'; // Import necessary functions from 'ai'
|
||||
import { generateObject, generateText } from 'ai'; // Import necessary functions from 'ai'
|
||||
import { log } from '../../scripts/modules/utils.js';
|
||||
|
||||
function getClient(apiKey, baseUrl) {
|
||||
|
||||
@@ -78,10 +78,16 @@ async function generateOpenRouterText({
|
||||
}
|
||||
};
|
||||
} catch (error) {
|
||||
log(
|
||||
'error',
|
||||
`OpenRouter generateText failed for model ${modelId}: ${error.message}`
|
||||
);
|
||||
let detailedMessage = `OpenRouter generateText failed for model ${modelId}: ${error.message}`;
|
||||
if (error.cause) {
|
||||
detailedMessage += `\n\nCause:\n\n ${typeof error.cause === 'string' ? error.cause : JSON.stringify(error.cause)}`;
|
||||
}
|
||||
// Vercel AI SDK sometimes wraps the actual API error response in error.data
|
||||
if (error.data) {
|
||||
detailedMessage += `\n\nData:\n\n ${JSON.stringify(error.data)}`;
|
||||
}
|
||||
// Log the original error object for full context if needed for deeper debugging
|
||||
log('error', detailedMessage, { originalErrorObject: error });
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -127,10 +133,14 @@ async function streamOpenRouterText({
|
||||
});
|
||||
return stream;
|
||||
} catch (error) {
|
||||
log(
|
||||
'error',
|
||||
`OpenRouter streamText failed for model ${modelId}: ${error.message}`
|
||||
);
|
||||
let detailedMessage = `OpenRouter streamText failed for model ${modelId}: ${error.message}`;
|
||||
if (error.cause) {
|
||||
detailedMessage += `\n\nCause:\n\n ${typeof error.cause === 'string' ? error.cause : JSON.stringify(error.cause)}`;
|
||||
}
|
||||
if (error.data) {
|
||||
detailedMessage += `\n\nData:\n\n ${JSON.stringify(error.data)}`;
|
||||
}
|
||||
log('error', detailedMessage, { originalErrorObject: error });
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -217,10 +227,14 @@ async function generateOpenRouterObject({
|
||||
}
|
||||
};
|
||||
} catch (error) {
|
||||
log(
|
||||
'error',
|
||||
`OpenRouter generateObject failed for model ${modelId}: ${error.message}`
|
||||
);
|
||||
let detailedMessage = `OpenRouter generateObject failed for model ${modelId}: ${error.message}`;
|
||||
if (error.cause) {
|
||||
detailedMessage += `\n\nCause:\n\n ${typeof error.cause === 'string' ? error.cause : JSON.stringify(error.cause)}`;
|
||||
}
|
||||
if (error.data) {
|
||||
detailedMessage += `\n\nData:\n\n ${JSON.stringify(error.data)}`;
|
||||
}
|
||||
log('error', detailedMessage, { originalErrorObject: error });
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
34
tasks/task_082.txt
Normal file
34
tasks/task_082.txt
Normal file
@@ -0,0 +1,34 @@
|
||||
# Task ID: 82
|
||||
# Title: Update supported-models.json with token limit fields
|
||||
# Status: pending
|
||||
# Dependencies: None
|
||||
# Priority: high
|
||||
# Description: Modify the supported-models.json file to include contextWindowTokens and maxOutputTokens fields for each model, replacing the ambiguous max_tokens field.
|
||||
# Details:
|
||||
For each model entry in supported-models.json:
|
||||
1. Add `contextWindowTokens` field representing the total context window (input + output tokens)
|
||||
2. Add `maxOutputTokens` field representing the maximum tokens the model can generate
|
||||
3. Remove or deprecate the ambiguous `max_tokens` field if present
|
||||
|
||||
Research and populate accurate values for each model from official documentation:
|
||||
- For OpenAI models (e.g., gpt-4o): contextWindowTokens=128000, maxOutputTokens=16384
|
||||
- For Anthropic models (e.g., Claude 3.7): contextWindowTokens=200000, maxOutputTokens=8192
|
||||
- For other providers, find official documentation or use reasonable defaults
|
||||
|
||||
Example entry:
|
||||
```json
|
||||
{
|
||||
"id": "claude-3-7-sonnet-20250219",
|
||||
"swe_score": 0.623,
|
||||
"cost_per_1m_tokens": { "input": 3.0, "output": 15.0 },
|
||||
"allowed_roles": ["main", "fallback"],
|
||||
"contextWindowTokens": 200000,
|
||||
"maxOutputTokens": 8192
|
||||
}
|
||||
```
|
||||
|
||||
# Test Strategy:
|
||||
1. Validate JSON syntax after changes
|
||||
2. Verify all models have the new fields with reasonable values
|
||||
3. Check that the values align with official documentation from each provider
|
||||
4. Ensure backward compatibility by maintaining any fields other systems might depend on
|
||||
95
tasks/task_083.txt
Normal file
95
tasks/task_083.txt
Normal file
@@ -0,0 +1,95 @@
|
||||
# Task ID: 83
|
||||
# Title: Update config-manager.js defaults and getters
|
||||
# Status: pending
|
||||
# Dependencies: 82
|
||||
# Priority: high
|
||||
# Description: Modify the config-manager.js module to replace maxTokens with maxInputTokens and maxOutputTokens in the DEFAULTS object and update related getter functions.
|
||||
# Details:
|
||||
1. Update the `DEFAULTS` object in config-manager.js:
|
||||
```javascript
|
||||
const DEFAULTS = {
|
||||
// ... existing defaults
|
||||
main: {
|
||||
// Replace maxTokens with these two fields
|
||||
maxInputTokens: 16000, // Example default
|
||||
maxOutputTokens: 4000, // Example default
|
||||
temperature: 0.7
|
||||
// ... other fields
|
||||
},
|
||||
research: {
|
||||
maxInputTokens: 16000,
|
||||
maxOutputTokens: 4000,
|
||||
temperature: 0.7
|
||||
// ... other fields
|
||||
},
|
||||
fallback: {
|
||||
maxInputTokens: 8000,
|
||||
maxOutputTokens: 2000,
|
||||
temperature: 0.7
|
||||
// ... other fields
|
||||
}
|
||||
// ... rest of DEFAULTS
|
||||
};
|
||||
```
|
||||
|
||||
2. Update `getParametersForRole` function to return the new fields:
|
||||
```javascript
|
||||
function getParametersForRole(role, explicitRoot = null) {
|
||||
const config = _getConfig(explicitRoot);
|
||||
return {
|
||||
maxInputTokens: config[role]?.maxInputTokens,
|
||||
maxOutputTokens: config[role]?.maxOutputTokens,
|
||||
temperature: config[role]?.temperature
|
||||
// ... any other parameters
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
3. Add a new function to get model capabilities:
|
||||
```javascript
|
||||
function getModelCapabilities(providerName, modelId) {
|
||||
const models = MODEL_MAP[providerName?.toLowerCase()];
|
||||
const model = models?.find(m => m.id === modelId);
|
||||
return {
|
||||
contextWindowTokens: model?.contextWindowTokens,
|
||||
maxOutputTokens: model?.maxOutputTokens
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
4. Deprecate or update the role-specific maxTokens getters:
|
||||
```javascript
|
||||
// Either remove these or update them to return maxInputTokens
|
||||
function getMainMaxTokens(explicitRoot = null) {
|
||||
console.warn('getMainMaxTokens is deprecated. Use getParametersForRole("main") instead.');
|
||||
return getParametersForRole("main", explicitRoot).maxInputTokens;
|
||||
}
|
||||
// Same for getResearchMaxTokens and getFallbackMaxTokens
|
||||
```
|
||||
|
||||
5. Export the new functions:
|
||||
```javascript
|
||||
module.exports = {
|
||||
// ... existing exports
|
||||
getParametersForRole,
|
||||
getModelCapabilities
|
||||
};
|
||||
```
|
||||
|
||||
# Test Strategy:
|
||||
1. Unit test the updated getParametersForRole function with various configurations
|
||||
2. Verify the new getModelCapabilities function returns correct values
|
||||
3. Test with both default and custom configurations
|
||||
4. Ensure backward compatibility by checking that existing code using the old getters still works (with warnings)
|
||||
|
||||
# Subtasks:
|
||||
## 1. Update config-manager.js with specific token limit fields [pending]
|
||||
### Dependencies: None
|
||||
### Description: Modify the DEFAULTS object in config-manager.js to replace maxTokens with more specific token limit fields (maxInputTokens, maxOutputTokens, maxTotalTokens) and update related getter functions while maintaining backward compatibility.
|
||||
### Details:
|
||||
1. Replace maxTokens in the DEFAULTS object with maxInputTokens, maxOutputTokens, and maxTotalTokens
|
||||
2. Update any getter functions that reference maxTokens to handle both old and new configurations
|
||||
3. Ensure backward compatibility so existing code using maxTokens continues to work
|
||||
4. Update any related documentation or comments to reflect the new token limit fields
|
||||
5. Test the changes to verify both new specific token limits and legacy maxTokens usage work correctly
|
||||
|
||||
93
tasks/task_084.txt
Normal file
93
tasks/task_084.txt
Normal file
@@ -0,0 +1,93 @@
|
||||
# Task ID: 84
|
||||
# Title: Implement token counting utility
|
||||
# Status: pending
|
||||
# Dependencies: 82
|
||||
# Priority: high
|
||||
# Description: Create a utility function to count tokens for prompts based on the model being used, primarily using tiktoken for OpenAI and Anthropic models with character-based fallbacks for other providers.
|
||||
# Details:
|
||||
1. Install the tiktoken package:
|
||||
```bash
|
||||
npm install tiktoken
|
||||
```
|
||||
|
||||
2. Create a new file `scripts/modules/token-counter.js`:
|
||||
```javascript
|
||||
const tiktoken = require('tiktoken');
|
||||
|
||||
/**
|
||||
* Count tokens for a given text and model
|
||||
* @param {string} text - The text to count tokens for
|
||||
* @param {string} provider - The AI provider (e.g., 'openai', 'anthropic')
|
||||
* @param {string} modelId - The model ID
|
||||
* @returns {number} - Estimated token count
|
||||
*/
|
||||
function countTokens(text, provider, modelId) {
|
||||
if (!text) return 0;
|
||||
|
||||
// Convert to lowercase for case-insensitive matching
|
||||
const providerLower = provider?.toLowerCase();
|
||||
|
||||
try {
|
||||
// OpenAI models
|
||||
if (providerLower === 'openai') {
|
||||
// Most OpenAI chat models use cl100k_base encoding
|
||||
const encoding = tiktoken.encoding_for_model(modelId) || tiktoken.get_encoding('cl100k_base');
|
||||
return encoding.encode(text).length;
|
||||
}
|
||||
|
||||
// Anthropic models - can use cl100k_base as an approximation
|
||||
// or follow Anthropic's guidance
|
||||
if (providerLower === 'anthropic') {
|
||||
try {
|
||||
// Try to use cl100k_base as a reasonable approximation
|
||||
const encoding = tiktoken.get_encoding('cl100k_base');
|
||||
return encoding.encode(text).length;
|
||||
} catch (e) {
|
||||
// Fallback to Anthropic's character-based estimation
|
||||
return Math.ceil(text.length / 3.5); // ~3.5 chars per token for English
|
||||
}
|
||||
}
|
||||
|
||||
// For other providers, use character-based estimation as fallback
|
||||
// Different providers may have different tokenization schemes
|
||||
return Math.ceil(text.length / 4); // General fallback estimate
|
||||
} catch (error) {
|
||||
console.warn(`Token counting error: ${error.message}. Using character-based estimate.`);
|
||||
return Math.ceil(text.length / 4); // Fallback if tiktoken fails
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { countTokens };
|
||||
```
|
||||
|
||||
3. Add tests for the token counter in `tests/token-counter.test.js`:
|
||||
```javascript
|
||||
const { countTokens } = require('../scripts/modules/token-counter');
|
||||
|
||||
describe('Token Counter', () => {
|
||||
test('counts tokens for OpenAI models', () => {
|
||||
const text = 'Hello, world! This is a test.';
|
||||
const count = countTokens(text, 'openai', 'gpt-4');
|
||||
expect(count).toBeGreaterThan(0);
|
||||
expect(typeof count).toBe('number');
|
||||
});
|
||||
|
||||
test('counts tokens for Anthropic models', () => {
|
||||
const text = 'Hello, world! This is a test.';
|
||||
const count = countTokens(text, 'anthropic', 'claude-3-7-sonnet-20250219');
|
||||
expect(count).toBeGreaterThan(0);
|
||||
expect(typeof count).toBe('number');
|
||||
});
|
||||
|
||||
test('handles empty text', () => {
|
||||
expect(countTokens('', 'openai', 'gpt-4')).toBe(0);
|
||||
expect(countTokens(null, 'openai', 'gpt-4')).toBe(0);
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
# Test Strategy:
|
||||
1. Unit test the countTokens function with various inputs and models
|
||||
2. Compare token counts with known examples from OpenAI and Anthropic documentation
|
||||
3. Test edge cases: empty strings, very long texts, non-English texts
|
||||
4. Test fallback behavior when tiktoken fails or is not applicable
|
||||
104
tasks/task_085.txt
Normal file
104
tasks/task_085.txt
Normal file
@@ -0,0 +1,104 @@
|
||||
# Task ID: 85
|
||||
# Title: Update ai-services-unified.js for dynamic token limits
|
||||
# Status: pending
|
||||
# Dependencies: 83, 84
|
||||
# Priority: medium
|
||||
# Description: Modify the _unifiedServiceRunner function in ai-services-unified.js to use the new token counting utility and dynamically adjust output token limits based on input length.
|
||||
# Details:
|
||||
1. Import the token counter in `ai-services-unified.js`:
|
||||
```javascript
|
||||
const { countTokens } = require('./token-counter');
|
||||
const { getParametersForRole, getModelCapabilities } = require('./config-manager');
|
||||
```
|
||||
|
||||
2. Update the `_unifiedServiceRunner` function to implement dynamic token limit adjustment:
|
||||
```javascript
|
||||
async function _unifiedServiceRunner({
|
||||
serviceType,
|
||||
provider,
|
||||
modelId,
|
||||
systemPrompt,
|
||||
prompt,
|
||||
temperature,
|
||||
currentRole,
|
||||
effectiveProjectRoot,
|
||||
// ... other parameters
|
||||
}) {
|
||||
// Get role parameters with new token limits
|
||||
const roleParams = getParametersForRole(currentRole, effectiveProjectRoot);
|
||||
|
||||
// Get model capabilities
|
||||
const modelCapabilities = getModelCapabilities(provider, modelId);
|
||||
|
||||
// Count tokens in the prompts
|
||||
const systemPromptTokens = countTokens(systemPrompt, provider, modelId);
|
||||
const userPromptTokens = countTokens(prompt, provider, modelId);
|
||||
const totalPromptTokens = systemPromptTokens + userPromptTokens;
|
||||
|
||||
// Validate against input token limits
|
||||
if (totalPromptTokens > roleParams.maxInputTokens) {
|
||||
throw new Error(
|
||||
`Prompt (${totalPromptTokens} tokens) exceeds configured max input tokens (${roleParams.maxInputTokens}) for role '${currentRole}'.`
|
||||
);
|
||||
}
|
||||
|
||||
// Validate against model's absolute context window
|
||||
if (modelCapabilities.contextWindowTokens && totalPromptTokens > modelCapabilities.contextWindowTokens) {
|
||||
throw new Error(
|
||||
`Prompt (${totalPromptTokens} tokens) exceeds model's context window (${modelCapabilities.contextWindowTokens}) for ${modelId}.`
|
||||
);
|
||||
}
|
||||
|
||||
// Calculate available output tokens
|
||||
// If model has a combined context window, we need to subtract input tokens
|
||||
let availableOutputTokens = roleParams.maxOutputTokens;
|
||||
|
||||
// If model has a context window constraint, ensure we don't exceed it
|
||||
if (modelCapabilities.contextWindowTokens) {
|
||||
const remainingContextTokens = modelCapabilities.contextWindowTokens - totalPromptTokens;
|
||||
availableOutputTokens = Math.min(availableOutputTokens, remainingContextTokens);
|
||||
}
|
||||
|
||||
// Also respect the model's absolute max output limit
|
||||
if (modelCapabilities.maxOutputTokens) {
|
||||
availableOutputTokens = Math.min(availableOutputTokens, modelCapabilities.maxOutputTokens);
|
||||
}
|
||||
|
||||
// Prepare API call parameters
|
||||
const callParams = {
|
||||
apiKey,
|
||||
modelId,
|
||||
maxTokens: availableOutputTokens, // Use dynamically calculated output limit
|
||||
temperature: roleParams.temperature,
|
||||
messages,
|
||||
baseUrl,
|
||||
...(serviceType === 'generateObject' && { schema, objectName }),
|
||||
...restApiParams
|
||||
};
|
||||
|
||||
// Log token usage information
|
||||
console.debug(`Token usage: ${totalPromptTokens} input tokens, ${availableOutputTokens} max output tokens`);
|
||||
|
||||
// Rest of the function remains the same...
|
||||
}
|
||||
```
|
||||
|
||||
3. Update the error handling to provide clear messages about token limits:
|
||||
```javascript
|
||||
try {
|
||||
// Existing code...
|
||||
} catch (error) {
|
||||
if (error.message.includes('tokens')) {
|
||||
// Token-related errors should be clearly identified
|
||||
console.error(`Token limit error: ${error.message}`);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
```
|
||||
|
||||
# Test Strategy:
|
||||
1. Test with prompts of various lengths to verify dynamic adjustment
|
||||
2. Test with different models to ensure model-specific limits are respected
|
||||
3. Verify error messages are clear when limits are exceeded
|
||||
4. Test edge cases: very short prompts, prompts near the limit
|
||||
5. Integration test with actual API calls to verify the calculated limits work in practice
|
||||
107
tasks/task_086.txt
Normal file
107
tasks/task_086.txt
Normal file
@@ -0,0 +1,107 @@
|
||||
# Task ID: 86
|
||||
# Title: Update .taskmasterconfig schema and user guide
|
||||
# Status: pending
|
||||
# Dependencies: 83
|
||||
# Priority: medium
|
||||
# Description: Create a migration guide for users to update their .taskmasterconfig files and document the new token limit configuration options.
|
||||
# Details:
|
||||
1. Create a migration script or guide for users to update their existing `.taskmasterconfig` files:
|
||||
|
||||
```javascript
|
||||
// Example migration snippet for .taskmasterconfig
|
||||
{
|
||||
"main": {
|
||||
// Before:
|
||||
// "maxTokens": 16000,
|
||||
|
||||
// After:
|
||||
"maxInputTokens": 16000,
|
||||
"maxOutputTokens": 4000,
|
||||
"temperature": 0.7
|
||||
},
|
||||
"research": {
|
||||
"maxInputTokens": 16000,
|
||||
"maxOutputTokens": 4000,
|
||||
"temperature": 0.7
|
||||
},
|
||||
"fallback": {
|
||||
"maxInputTokens": 8000,
|
||||
"maxOutputTokens": 2000,
|
||||
"temperature": 0.7
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
2. Update the user documentation to explain the new token limit fields:
|
||||
|
||||
```markdown
|
||||
# Token Limit Configuration
|
||||
|
||||
Task Master now provides more granular control over token limits with separate settings for input and output tokens:
|
||||
|
||||
- `maxInputTokens`: Maximum number of tokens allowed in the input prompt (system prompt + user prompt)
|
||||
- `maxOutputTokens`: Maximum number of tokens the model should generate in its response
|
||||
|
||||
## Benefits
|
||||
|
||||
- More precise control over token usage
|
||||
- Better cost management
|
||||
- Reduced likelihood of hitting model context limits
|
||||
- Dynamic adjustment to maximize output space based on input length
|
||||
|
||||
## Migration from Previous Versions
|
||||
|
||||
If you're upgrading from a previous version, you'll need to update your `.taskmasterconfig` file:
|
||||
|
||||
1. Replace the single `maxTokens` field with separate `maxInputTokens` and `maxOutputTokens` fields
|
||||
2. Recommended starting values:
|
||||
- Set `maxInputTokens` to your previous `maxTokens` value
|
||||
- Set `maxOutputTokens` to approximately 1/4 of your model's context window
|
||||
|
||||
## Example Configuration
|
||||
|
||||
```json
|
||||
{
|
||||
"main": {
|
||||
"maxInputTokens": 16000,
|
||||
"maxOutputTokens": 4000,
|
||||
"temperature": 0.7
|
||||
}
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
3. Update the schema validation in `config-manager.js` to validate the new fields:
|
||||
|
||||
```javascript
|
||||
function _validateConfig(config) {
|
||||
// ... existing validation
|
||||
|
||||
// Validate token limits for each role
|
||||
['main', 'research', 'fallback'].forEach(role => {
|
||||
if (config[role]) {
|
||||
// Check if old maxTokens is present and warn about migration
|
||||
if (config[role].maxTokens !== undefined) {
|
||||
console.warn(`Warning: 'maxTokens' in ${role} role is deprecated. Please use 'maxInputTokens' and 'maxOutputTokens' instead.`);
|
||||
}
|
||||
|
||||
// Validate new token limit fields
|
||||
if (config[role].maxInputTokens !== undefined && (!Number.isInteger(config[role].maxInputTokens) || config[role].maxInputTokens <= 0)) {
|
||||
throw new Error(`Invalid maxInputTokens for ${role} role: must be a positive integer`);
|
||||
}
|
||||
|
||||
if (config[role].maxOutputTokens !== undefined && (!Number.isInteger(config[role].maxOutputTokens) || config[role].maxOutputTokens <= 0)) {
|
||||
throw new Error(`Invalid maxOutputTokens for ${role} role: must be a positive integer`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return config;
|
||||
}
|
||||
```
|
||||
|
||||
# Test Strategy:
|
||||
1. Verify documentation is clear and provides migration steps
|
||||
2. Test the validation logic with various config formats
|
||||
3. Test backward compatibility with old config format
|
||||
4. Ensure error messages are helpful when validation fails
|
||||
119
tasks/task_087.txt
Normal file
119
tasks/task_087.txt
Normal file
@@ -0,0 +1,119 @@
|
||||
# Task ID: 87
|
||||
# Title: Implement validation and error handling
|
||||
# Status: pending
|
||||
# Dependencies: 85
|
||||
# Priority: low
|
||||
# Description: Add comprehensive validation and error handling for token limits throughout the system, including helpful error messages and graceful fallbacks.
|
||||
# Details:
|
||||
1. Add validation when loading models in `config-manager.js`:
|
||||
```javascript
|
||||
function _validateModelMap(modelMap) {
|
||||
// Validate each provider's models
|
||||
Object.entries(modelMap).forEach(([provider, models]) => {
|
||||
models.forEach(model => {
|
||||
// Check for required token limit fields
|
||||
if (!model.contextWindowTokens) {
|
||||
console.warn(`Warning: Model ${model.id} from ${provider} is missing contextWindowTokens field`);
|
||||
}
|
||||
if (!model.maxOutputTokens) {
|
||||
console.warn(`Warning: Model ${model.id} from ${provider} is missing maxOutputTokens field`);
|
||||
}
|
||||
});
|
||||
});
|
||||
return modelMap;
|
||||
}
|
||||
```
|
||||
|
||||
2. Add validation when setting up a model in the CLI:
|
||||
```javascript
|
||||
function validateModelConfig(modelConfig, modelCapabilities) {
|
||||
const issues = [];
|
||||
|
||||
// Check if input tokens exceed model's context window
|
||||
if (modelConfig.maxInputTokens > modelCapabilities.contextWindowTokens) {
|
||||
issues.push(`maxInputTokens (${modelConfig.maxInputTokens}) exceeds model's context window (${modelCapabilities.contextWindowTokens})`);
|
||||
}
|
||||
|
||||
// Check if output tokens exceed model's maximum
|
||||
if (modelConfig.maxOutputTokens > modelCapabilities.maxOutputTokens) {
|
||||
issues.push(`maxOutputTokens (${modelConfig.maxOutputTokens}) exceeds model's maximum output tokens (${modelCapabilities.maxOutputTokens})`);
|
||||
}
|
||||
|
||||
// Check if combined tokens exceed context window
|
||||
if (modelConfig.maxInputTokens + modelConfig.maxOutputTokens > modelCapabilities.contextWindowTokens) {
|
||||
issues.push(`Combined maxInputTokens and maxOutputTokens (${modelConfig.maxInputTokens + modelConfig.maxOutputTokens}) exceeds model's context window (${modelCapabilities.contextWindowTokens})`);
|
||||
}
|
||||
|
||||
return issues;
|
||||
}
|
||||
```
|
||||
|
||||
3. Add graceful fallbacks in `ai-services-unified.js`:
|
||||
```javascript
|
||||
// Fallback for missing token limits
|
||||
if (!roleParams.maxInputTokens) {
|
||||
console.warn(`Warning: maxInputTokens not specified for role '${currentRole}'. Using default value.`);
|
||||
roleParams.maxInputTokens = 8000; // Reasonable default
|
||||
}
|
||||
|
||||
if (!roleParams.maxOutputTokens) {
|
||||
console.warn(`Warning: maxOutputTokens not specified for role '${currentRole}'. Using default value.`);
|
||||
roleParams.maxOutputTokens = 2000; // Reasonable default
|
||||
}
|
||||
|
||||
// Fallback for missing model capabilities
|
||||
if (!modelCapabilities.contextWindowTokens) {
|
||||
console.warn(`Warning: contextWindowTokens not specified for model ${modelId}. Using conservative estimate.`);
|
||||
modelCapabilities.contextWindowTokens = roleParams.maxInputTokens + roleParams.maxOutputTokens;
|
||||
}
|
||||
|
||||
if (!modelCapabilities.maxOutputTokens) {
|
||||
console.warn(`Warning: maxOutputTokens not specified for model ${modelId}. Using role configuration.`);
|
||||
modelCapabilities.maxOutputTokens = roleParams.maxOutputTokens;
|
||||
}
|
||||
```
|
||||
|
||||
4. Add detailed logging for token usage:
|
||||
```javascript
|
||||
function logTokenUsage(provider, modelId, inputTokens, outputTokens, role) {
|
||||
const inputCost = calculateTokenCost(provider, modelId, 'input', inputTokens);
|
||||
const outputCost = calculateTokenCost(provider, modelId, 'output', outputTokens);
|
||||
|
||||
console.info(`Token usage for ${role} role with ${provider}/${modelId}:`);
|
||||
console.info(`- Input: ${inputTokens.toLocaleString()} tokens ($${inputCost.toFixed(6)})`);
|
||||
console.info(`- Output: ${outputTokens.toLocaleString()} tokens ($${outputCost.toFixed(6)})`);
|
||||
console.info(`- Total cost: $${(inputCost + outputCost).toFixed(6)}`);
|
||||
console.info(`- Available output tokens: ${availableOutputTokens.toLocaleString()}`);
|
||||
}
|
||||
```
|
||||
|
||||
5. Add a helper function to suggest configuration improvements:
|
||||
```javascript
|
||||
function suggestTokenConfigImprovements(roleParams, modelCapabilities, promptTokens) {
|
||||
const suggestions = [];
|
||||
|
||||
// If prompt is using less than 50% of allowed input
|
||||
if (promptTokens < roleParams.maxInputTokens * 0.5) {
|
||||
suggestions.push(`Consider reducing maxInputTokens from ${roleParams.maxInputTokens} to save on potential costs`);
|
||||
}
|
||||
|
||||
// If output tokens are very limited due to large input
|
||||
const availableOutput = Math.min(
|
||||
roleParams.maxOutputTokens,
|
||||
modelCapabilities.contextWindowTokens - promptTokens
|
||||
);
|
||||
|
||||
if (availableOutput < roleParams.maxOutputTokens * 0.5) {
|
||||
suggestions.push(`Available output tokens (${availableOutput}) are significantly less than configured maxOutputTokens (${roleParams.maxOutputTokens}) due to large input`);
|
||||
}
|
||||
|
||||
return suggestions;
|
||||
}
|
||||
```
|
||||
|
||||
# Test Strategy:
|
||||
1. Test validation functions with valid and invalid configurations
|
||||
2. Verify fallback behavior works correctly when configuration is missing
|
||||
3. Test error messages are clear and actionable
|
||||
4. Test logging functions provide useful information
|
||||
5. Verify suggestion logic provides helpful recommendations
|
||||
@@ -1,12 +1,4 @@
|
||||
{
|
||||
"meta": {
|
||||
"projectName": "Your Project Name",
|
||||
"version": "1.0.0",
|
||||
"source": "scripts/prd.txt",
|
||||
"description": "Tasks generated from PRD",
|
||||
"totalTasksGenerated": 20,
|
||||
"tasksIncluded": 20
|
||||
},
|
||||
"tasks": [
|
||||
{
|
||||
"id": 1,
|
||||
@@ -5228,6 +5220,92 @@
|
||||
"testStrategy": "Test dashboard visualizations with various usage patterns. Verify recommendations are relevant and helpful based on simulated usage data. Conduct usability testing to ensure insights are presented in an understandable way. Test with different user profiles to ensure recommendations are appropriately personalized."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 82,
|
||||
"title": "Update supported-models.json with token limit fields",
|
||||
"description": "Modify the supported-models.json file to include contextWindowTokens and maxOutputTokens fields for each model, replacing the ambiguous max_tokens field.",
|
||||
"details": "For each model entry in supported-models.json:\n1. Add `contextWindowTokens` field representing the total context window (input + output tokens)\n2. Add `maxOutputTokens` field representing the maximum tokens the model can generate\n3. Remove or deprecate the ambiguous `max_tokens` field if present\n\nResearch and populate accurate values for each model from official documentation:\n- For OpenAI models (e.g., gpt-4o): contextWindowTokens=128000, maxOutputTokens=16384\n- For Anthropic models (e.g., Claude 3.7): contextWindowTokens=200000, maxOutputTokens=8192\n- For other providers, find official documentation or use reasonable defaults\n\nExample entry:\n```json\n{\n \"id\": \"claude-3-7-sonnet-20250219\",\n \"swe_score\": 0.623,\n \"cost_per_1m_tokens\": { \"input\": 3.0, \"output\": 15.0 },\n \"allowed_roles\": [\"main\", \"fallback\"],\n \"contextWindowTokens\": 200000,\n \"maxOutputTokens\": 8192\n}\n```",
|
||||
"testStrategy": "1. Validate JSON syntax after changes\n2. Verify all models have the new fields with reasonable values\n3. Check that the values align with official documentation from each provider\n4. Ensure backward compatibility by maintaining any fields other systems might depend on",
|
||||
"priority": "high",
|
||||
"dependencies": [],
|
||||
"status": "pending",
|
||||
"subtasks": []
|
||||
},
|
||||
{
|
||||
"id": 83,
|
||||
"title": "Update config-manager.js defaults and getters",
|
||||
"description": "Modify the config-manager.js module to replace maxTokens with maxInputTokens and maxOutputTokens in the DEFAULTS object and update related getter functions.",
|
||||
"details": "1. Update the `DEFAULTS` object in config-manager.js:\n```javascript\nconst DEFAULTS = {\n // ... existing defaults\n main: {\n // Replace maxTokens with these two fields\n maxInputTokens: 16000, // Example default\n maxOutputTokens: 4000, // Example default\n temperature: 0.7\n // ... other fields\n },\n research: {\n maxInputTokens: 16000,\n maxOutputTokens: 4000,\n temperature: 0.7\n // ... other fields\n },\n fallback: {\n maxInputTokens: 8000,\n maxOutputTokens: 2000,\n temperature: 0.7\n // ... other fields\n }\n // ... rest of DEFAULTS\n};\n```\n\n2. Update `getParametersForRole` function to return the new fields:\n```javascript\nfunction getParametersForRole(role, explicitRoot = null) {\n const config = _getConfig(explicitRoot);\n return {\n maxInputTokens: config[role]?.maxInputTokens,\n maxOutputTokens: config[role]?.maxOutputTokens,\n temperature: config[role]?.temperature\n // ... any other parameters\n };\n}\n```\n\n3. Add a new function to get model capabilities:\n```javascript\nfunction getModelCapabilities(providerName, modelId) {\n const models = MODEL_MAP[providerName?.toLowerCase()];\n const model = models?.find(m => m.id === modelId);\n return {\n contextWindowTokens: model?.contextWindowTokens,\n maxOutputTokens: model?.maxOutputTokens\n };\n}\n```\n\n4. Deprecate or update the role-specific maxTokens getters:\n```javascript\n// Either remove these or update them to return maxInputTokens\nfunction getMainMaxTokens(explicitRoot = null) {\n console.warn('getMainMaxTokens is deprecated. Use getParametersForRole(\"main\") instead.');\n return getParametersForRole(\"main\", explicitRoot).maxInputTokens;\n}\n// Same for getResearchMaxTokens and getFallbackMaxTokens\n```\n\n5. Export the new functions:\n```javascript\nmodule.exports = {\n // ... existing exports\n getParametersForRole,\n getModelCapabilities\n};\n```",
|
||||
"testStrategy": "1. Unit test the updated getParametersForRole function with various configurations\n2. Verify the new getModelCapabilities function returns correct values\n3. Test with both default and custom configurations\n4. Ensure backward compatibility by checking that existing code using the old getters still works (with warnings)",
|
||||
"priority": "high",
|
||||
"dependencies": [
|
||||
82
|
||||
],
|
||||
"status": "pending",
|
||||
"subtasks": [
|
||||
{
|
||||
"id": 1,
|
||||
"title": "Update config-manager.js with specific token limit fields",
|
||||
"description": "Modify the DEFAULTS object in config-manager.js to replace maxTokens with more specific token limit fields (maxInputTokens, maxOutputTokens, maxTotalTokens) and update related getter functions while maintaining backward compatibility.",
|
||||
"dependencies": [],
|
||||
"details": "1. Replace maxTokens in the DEFAULTS object with maxInputTokens, maxOutputTokens, and maxTotalTokens\n2. Update any getter functions that reference maxTokens to handle both old and new configurations\n3. Ensure backward compatibility so existing code using maxTokens continues to work\n4. Update any related documentation or comments to reflect the new token limit fields\n5. Test the changes to verify both new specific token limits and legacy maxTokens usage work correctly",
|
||||
"status": "pending"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 84,
|
||||
"title": "Implement token counting utility",
|
||||
"description": "Create a utility function to count tokens for prompts based on the model being used, primarily using tiktoken for OpenAI and Anthropic models with character-based fallbacks for other providers.",
|
||||
"details": "1. Install the tiktoken package:\n```bash\nnpm install tiktoken\n```\n\n2. Create a new file `scripts/modules/token-counter.js`:\n```javascript\nconst tiktoken = require('tiktoken');\n\n/**\n * Count tokens for a given text and model\n * @param {string} text - The text to count tokens for\n * @param {string} provider - The AI provider (e.g., 'openai', 'anthropic')\n * @param {string} modelId - The model ID\n * @returns {number} - Estimated token count\n */\nfunction countTokens(text, provider, modelId) {\n if (!text) return 0;\n \n // Convert to lowercase for case-insensitive matching\n const providerLower = provider?.toLowerCase();\n \n try {\n // OpenAI models\n if (providerLower === 'openai') {\n // Most OpenAI chat models use cl100k_base encoding\n const encoding = tiktoken.encoding_for_model(modelId) || tiktoken.get_encoding('cl100k_base');\n return encoding.encode(text).length;\n }\n \n // Anthropic models - can use cl100k_base as an approximation\n // or follow Anthropic's guidance\n if (providerLower === 'anthropic') {\n try {\n // Try to use cl100k_base as a reasonable approximation\n const encoding = tiktoken.get_encoding('cl100k_base');\n return encoding.encode(text).length;\n } catch (e) {\n // Fallback to Anthropic's character-based estimation\n return Math.ceil(text.length / 3.5); // ~3.5 chars per token for English\n }\n }\n \n // For other providers, use character-based estimation as fallback\n // Different providers may have different tokenization schemes\n return Math.ceil(text.length / 4); // General fallback estimate\n } catch (error) {\n console.warn(`Token counting error: ${error.message}. Using character-based estimate.`);\n return Math.ceil(text.length / 4); // Fallback if tiktoken fails\n }\n}\n\nmodule.exports = { countTokens };\n```\n\n3. Add tests for the token counter in `tests/token-counter.test.js`:\n```javascript\nconst { countTokens } = require('../scripts/modules/token-counter');\n\ndescribe('Token Counter', () => {\n test('counts tokens for OpenAI models', () => {\n const text = 'Hello, world! This is a test.';\n const count = countTokens(text, 'openai', 'gpt-4');\n expect(count).toBeGreaterThan(0);\n expect(typeof count).toBe('number');\n });\n \n test('counts tokens for Anthropic models', () => {\n const text = 'Hello, world! This is a test.';\n const count = countTokens(text, 'anthropic', 'claude-3-7-sonnet-20250219');\n expect(count).toBeGreaterThan(0);\n expect(typeof count).toBe('number');\n });\n \n test('handles empty text', () => {\n expect(countTokens('', 'openai', 'gpt-4')).toBe(0);\n expect(countTokens(null, 'openai', 'gpt-4')).toBe(0);\n });\n});\n```",
|
||||
"testStrategy": "1. Unit test the countTokens function with various inputs and models\n2. Compare token counts with known examples from OpenAI and Anthropic documentation\n3. Test edge cases: empty strings, very long texts, non-English texts\n4. Test fallback behavior when tiktoken fails or is not applicable",
|
||||
"priority": "high",
|
||||
"dependencies": [
|
||||
82
|
||||
],
|
||||
"status": "pending",
|
||||
"subtasks": []
|
||||
},
|
||||
{
|
||||
"id": 85,
|
||||
"title": "Update ai-services-unified.js for dynamic token limits",
|
||||
"description": "Modify the _unifiedServiceRunner function in ai-services-unified.js to use the new token counting utility and dynamically adjust output token limits based on input length.",
|
||||
"details": "1. Import the token counter in `ai-services-unified.js`:\n```javascript\nconst { countTokens } = require('./token-counter');\nconst { getParametersForRole, getModelCapabilities } = require('./config-manager');\n```\n\n2. Update the `_unifiedServiceRunner` function to implement dynamic token limit adjustment:\n```javascript\nasync function _unifiedServiceRunner({\n serviceType,\n provider,\n modelId,\n systemPrompt,\n prompt,\n temperature,\n currentRole,\n effectiveProjectRoot,\n // ... other parameters\n}) {\n // Get role parameters with new token limits\n const roleParams = getParametersForRole(currentRole, effectiveProjectRoot);\n \n // Get model capabilities\n const modelCapabilities = getModelCapabilities(provider, modelId);\n \n // Count tokens in the prompts\n const systemPromptTokens = countTokens(systemPrompt, provider, modelId);\n const userPromptTokens = countTokens(prompt, provider, modelId);\n const totalPromptTokens = systemPromptTokens + userPromptTokens;\n \n // Validate against input token limits\n if (totalPromptTokens > roleParams.maxInputTokens) {\n throw new Error(\n `Prompt (${totalPromptTokens} tokens) exceeds configured max input tokens (${roleParams.maxInputTokens}) for role '${currentRole}'.`\n );\n }\n \n // Validate against model's absolute context window\n if (modelCapabilities.contextWindowTokens && totalPromptTokens > modelCapabilities.contextWindowTokens) {\n throw new Error(\n `Prompt (${totalPromptTokens} tokens) exceeds model's context window (${modelCapabilities.contextWindowTokens}) for ${modelId}.`\n );\n }\n \n // Calculate available output tokens\n // If model has a combined context window, we need to subtract input tokens\n let availableOutputTokens = roleParams.maxOutputTokens;\n \n // If model has a context window constraint, ensure we don't exceed it\n if (modelCapabilities.contextWindowTokens) {\n const remainingContextTokens = modelCapabilities.contextWindowTokens - totalPromptTokens;\n availableOutputTokens = Math.min(availableOutputTokens, remainingContextTokens);\n }\n \n // Also respect the model's absolute max output limit\n if (modelCapabilities.maxOutputTokens) {\n availableOutputTokens = Math.min(availableOutputTokens, modelCapabilities.maxOutputTokens);\n }\n \n // Prepare API call parameters\n const callParams = {\n apiKey,\n modelId,\n maxTokens: availableOutputTokens, // Use dynamically calculated output limit\n temperature: roleParams.temperature,\n messages,\n baseUrl,\n ...(serviceType === 'generateObject' && { schema, objectName }),\n ...restApiParams\n };\n \n // Log token usage information\n console.debug(`Token usage: ${totalPromptTokens} input tokens, ${availableOutputTokens} max output tokens`);\n \n // Rest of the function remains the same...\n}\n```\n\n3. Update the error handling to provide clear messages about token limits:\n```javascript\ntry {\n // Existing code...\n} catch (error) {\n if (error.message.includes('tokens')) {\n // Token-related errors should be clearly identified\n console.error(`Token limit error: ${error.message}`);\n }\n throw error;\n}\n```",
|
||||
"testStrategy": "1. Test with prompts of various lengths to verify dynamic adjustment\n2. Test with different models to ensure model-specific limits are respected\n3. Verify error messages are clear when limits are exceeded\n4. Test edge cases: very short prompts, prompts near the limit\n5. Integration test with actual API calls to verify the calculated limits work in practice",
|
||||
"priority": "medium",
|
||||
"dependencies": [
|
||||
83,
|
||||
84
|
||||
],
|
||||
"status": "pending",
|
||||
"subtasks": []
|
||||
},
|
||||
{
|
||||
"id": 86,
|
||||
"title": "Update .taskmasterconfig schema and user guide",
|
||||
"description": "Create a migration guide for users to update their .taskmasterconfig files and document the new token limit configuration options.",
|
||||
"details": "1. Create a migration script or guide for users to update their existing `.taskmasterconfig` files:\n\n```javascript\n// Example migration snippet for .taskmasterconfig\n{\n \"main\": {\n // Before:\n // \"maxTokens\": 16000,\n \n // After:\n \"maxInputTokens\": 16000,\n \"maxOutputTokens\": 4000,\n \"temperature\": 0.7\n },\n \"research\": {\n \"maxInputTokens\": 16000,\n \"maxOutputTokens\": 4000,\n \"temperature\": 0.7\n },\n \"fallback\": {\n \"maxInputTokens\": 8000,\n \"maxOutputTokens\": 2000,\n \"temperature\": 0.7\n }\n}\n```\n\n2. Update the user documentation to explain the new token limit fields:\n\n```markdown\n# Token Limit Configuration\n\nTask Master now provides more granular control over token limits with separate settings for input and output tokens:\n\n- `maxInputTokens`: Maximum number of tokens allowed in the input prompt (system prompt + user prompt)\n- `maxOutputTokens`: Maximum number of tokens the model should generate in its response\n\n## Benefits\n\n- More precise control over token usage\n- Better cost management\n- Reduced likelihood of hitting model context limits\n- Dynamic adjustment to maximize output space based on input length\n\n## Migration from Previous Versions\n\nIf you're upgrading from a previous version, you'll need to update your `.taskmasterconfig` file:\n\n1. Replace the single `maxTokens` field with separate `maxInputTokens` and `maxOutputTokens` fields\n2. Recommended starting values:\n - Set `maxInputTokens` to your previous `maxTokens` value\n - Set `maxOutputTokens` to approximately 1/4 of your model's context window\n\n## Example Configuration\n\n```json\n{\n \"main\": {\n \"maxInputTokens\": 16000,\n \"maxOutputTokens\": 4000,\n \"temperature\": 0.7\n }\n}\n```\n```\n\n3. Update the schema validation in `config-manager.js` to validate the new fields:\n\n```javascript\nfunction _validateConfig(config) {\n // ... existing validation\n \n // Validate token limits for each role\n ['main', 'research', 'fallback'].forEach(role => {\n if (config[role]) {\n // Check if old maxTokens is present and warn about migration\n if (config[role].maxTokens !== undefined) {\n console.warn(`Warning: 'maxTokens' in ${role} role is deprecated. Please use 'maxInputTokens' and 'maxOutputTokens' instead.`);\n }\n \n // Validate new token limit fields\n if (config[role].maxInputTokens !== undefined && (!Number.isInteger(config[role].maxInputTokens) || config[role].maxInputTokens <= 0)) {\n throw new Error(`Invalid maxInputTokens for ${role} role: must be a positive integer`);\n }\n \n if (config[role].maxOutputTokens !== undefined && (!Number.isInteger(config[role].maxOutputTokens) || config[role].maxOutputTokens <= 0)) {\n throw new Error(`Invalid maxOutputTokens for ${role} role: must be a positive integer`);\n }\n }\n });\n \n return config;\n}\n```",
|
||||
"testStrategy": "1. Verify documentation is clear and provides migration steps\n2. Test the validation logic with various config formats\n3. Test backward compatibility with old config format\n4. Ensure error messages are helpful when validation fails",
|
||||
"priority": "medium",
|
||||
"dependencies": [
|
||||
83
|
||||
],
|
||||
"status": "pending",
|
||||
"subtasks": []
|
||||
},
|
||||
{
|
||||
"id": 87,
|
||||
"title": "Implement validation and error handling",
|
||||
"description": "Add comprehensive validation and error handling for token limits throughout the system, including helpful error messages and graceful fallbacks.",
|
||||
"details": "1. Add validation when loading models in `config-manager.js`:\n```javascript\nfunction _validateModelMap(modelMap) {\n // Validate each provider's models\n Object.entries(modelMap).forEach(([provider, models]) => {\n models.forEach(model => {\n // Check for required token limit fields\n if (!model.contextWindowTokens) {\n console.warn(`Warning: Model ${model.id} from ${provider} is missing contextWindowTokens field`);\n }\n if (!model.maxOutputTokens) {\n console.warn(`Warning: Model ${model.id} from ${provider} is missing maxOutputTokens field`);\n }\n });\n });\n return modelMap;\n}\n```\n\n2. Add validation when setting up a model in the CLI:\n```javascript\nfunction validateModelConfig(modelConfig, modelCapabilities) {\n const issues = [];\n \n // Check if input tokens exceed model's context window\n if (modelConfig.maxInputTokens > modelCapabilities.contextWindowTokens) {\n issues.push(`maxInputTokens (${modelConfig.maxInputTokens}) exceeds model's context window (${modelCapabilities.contextWindowTokens})`);\n }\n \n // Check if output tokens exceed model's maximum\n if (modelConfig.maxOutputTokens > modelCapabilities.maxOutputTokens) {\n issues.push(`maxOutputTokens (${modelConfig.maxOutputTokens}) exceeds model's maximum output tokens (${modelCapabilities.maxOutputTokens})`);\n }\n \n // Check if combined tokens exceed context window\n if (modelConfig.maxInputTokens + modelConfig.maxOutputTokens > modelCapabilities.contextWindowTokens) {\n issues.push(`Combined maxInputTokens and maxOutputTokens (${modelConfig.maxInputTokens + modelConfig.maxOutputTokens}) exceeds model's context window (${modelCapabilities.contextWindowTokens})`);\n }\n \n return issues;\n}\n```\n\n3. Add graceful fallbacks in `ai-services-unified.js`:\n```javascript\n// Fallback for missing token limits\nif (!roleParams.maxInputTokens) {\n console.warn(`Warning: maxInputTokens not specified for role '${currentRole}'. Using default value.`);\n roleParams.maxInputTokens = 8000; // Reasonable default\n}\n\nif (!roleParams.maxOutputTokens) {\n console.warn(`Warning: maxOutputTokens not specified for role '${currentRole}'. Using default value.`);\n roleParams.maxOutputTokens = 2000; // Reasonable default\n}\n\n// Fallback for missing model capabilities\nif (!modelCapabilities.contextWindowTokens) {\n console.warn(`Warning: contextWindowTokens not specified for model ${modelId}. Using conservative estimate.`);\n modelCapabilities.contextWindowTokens = roleParams.maxInputTokens + roleParams.maxOutputTokens;\n}\n\nif (!modelCapabilities.maxOutputTokens) {\n console.warn(`Warning: maxOutputTokens not specified for model ${modelId}. Using role configuration.`);\n modelCapabilities.maxOutputTokens = roleParams.maxOutputTokens;\n}\n```\n\n4. Add detailed logging for token usage:\n```javascript\nfunction logTokenUsage(provider, modelId, inputTokens, outputTokens, role) {\n const inputCost = calculateTokenCost(provider, modelId, 'input', inputTokens);\n const outputCost = calculateTokenCost(provider, modelId, 'output', outputTokens);\n \n console.info(`Token usage for ${role} role with ${provider}/${modelId}:`);\n console.info(`- Input: ${inputTokens.toLocaleString()} tokens ($${inputCost.toFixed(6)})`);\n console.info(`- Output: ${outputTokens.toLocaleString()} tokens ($${outputCost.toFixed(6)})`);\n console.info(`- Total cost: $${(inputCost + outputCost).toFixed(6)}`);\n console.info(`- Available output tokens: ${availableOutputTokens.toLocaleString()}`);\n}\n```\n\n5. Add a helper function to suggest configuration improvements:\n```javascript\nfunction suggestTokenConfigImprovements(roleParams, modelCapabilities, promptTokens) {\n const suggestions = [];\n \n // If prompt is using less than 50% of allowed input\n if (promptTokens < roleParams.maxInputTokens * 0.5) {\n suggestions.push(`Consider reducing maxInputTokens from ${roleParams.maxInputTokens} to save on potential costs`);\n }\n \n // If output tokens are very limited due to large input\n const availableOutput = Math.min(\n roleParams.maxOutputTokens,\n modelCapabilities.contextWindowTokens - promptTokens\n );\n \n if (availableOutput < roleParams.maxOutputTokens * 0.5) {\n suggestions.push(`Available output tokens (${availableOutput}) are significantly less than configured maxOutputTokens (${roleParams.maxOutputTokens}) due to large input`);\n }\n \n return suggestions;\n}\n```",
|
||||
"testStrategy": "1. Test validation functions with valid and invalid configurations\n2. Verify fallback behavior works correctly when configuration is missing\n3. Test error messages are clear and actionable\n4. Test logging functions provide useful information\n5. Verify suggestion logic provides helpful recommendations",
|
||||
"priority": "low",
|
||||
"dependencies": [
|
||||
85
|
||||
],
|
||||
"status": "pending",
|
||||
"subtasks": []
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user