vxcontrol/pentagi · error
failed to create flow worker: %w
Error message
failed to create flow worker: %w
What it means
CreateFlow wraps a failure of LoadFlowWorker (which assembles flowProviderWorkers and spins up the worker) with this message. The flow row may have been created in the DB, but the in-memory worker could not be constructed, so no worker is registered in fc.flows.
Source
Thrown at backend/pkg/controller/flows.go:189
db: fc.db,
cfg: fc.cfg,
docker: fc.docker,
provs: fc.provs,
subs: fc.subs,
flowProviderControllers: flowProviderControllers{
mlc: fc.mlc,
aslc: fc.aslc,
alc: fc.alc,
slc: fc.slc,
tlc: fc.tlc,
vslc: fc.vslc,
tclc: fc.tclc,
sc: fc.sc,
},
},
})
if err != nil {
return nil, fmt.Errorf("failed to create flow worker: %w", err)
}
fc.flows[fw.GetFlowID()] = fw
return fw, nil
}
func (fc *flowController) CreateAssistant(
ctx context.Context,
userID int64,
flowID int64,
input string,
useAgents bool,
prvname provider.ProviderName,
prvtype provider.ProviderType,
functions *tools.Functions,
resources []database.UserResource,
) (AssistantWorker, error) {View on GitHub (pinned to ea665308ba)
Solutions
- Check the wrapped cause from LoadFlowWorker logs to find which component failed.
- Delete or clean up the orphaned flow row if the worker cannot be created, then retry CreateFlow.
- Verify all storage backends (DB, screenshot store, vector store) are healthy.
- Reduce creation concurrency or scale the DB connection pool if under load.
Example fix
// before
fw, err := LoadFlowWorker(ctx, flow, flowWorkerCtx{...})
if err != nil {
return nil, fmt.Errorf("failed to create flow worker: %w", err)
}
// after
fw, err := LoadFlowWorker(ctx, flow, flowWorkerCtx{...})
if err != nil {
_ = fc.db.DeleteFlow(ctx, flow.GetFlowID()) // avoid orphaned flow rows
return nil, fmt.Errorf("failed to create flow worker: %w", err)
} Defensive patterns
Strategy: try-catch
Validate before calling
// ensure backing stores are healthy before creating flows
if err := db.PingContext(ctx); err != nil { /* abort flow creation */ }
// storage/vector/screenshot services health-checked at boot Type guard
func isCreateWorkerError(err error) bool {
return err != nil && strings.Contains(err.Error(), "failed to create flow worker")
} Try / catch
fw, err := LoadFlowWorker(ctx, flow, flowWorkerCtx{...})
if err != nil {
// roll back the persisted flow row to avoid orphans
_ = fc.db.DeleteFlow(ctx, flow.GetFlowID())
return nil, fmt.Errorf("failed to create flow worker: %w", err)
} Prevention
- Health-check all worker dependencies (DB, screenshot store, vector store) before accepting flow creation.
- Roll back the DB flow row when worker creation fails.
- Unwrap and log the root cause to identify the failing component quickly.
- Limit concurrent flow creation to avoid resource exhaustion.
When it happens
Trigger: Calling CreateFlow when any component of flowWorkerCtx fails to initialize its worker — e.g., any of the log fetchers (msg/agent/search/term/vector-store/tool-call/screenshot) errors for the freshly created flowID.
Common situations: DB degraded right after flow insert; storage components misconfigured (screenshots/vector store); resource exhaustion (goroutines/connections) under heavy flow creation load.
Related errors
- failed to create flow in DB: %w
- failed to get flow msg log: %w
- failed to get flow search log: %w
- failed to get flow term log: %w
- failed to get flow vector store log: %w
AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01).
Data as JSON: /api/errors/cc7c6ea8fadf92c2.
Report an issue: GitHub.