{"record":{"id":"204525591b384eba","repo":"vxcontrol/pentagi","slug":"failed-to-store-guide-w","errorCode":null,"errorMessage":"failed to store guide: %w","messagePattern":"failed to store guide: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/tools/guide.go","lineNumber":300,"sourceCode":"\t\t\t\tlogger.WithError(err).Error(\"failed to load document\")\n\t\t\t\treturn \"\", fmt.Errorf(\"failed to load document: %w\", err)\n\t\t\t}\n\t\t\tfor i := range docs {\n\t\t\t\tif docs[i].Metadata == nil {\n\t\t\t\t\tdocs[i].Metadata = map[string]any{}\n\t\t\t\t}\n\t\t\t\tmaps.Copy(docs[i].Metadata, metadata)\n\t\t\t\tdocs[i].Metadata[\"part_size\"] = len(docs[i].PageContent)\n\t\t\t}\n\t\t\tids, err = g.store.AddDocuments(ctx, docs)\n\t\t\teventMetadata[\"ids\"] = ids\n\t\t\tif err != nil {\n\t\t\t\tobservation.Event(append(opts,\n\t\t\t\t\tlangfuse.WithEventStatus(err.Error()),\n\t\t\t\t\tlangfuse.WithEventLevel(langfuse.ObservationLevelError),\n\t\t\t\t)...)\n\t\t\t\tlogger.WithError(err).Error(\"failed to store guide\")\n\t\t\t\treturn \"\", fmt.Errorf(\"failed to store guide: %w\", err)\n\t\t\t}\n\t\t} else {\n\t\t\t// Slow path: Guide field exceeds embedding limit.\n\t\t\t// Template: \"Question:\\n{question}\\n\\nGuide:\\n{guide}\"\n\t\t\tprefix := \"Question:\\n\" + anonymizedQuestion + \"\\n\\nGuide:\\n\"\n\t\t\tavailable := max(g.maxEmbeddingBytes-len(prefix), 0)\n\t\t\tembeddingText := prefix + truncateForEmbedding(anonymizedGuideOnly, available)\n\n\t\t\tid, err := storeDocumentWithEmbeddingLimit(ctx, g.db, g.embedder,\n\t\t\t\tembeddingText, anonymizedGuide, metadata)\n\t\t\tif err != nil {\n\t\t\t\tobservation.Event(append(opts,\n\t\t\t\t\tlangfuse.WithEventStatus(err.Error()),\n\t\t\t\t\tlangfuse.WithEventLevel(langfuse.ObservationLevelError),\n\t\t\t\t)...)\n\t\t\t\tlogger.WithError(err).Error(\"failed to store guide with embedding limit\")\n\t\t\t\treturn \"\", fmt.Errorf(\"failed to store guide: %w\", err)\n\t\t\t}","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/tools/guide.go#L282-L318","documentation":"The fast path of store_guide — when the anonymized guide fits within maxEmbeddingBytes — failed while adding the document to the pgvector store. Same failure class as the load-document error but on the direct AddDocuments branch.","triggerScenarios":"Embedder API failure (auth, quota, timeout) or pgvector insert failure when calling store_guide with a guide whose serialized form fits the embedding byte limit.","commonSituations":"Expired/invalid embeddings API key; embeddings provider rate-limited mid-flow; PostgreSQL down or pgvector table missing; context deadline exceeded on a slow embedder.","solutions":["Inspect the wrapped cause to separate embedder vs DB failure.","Fix embeddings credentials/quota or provider URL in config (.env / Settings UI).","Run migrations to ensure the pgvector schema exists.","Retry the store_guide call — transient API/rate-limit errors resolve on retry.","Check DB connectivity and pool exhaustion in PostgreSQL logs."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"func canEmbed(ctx context.Context, e embeddings.Embedder, text string) error {\n    _, err := e.EmbedDocuments(ctx, []string{text[:min(len(text), 64)]})\n    return err\n}","typeGuard":"func embeddingsConfigured(store *pgvector.Store, e embeddings.Embedder) bool {\n    return store != nil && e != nil\n}","tryCatchPattern":"out, err := tool.Handle(ctx, \"store_guide\", args)\nif err != nil && strings.Contains(err.Error(), \"failed to store guide\") {\n    return withRetry(3, backoff.Exponential, func() error {\n        _, err = tool.Handle(ctx, \"store_guide\", args)\n        return err\n    })\n}","preventionTips":["Keep embeddings credentials and quotas monitored","Retry idempotent store operations on transient provider errors","Alert on pgvector insert failures from backend logs","Validate DB connectivity at flow start"],"tags":["database","pgvector","embeddings"],"backgroundTag":"vector-store-write-failed","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}