vxcontrol/pentagi · error
failed to create flow tool call log: %w
Error message
failed to create flow tool call log: %w
What it means
Sixth step of newFlowProviderWorkers: the tool call log worker is created via cnts.tclc.NewFlowToolCallLog(ctx, flowID, pub). An error wrapped with this message aborts flow startup, because agent tool-call events could not be recorded persistently.
Source
Thrown at backend/pkg/controller/flow.go:1194
slw, err := cnts.slc.NewFlowSearchLog(ctx, flowID, pub)
if err != nil {
return nil, fmt.Errorf("failed to create flow search log: %w", err)
}
tlw, err := cnts.tlc.NewFlowTermLog(ctx, flowID, pub)
if err != nil {
return nil, fmt.Errorf("failed to create flow term log: %w", err)
}
vslw, err := cnts.vslc.NewFlowVectorStoreLog(ctx, flowID, pub)
if err != nil {
return nil, fmt.Errorf("failed to create flow vector store log: %w", err)
}
tclw, err := cnts.tclc.NewFlowToolCallLog(ctx, flowID, pub)
if err != nil {
return nil, fmt.Errorf("failed to create flow tool call log: %w", err)
}
sw, err := cnts.sc.NewFlowScreenshot(ctx, flowID, pub)
if err != nil {
return nil, fmt.Errorf("failed to create flow screenshot: %w", err)
}
return &flowProviderWorkers{
mlw: mlw,
alw: alw,
slw: slw,
tlw: tlw,
vslw: vslw,
tclw: tclw,
sw: sw,
}, nil
}
View on GitHub (pinned to ea665308ba)
Solutions
- Inspect the wrapped error and Postgres logs for the failing statement
- Run pending migrations so the tool-call-log schema exists
- Increase DB pool size or start flows with less concurrency
- Retry flow creation once DB health is confirmed
Example fix
// before: one slow step eats the whole startup budget
// (ctx shared, no deadline management)
tclw, err := cnts.tclc.NewFlowToolCallLog(ctx, flowID, pub)
// after: give worker creation its own deadline
wctx, cancel := context.WithTimeout(context.WithoutCancel(ctx), 30*time.Second)
defer cancel()
tclw, err = cnts.tclc.NewFlowToolCallLog(wctx, flowID, pub)
if err != nil {
return nil, fmt.Errorf("failed to create flow tool call log (flow=%d): %w", flowID, err)
} Defensive patterns
Strategy: retry
Validate before calling
var exists int
if err := db.QueryRowContext(ctx, `SELECT COUNT(1) FROM flows WHERE id=$1`, flowID).Scan(&exists); err != nil || exists == 0 {
return fmt.Errorf("flow %d gone; cannot create tool call log", flowID)
} Type guard
func hasValidFlowID(flowID int64) bool { return flowID > 0 } Try / catch
tclw, err := cnts.tclc.NewFlowToolCallLog(ctx, flowID, pub)
if err != nil {
if isTransientDBError(err) { /* retry with exponential backoff */ }
return nil, fmt.Errorf("failed to create flow tool call log (flow=%d): %w", flowID, err)
} Prevention
- Raise the DB connection pool limit if many flows start simultaneously
- Run migrations on every deploy
- Inspect the wrapped cause before assuming the flow is unrecoverable
- Use context.WithTimeout per step so earlier slow steps do not exhaust the budget
When it happens
Trigger: NewFlowToolCallLog fails during flow startup — DB error creating the tool-call log for this flow, invalid/deleted flowID, or context cancelled during the sequential worker-creation chain.
Common situations: PostgreSQL connection pool exhausted during many simultaneous flow starts; tool_call_logs table missing due to skipped migration; ctx deadline already exceeded after earlier slow steps; concurrent flow deletion.
Related errors
- failed to create flow agent log: %w
- failed to create flow msg log: %w
- failed to create flow search log: %w
- failed to create flow term log: %w
- failed to create flow vector store log: %w
AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01).
Data as JSON: /api/errors/e8bc159eeb8dd878.
Report an issue: GitHub.