{"record":{"id":"9f74a4e1dc15d01e","repo":"vxcontrol/pentagi","slug":"failed-to-generate-subtasks-for-task-d-w","errorCode":null,"errorMessage":"failed to generate subtasks for task %d: %w","messagePattern":"failed to generate subtasks for task (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/controller/subtasks.go","lineNumber":74,"sourceCode":"\t\tst, err := LoadSubtaskWorker(ctx, subtask, stc.taskCtx, updater)\n\t\tif err != nil {\n\t\t\tif errors.Is(err, ErrNothingToLoad) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\treturn fmt.Errorf(\"failed to create subtask worker: %w\", err)\n\t\t}\n\n\t\tstc.subtasks[subtask.ID] = st\n\t}\n\n\treturn nil\n}\n\nfunc (stc *subtaskController) GenerateSubtasks(ctx context.Context) error {\n\tplan, err := stc.taskCtx.Provider.GenerateSubtasks(ctx, stc.taskCtx.TaskID)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to generate subtasks for task %d: %w\", stc.taskCtx.TaskID, err)\n\t}\n\n\tif len(plan) == 0 {\n\t\treturn fmt.Errorf(\"no subtasks generated for task %d\", stc.taskCtx.TaskID)\n\t}\n\n\t// TODO: change it to insert subtasks in transaction\n\tfor _, info := range plan {\n\t\t_, err := stc.taskCtx.DB.CreateSubtask(ctx, database.CreateSubtaskParams{\n\t\t\tStatus:      database.SubtaskStatusCreated,\n\t\t\tTaskID:      stc.taskCtx.TaskID,\n\t\t\tTitle:       info.Title,\n\t\t\tDescription: info.Description,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to create subtask for task %d: %w\", stc.taskCtx.TaskID, err)\n\t\t}\n\t}","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/controller/subtasks.go#L56-L92","documentation":"Wraps the error from Provider.GenerateSubtasks when the LLM-backed provider fails to produce a subtask plan for the task. The provider call (LLM request, chain setup) errored, so no plan was returned and the task cannot progress. The taskID identifies which task's plan generation failed.","triggerScenarios":"subtaskController.GenerateSubtasks calls stc.taskCtx.Provider.GenerateSubtasks(ctx, stc.taskCtx.TaskID) and the provider returns an error — LLM API auth failure, rate limit, timeout, malformed model response, or unavailable provider.","commonSituations":"Expired/invalid LLM API key in env or settings; provider outage or 429 rate limiting; model returns a response that fails plan parsing; network egress blocked in a firewalled deployment; context deadline exceeded on a very slow model.","solutions":["Check the wrapped error: if it's an HTTP/auth error from the LLM provider, fix the API key and provider config in Settings or env.","Retry — transient 429/5xx from the LLM provider usually clears; add backoff.","Verify the configured provider/model is available (provider health check or a test request via ftester).","Increase the context timeout or switch to a faster/more reliable model if deadlines are being exceeded.","Ensure the task description/prompt is valid — malformed input can make the model return unparseable plans."],"exampleFix":"// before: assume plan generation always succeeds\nplan, err := provider.GenerateSubtasks(ctx, taskID)\nif err != nil { return err }\n// after: retry transient failures\nvar plan []providers.SubtaskInfo\nerr = retry.Do(func() error {\n    plan, err = provider.GenerateSubtasks(ctx, taskID)\n    return err\n}, retry.Attempts(3), retry.DelayType(retry.BackOffDelay))","handlingStrategy":"retry","validationCode":"// verify provider availability before generating\nif !provider.IsAvailable() {\n    return fmt.Errorf(\"LLM provider not configured\")\n}\nif ctx.Err() != nil { return ctx.Err() }","typeGuard":"func isRetryableLLMError(err error) bool {\n    var httpErr *HTTPError\n    if errors.As(err, &httpErr) {\n        return httpErr.StatusCode == 429 || httpErr.StatusCode >= 500\n    }\n    return errors.Is(err, context.DeadlineExceeded)\n}","tryCatchPattern":"if err := stc.GenerateSubtasks(ctx); err != nil {\n    if isRetryableLLMError(err) {\n        time.Sleep(backoff)\n        return stc.GenerateSubtasks(ctx)\n    }\n    return fmt.Errorf(\"plan generation failed permanently: %w\", err)\n}","preventionTips":["Validate LLM API keys at startup and in Settings before creating flows.","Configure per-provider rate limits and timeouts to match the provider's quota.","Keep at least one fallback LLM provider configured.","Test plan generation with cmd/ftester before production rollout of a new provider."],"tags":["llm","provider","subtask-generation","network"],"backgroundTag":"llm-provider-request-failed","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}