{"record":{"id":"560adfebfc801af9","repo":"vxcontrol/pentagi","slug":"memory-is-not-available","errorCode":null,"errorMessage":"memory is not available","messagePattern":"memory is not available","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/tools/memory.go","lineNumber":44,"sourceCode":")\n\ntype memory struct {\n\tflowID int64\n\tstore  *pgvector.Store\n\tvslp   VectorStoreLogProvider\n}\n\nfunc NewMemoryTool(flowID int64, store *pgvector.Store, vslp VectorStoreLogProvider) Tool {\n\treturn &memory{\n\t\tflowID: flowID,\n\t\tstore:  store,\n\t\tvslp:   vslp,\n\t}\n}\n\nfunc (m *memory) Handle(ctx context.Context, name string, args json.RawMessage) (string, error) {\n\tif !m.IsAvailable() {\n\t\treturn \"\", fmt.Errorf(\"memory is not available\")\n\t}\n\n\tctx, observation := obs.Observer.NewObservation(ctx)\n\tlogger := logrus.WithContext(ctx).WithFields(enrichLogrusFields(m.flowID, nil, nil, logrus.Fields{\n\t\t\"tool\": name,\n\t\t\"args\": string(args),\n\t}))\n\n\tif m.store == nil {\n\t\tlogger.Error(\"pgvector store is not initialized\")\n\t\treturn \"\", fmt.Errorf(\"pgvector store is not initialized\")\n\t}\n\n\tswitch name {\n\tcase SearchInMemoryToolName:\n\t\tvar action SearchInMemoryAction\n\t\tif err := json.Unmarshal(args, &action); err != nil {\n\t\t\tlogger.WithError(err).Error(\"failed to unmarshal search in memory action arguments\")","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/tools/memory.go#L26-L62","documentation":"The memory tool's Handle was invoked when m.IsAvailable() is false — i.e. the tool was constructed without a pgvector store (and related dependencies), so it cannot operate at all. It's an availability guard, not a runtime failure.","triggerScenarios":"Calling search_in_memory (or any memory tool name) when NewMemoryTool received a nil store; this happens when the deployment has no pgvector store configured (DB not set up, vector-store disabled at startup) yet the tool was still registered with the agent.","commonSituations":"PostgreSQL/pgvector not configured in .env; vector store initialization failed at startup but tools were still registered; running flows against an environment without the memory feature enabled.","solutions":["Check startup logs for pgvector store initialization errors before the flow ran.","Ensure the pgvector store is configured (DB URL with pgvector extension) so NewMemoryTool gets a non-nil store.","Don't register the memory tool with agents when the store is nil — gate registration on availability.","Verify DB migrations applied so the store constructor succeeds."],"exampleFix":"// before: register unconditionally\ntools = append(tools, NewMemoryTool(flowID, store, vslp))\n\n// after: register only when available\nif m := NewMemoryTool(flowID, store, vslp); m.IsAvailable() {\n    tools = append(tools, m)\n}","handlingStrategy":"type-guard","validationCode":"func memoryAvailable(store *pgvector.Store) bool {\n    return store != nil\n}","typeGuard":"func withMemoryTool(store *pgvector.Store) Tool {\n    if store == nil {\n        return nil // caller must skip registration\n    }\n    return NewMemoryTool(flowID, store, vslp)\n}","tryCatchPattern":"out, err := tool.Handle(ctx, \"search_in_memory\", args)\nif err != nil && strings.Contains(err.Error(), \"memory is not available\") {\n    log.Println(\"memory store disabled; continuing without memory lookup\")\n    return emptyResult, nil\n}","preventionTips":["Gate tool registration on IsAvailable() at flow startup","Check pgvector configuration (.env DB settings) before enabling memory features","Fail fast at deploy time if pgvector is expected but not initialized","Make the agent prompt omit unavailable tools so the model never calls them"],"tags":["availability","pgvector","configuration","tool-guard"],"backgroundTag":"tool-not-available","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}