vxcontrol/pentagi · error
failed to get flow tasks: %w
Error message
failed to get flow tasks: %w
What it means
buildSummary fetches the flow's tasks via the database (GetFlowTasks) and wraps any failure with this message. This is a backend/data-access error — the tool arguments were fine, but the task list could not be loaded, so no status summary can be produced.
Source
Thrown at backend/pkg/tools/flow_manager.go:94
case FlowStatusDetailSummary:
return t.buildSummary(ctx, verbose)
case FlowStatusDetailTasks:
return t.buildTasksList(ctx, verbose)
case FlowStatusDetailSubtasks:
return t.buildSubtasksList(ctx, action.TaskID.PtrInt64(), verbose)
case FlowStatusDetailRunning:
return t.buildRunningInfo(ctx, verbose)
case FlowStatusDetailPlanned:
return t.buildPlannedList(ctx, action.TaskID.PtrInt64(), verbose)
default:
return "", fmt.Errorf("unknown detail level %q; use one of: summary, tasks, subtasks, running, planned", action.Detail)
}
}
func (t *flowStatusTool) buildSummary(ctx context.Context, verbose bool) (string, error) {
tasks, err := t.db.GetFlowTasks(ctx, t.flowID)
if err != nil {
return "", fmt.Errorf("failed to get flow tasks: %w", err)
}
subtasks, err := t.db.GetFlowSubtasks(ctx, t.flowID)
if err != nil {
return "", fmt.Errorf("failed to get flow subtasks: %w", err)
}
taskCounts := map[string]int{"created": 0, "running": 0, "waiting": 0, "finished": 0, "failed": 0}
var activeTask *database.Task
for i, task := range tasks {
taskCounts[string(task.Status)]++
if task.Status == database.TaskStatusRunning || task.Status == database.TaskStatusWaiting {
activeTask = &tasks[i]
}
}
stCounts := map[string]int{"created": 0, "running": 0, "waiting": 0, "finished": 0, "failed": 0}
var activeST *database.SubtaskView on GitHub (pinned to ea665308ba)
Solutions
- Check the wrapped cause in the error message and the backend logs for the underlying DB error.
- Verify PostgreSQL is reachable and healthy (docker compose ps, connection env vars: DB host/port/user/password).
- Confirm migrations ran (goose up) so the flow task tables exist.
- Retry the tool call if the failure was transient (context timeout / connection reset).
- Verify the flow ID still exists — the flow or its tasks may have been deleted.
Example fix
// .env before DATABASE_HOST=localhost DATABASE_PORT=5433 // .env after (match the running postgres service) DATABASE_HOST=localhost DATABASE_PORT=5432
Defensive patterns
Strategy: retry
Validate before calling
func dbReachable(db *sql.DB) error {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()
return db.PingContext(ctx)
} Try / catch
var out string
var lastErr error
for attempt := 0; attempt < 3; attempt++ {
out, lastErr = tool.Handle(ctx, "get_flow_status", args)
if lastErr == nil { return out, nil }
if !strings.Contains(lastErr.Error(), "failed to get flow") { break }
time.Sleep(time.Duration(1<<attempt) * 100 * time.Millisecond)
}
return lastErr Prevention
- Monitor PostgreSQL health before invoking flow tools (docker compose ps / pg_isready)
- Verify DB env vars and that goose migrations have run
- Set generous context timeouts for large flows to avoid cancellation mid-query
- Retry transient DB errors with exponential backoff
- Check the flow still exists if deletions happen concurrently
When it happens
Trigger: GetFlowTasks returns an error: database connection refused, context canceled (flow request timed out), the flows/tasks table missing or the flow row deleted mid-query, or a Postgres error (deadlock, OOM, disk full).
Common situations: PostgreSQL container down or restarting during local Docker Compose runs; wrong DB credentials in .env; migration not applied so tables are absent; context deadline exceeded on very large flows; transient network blip between backend and DB.
Understand the failure class
Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.
Related errors
- failed to create flow in DB: %w
- failed to set flow %d status: %w
- failed to delete assistant %d: %w
- failed to rename flow %d: %w
- failed to update flow provider in DB: %w
AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01).
Data as JSON: /api/errors/df384c823ba88b49.
Report an issue: GitHub.