vxcontrol/pentagi · error
failed to generate subtasks for task %d: %w
Error message
failed to generate subtasks for task %d: %w
What it means
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.
Source
Thrown at backend/pkg/controller/subtasks.go:74
st, err := LoadSubtaskWorker(ctx, subtask, stc.taskCtx, updater)
if err != nil {
if errors.Is(err, ErrNothingToLoad) {
continue
}
return fmt.Errorf("failed to create subtask worker: %w", err)
}
stc.subtasks[subtask.ID] = st
}
return nil
}
func (stc *subtaskController) GenerateSubtasks(ctx context.Context) error {
plan, err := stc.taskCtx.Provider.GenerateSubtasks(ctx, stc.taskCtx.TaskID)
if err != nil {
return fmt.Errorf("failed to generate subtasks for task %d: %w", stc.taskCtx.TaskID, err)
}
if len(plan) == 0 {
return fmt.Errorf("no subtasks generated for task %d", stc.taskCtx.TaskID)
}
// TODO: change it to insert subtasks in transaction
for _, info := range plan {
_, err := stc.taskCtx.DB.CreateSubtask(ctx, database.CreateSubtaskParams{
Status: database.SubtaskStatusCreated,
TaskID: stc.taskCtx.TaskID,
Title: info.Title,
Description: info.Description,
})
if err != nil {
return fmt.Errorf("failed to create subtask for task %d: %w", stc.taskCtx.TaskID, err)
}
}View on GitHub (pinned to ea665308ba)
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.
Example fix
// before: assume plan generation always succeeds
plan, err := provider.GenerateSubtasks(ctx, taskID)
if err != nil { return err }
// after: retry transient failures
var plan []providers.SubtaskInfo
err = retry.Do(func() error {
plan, err = provider.GenerateSubtasks(ctx, taskID)
return err
}, retry.Attempts(3), retry.DelayType(retry.BackOffDelay)) Defensive patterns
Strategy: retry
Validate before calling
// verify provider availability before generating
if !provider.IsAvailable() {
return fmt.Errorf("LLM provider not configured")
}
if ctx.Err() != nil { return ctx.Err() } Type guard
func isRetryableLLMError(err error) bool {
var httpErr *HTTPError
if errors.As(err, &httpErr) {
return httpErr.StatusCode == 429 || httpErr.StatusCode >= 500
}
return errors.Is(err, context.DeadlineExceeded)
} Try / catch
if err := stc.GenerateSubtasks(ctx); err != nil {
if isRetryableLLMError(err) {
time.Sleep(backoff)
return stc.GenerateSubtasks(ctx)
}
return fmt.Errorf("plan generation failed permanently: %w", err)
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- failed to test provider: %w
- failed to switch provider: %w
- failed to perform agent chain for subtask %d: %w
- no subtasks generated for task %d
- failed to refine subtasks for task %d: %w
AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01).
Data as JSON: /api/errors/9f74a4e1dc15d01e.
Report an issue: GitHub.