vxcontrol/pentagi · error
failed to create assistant: %w
Error message
failed to create assistant: %w
What it means
Wrap in CreateAssistant when NewAssistantWorker fails to construct the assistant worker after the flow worker is resolved. NewAssistantWorker wires up provider, functions, resources and flow context; failures there (provider resolution, function binding, resource setup) are wrapped with %w.
Source
Thrown at backend/pkg/controller/flows.go:320
if fw == nil { // just double check, this should never happen
return nil, fmt.Errorf("unexpected error: flow %d not found", flowID)
}
aw, err := NewAssistantWorker(ctx, newAssistantWorkerCtx{
userID: userID,
flowID: flowID,
input: input,
prvname: prvname,
prvtype: prvtype,
useAgents: useAgents,
functions: functions,
resources: resources,
fw: fw,
flowWorkerCtx: flowWorkerCtx,
})
if err != nil {
return nil, fmt.Errorf("failed to create assistant: %w", err)
}
if err = fw.AddAssistant(ctx, aw); err != nil {
return nil, fmt.Errorf("failed to add assistant to flow: %w", err)
}
return aw, nil
}
func (fc *flowController) ListFlows(ctx context.Context) []FlowWorker {
fc.mx.Lock()
defer fc.mx.Unlock()
flows := make([]FlowWorker, 0)
for _, flow := range fc.flows {
flows = append(flows, flow)
}
View on GitHub (pinned to ea665308ba)
Solutions
- Read the wrapped root cause and address it directly (provider, functions, or DB).
- Verify provider configuration (API keys, server URL) for prvname/prvtype.
- Ensure the tools.Functions set is built and registered for the selected provider/model.
- Check that the referenced user resources exist and are readable.
- Confirm DB connectivity and that migrations are current.
Example fix
// before funcs built for Anthropic passed with prvtype=OpenAI -> NewAssistantWorker fails // after funcs, err := tools.BuildFunctions(ctx, provs, prvtype) aw, err := ctl.CreateAssistant(ctx, userID, flowID, input, true, prvname, prvtype, funcs, resources)
Defensive patterns
Strategy: validation
Validate before calling
// pre-check provider availability for the assistant's provider
if !providerRegistry.IsConfigured(prvname, prvtype) {
return fmt.Errorf("provider %s/%s is not configured", prvname, prvtype)
}
if functions == nil {
return fmt.Errorf("functions required")
} Try / catch
aw, err := ctl.CreateAssistant(...)
if err != nil {
if strings.Contains(err.Error(), "failed to create assistant") {
log.Errorf("assistant init: %v", err) // unwrap for root cause
}
return err
} Prevention
- Build tools.Functions against the same provider type passed to CreateAssistant.
- Validate user resources exist before referencing them in an assistant.
- Keep provider credentials present for the lifetime of flows.
- Ensure migrations and DB are healthy before creating assistants.
When it happens
Trigger: CreateAssistant reached the NewAssistantWorker call (flow resolved fine) but construction failed — e.g. the provider cannot be instantiated for prvname/prvtype, functions is incompatible with the provider, or initializing assistant state in the DB fails.
Common situations: Provider credentials missing at assistant-creation time, functions/tool set not registered for the chosen model, invalid user resources referenced, or a DB error while persisting the assistant record.
Related errors
- failed to finish assistant %d: %w
- failed to renew flow %d status: %w
- failed to load flow %d: %w
- failed to get flow %d status: %w
- failed to stop flow %d: %w
AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01).
Data as JSON: /api/errors/3920be6d7a2e6e00.
Report an issue: GitHub.