vxcontrol/pentagi · error
failed to check flow status: %w
Error message
failed to check flow status: %w
What it means
After parsing the wait arguments, the tool calls db.GetFlowTasks(flowID) to inspect the flow's task list and that database query failed. The error is wrapped so callers can match the underlying GORM/SQL error (connection loss, cancelled context, missing table). Without the task list the tool cannot report flow status.
Source
Thrown at backend/pkg/tools/flow_manager.go:558
}
func (t *waitFlowCompletionTool) Handle(ctx context.Context, name string, args json.RawMessage) (string, error) {
var action WaitFlowCompletionAction
if err := json.Unmarshal(args, &action); err != nil {
return "", fmt.Errorf("failed to parse %s args: %w", WaitFlowCompletionToolName, err)
}
timeout := time.Duration(action.Timeout.Int64()) * time.Second
switch {
case timeout <= 0:
timeout = waitFlowDefaultTimeout
case timeout > waitFlowMaxTimeout:
timeout = waitFlowMaxTimeout
}
tasks, err := t.db.GetFlowTasks(ctx, t.flowID)
if err != nil {
return "", fmt.Errorf("failed to check flow status: %w", err)
}
if len(tasks) == 0 {
return fmt.Sprintf(
"The automation has not been created yet — no tasks exist. "+
"Use %s to submit the first task description and start the automation.",
SubmitFlowInputToolName), nil
}
isRunning := false
for _, task := range tasks {
if task.Status == database.TaskStatusRunning {
isRunning = true
break
}
}
if !isRunning {View on GitHub (pinned to ea665308ba)
Solutions
- Check PostgreSQL availability and connectivity (docker compose ps, logs of the db service) and restart the DB if it crashed.
- Verify DB credentials and connection settings in the environment (.env: POSTGRES_* variables).
- Run the migrations (they apply at startup via goose) and confirm the flows/tasks tables exist.
- Retry the tool call once the database is healthy; if the wrapped error is context.Canceled, re-issue the request in a live session.
Example fix
// before: db unreachable // after: ensure db is up then retry $ docker compose up -d postgres $ docker compose logs pentagi # confirm reconnection
Defensive patterns
Strategy: retry
Validate before calling
// Pre-check DB reachability before invoking flow tools
await fetch(`${baseUrl}/api/health`).then(r => { if (!r.ok) throw new Error('backend unhealthy'); }); Try / catch
try {
await tool.call('wait_flow_completion', { timeout: 60 });
} catch (err) {
if (String(err).includes('failed to check flow status')) {
await sleep(2000); // transient DB issue — retry with backoff
}
} Prevention
- Ensure PostgreSQL is up and healthy before long agent runs
- Keep DB credentials/connection env vars correct
- Verify migrations ran at startup
- Avoid cancelling the session context while flow tools are in flight
When it happens
Trigger: Calling wait_flow_completion (or stop_flow, which shares this message) while the PostgreSQL connection is down, the context is cancelled, the flows/tasks tables are missing, or GetFlowTasks returns any store-level error for the tool's bound flowID.
Common situations: Database container restarted or unreachable during a long agent run; DB credentials/network misconfigured in the environment; migration not applied so tables are absent; context cancelled by an upstream shutdown racing the query.
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 get flow subtasks: %w
- failed to get subtasks: %w
- failed to get subtask msg logs: %w
- failed to put terminal log (stdin): %w
- failed to set flow %d status: %w
AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01).
Data as JSON: /api/errors/a9efca24daa9e8cf.
Report an issue: GitHub.