vxcontrol/pentagi · error
failed to get assistant system prompt: %w
Error message
failed to get assistant system prompt: %w
What it means
PrepareAgentChain of the assistant provider failed while fetching the assistant agent's system prompt (ap.getAssistantSystemPrompt). The prompt template is stored/config-backed; failure here aborts building the assistant message chain, and the error is wrapped after being logged.
Source
Thrown at backend/pkg/providers/assistant.go:117
func (ap *assistantProvider) SetFlowWorker(flowWorker FlowWorker) {
ap.flowWorker = flowWorker
}
func (ap *assistantProvider) PrepareAgentChain(ctx context.Context) (int64, error) {
ctx, span := obs.Observer.NewSpan(ctx, obs.SpanKindInternal, "providers.flowProvider.PrepareAssistantChain")
defer span.End()
logger := logrus.WithContext(ctx).WithFields(logrus.Fields{
"provider": ap.fp.Type(),
"assistant_id": ap.id,
"flow_id": ap.fp.ID(),
})
systemPrompt, err := ap.getAssistantSystemPrompt(ctx)
if err != nil {
logger.WithError(err).Error("failed to get assistant system prompt")
return 0, fmt.Errorf("failed to get assistant system prompt: %w", err)
}
optAgentType := pconfig.OptionsTypeAssistant
msgChainType := database.MsgchainTypeAssistant
ap.msgChainID, _, err = ap.fp.restoreChain(
ctx, nil, nil, optAgentType, msgChainType, systemPrompt, "",
)
if err != nil {
logger.WithError(err).Error("failed to restore assistant msg chain")
return 0, fmt.Errorf("failed to restore assistant msg chain: %w", err)
}
return ap.msgChainID, nil
}
func (ap *assistantProvider) PerformAgentChain(ctx context.Context) error {
ctx, span := obs.Observer.NewSpan(ctx, obs.SpanKindInternal, "providers.assistantProvider.PerformAgentChain")
defer span.End()View on GitHub (pinned to ea665308ba)
Solutions
- Check the wrapped cause: DB error vs not-found
- Verify prompt settings in the UI (Settings → Prompts) — restore/create the assistant prompt
- Confirm goose migrations ran (backend/migrations/sql) and the prompts table is seeded
- Check database connectivity from the backend container
Example fix
// before
systemPrompt, err := ap.getAssistantSystemPrompt(ctx)
if err != nil { return 0, err }
// after
systemPrompt, err := ap.getAssistantSystemPrompt(ctx)
if err != nil {
if errors.Is(err, sql.ErrNoRows) {
systemPrompt = defaultAssistantPrompt // seed fallback
} else {
return 0, fmt.Errorf("failed to get assistant system prompt: %w", err)
}
} Defensive patterns
Strategy: try-catch
Validate before calling
// before creating the flow, ensure the assistant prompt exists // SELECT count(*) FROM prompts WHERE type='assistant'
Try / catch
id, err := ap.PrepareAgentChain(ctx)
if err != nil {
if strings.Contains(err.Error(), "failed to get assistant system prompt") {
// re-seed default prompts or surface a settings error to the user
}
return err
} Prevention
- Seed default prompts via migrations and idempotent bootstrap
- Protect built-in prompts from deletion in the Settings UI
- Check DB health before spawning agent workers
- Handle the error before PerformAgentChain and fail the flow cleanly
When it happens
Trigger: getAssistantSystemPrompt returns an error: the assistant prompt record is missing from the database (prompt settings table), the DB query fails (connection down, migration not applied), or the context is cancelled during the fetch.
Common situations: Fresh deployment where the default prompts were never seeded; user deleted the 'assistant' prompt in Settings UI; database migrations incomplete; Postgres outage.
Related errors
- failed to restore assistant msg chain: %w
- failed to load user prompts: %w
- failed to get assistant use agents: %w
- token not found in database
- failed to create flow in DB: %w
AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01).
Data as JSON: /api/errors/9fcaf74c05db29be.
Report an issue: GitHub.