vxcontrol/pentagi · error
pgvector store is not initialized
Error message
pgvector store is not initialized
What it means
The search tool's `Handle` was invoked while its pgvector-backed store field is nil, so no vector search can be performed. `IsAvailable()` returns false in this state; this error enforces that contract for direct calls that bypass the availability check.
Source
Thrown at backend/pkg/tools/search.go:81
store: store,
embedder: embedder,
db: db,
maxEmbeddingBytes: maxEmbeddingBytes,
vslp: vslp,
knp: knp,
}
}
func (s *search) Handle(ctx context.Context, name string, args json.RawMessage) (string, error) {
ctx, observation := obs.Observer.NewObservation(ctx)
logger := logrus.WithContext(ctx).WithFields(enrichLogrusFields(s.flowID, s.taskID, s.subtaskID, logrus.Fields{
"tool": name,
"args": string(args),
}))
if s.store == nil {
logger.Error("pgvector store is not initialized")
return "", fmt.Errorf("pgvector store is not initialized")
}
switch name {
case SearchAnswerToolName:
var action SearchAnswerAction
if err := json.Unmarshal(args, &action); err != nil {
logger.WithError(err).Error("failed to unmarshal search answer action arguments")
return "", fmt.Errorf("failed to unmarshal %s search answer action arguments: %w", name, err)
}
filters := map[string]any{
"doc_type": searchVectorStoreDefaultType,
"answer_type": action.Type,
}
metadata := langfuse.Metadata{
"tool_name": name,
"message": action.Message,View on GitHub (pinned to ea665308ba)
Solutions
- Check `IsAvailable()` before invoking the tool and exclude it from the agent's toolset when false.
- Verify pgvector/Postgres connectivity and DSN env config; restart the backend after fixing.
- Inspect startup logs for the vector-store initialization error that left the store nil.
- Fix the wiring so construction fails fast instead of registering a tool with a nil store.
Example fix
// before
out, err := searchTool.Handle(ctx, tools.SearchAnswerToolName, args)
// after
if !searchTool.IsAvailable() {
return errors.New("search tool unavailable: pgvector store not initialized")
}
out, err := searchTool.Handle(ctx, tools.SearchAnswerToolName, args) Defensive patterns
Strategy: type-guard
Validate before calling
if !searchTool.IsAvailable() {
return errors.New("search tool unavailable: pgvector store not initialized")
} Type guard
func usable(s *search.Search) bool {
return s != nil && s.IsAvailable()
} Try / catch
if err := handle(ctx, name, args); err != nil {
if strings.Contains(err.Error(), "pgvector store is not initialized") {
return fallbackKeywordSearch(ctx, args) // degrade gracefully
}
return err
} Prevention
- Check IsAvailable() before adding any vector tool to the agent toolset.
- Fail fast at startup if pgvector is required but unreachable.
- Monitor container health for Postgres/pgvector so nil-store states are caught early.
When it happens
Trigger: Calling `search.Handle(ctx, name, args)` when `NewSearch` was constructed without a vector store (pgvector unreachable at startup, disabled by config) or the store failed to initialize, instead of checking `IsAvailable()` first.
Common situations: Postgres/pgvector not running or wrong DSN at container start; vector-store feature disabled via env config but agent config still lists the search tools; construction error swallowed so the tool object exists with a nil store.
Related errors
- failed to get flow vector store log: %w
- memory is not available
- pgvector store is not initialized
- failed to create flow vector store log: %w
- failed to prepare primary agent chain for subtask %d: %w
AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01).
Data as JSON: /api/errors/d4c85d538e152285.
Report an issue: GitHub.