Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Generate Insights

Reason over stored knowledge in your wisdom graph to surface patterns and recommendations.

POST/v1/memories/insightsGenerate insights by reasoning over stored knowledge

Authentication

All requests require an Authorization: Bearer <agent-secret> header.

Request Body

NameTypeStatusDefaultDescription
taskstringrequiredThe question or task to reason about.
graph_idstringrequiredGraph to reason over.
locus_querystringoptionalSearch query for relevant knowledge. Defaults to the task value.
limitintegeroptionalMax memories to consider. Default 5.
context_idsstring[]optionalFilter by specific context IDs.
context_typesobjectoptionalFilter by context types. A map of type to name arrays.

When locus_query is omitted, the API uses your task as the search query. Set locus_query separately when your task description is broad but you want to search a specific area of knowledge.

Response

200Success
{
  "insight": "Users consistently prefer dark mode interfaces. Three separate feedback events confirm this.",
  "recommendation": "Set dark mode as the default theme",
  "confidence": "high"
}
  • insight — A synthesized finding drawn from relevant knowledge.
  • recommendation — An actionable suggestion based on the insight.
  • confidence"high", "medium", or "low".

Examples

curl

curl -X POST https://api.locusgraph.com/v1/memories/insights \
  -H "Authorization: Bearer <agent-secret>" \
  -H "Content-Type: application/json" \
  -d '{
    "task": "What UI preferences have users expressed?",
    "graph_id": "graph_01",
    "limit": 10,
    "context_types": {
      "feedback": ["ui", "design"]
    }
  }'

TypeScript

import { LocusGraph } from "@locusgraph/sdk";
 
const locus = new LocusGraph({ agentSecret: process.env.LOCUS_SECRET });
 
const result = await locus.generateInsights({
  task: "What UI preferences have users expressed?",
  graphId: "graph_01",
  limit: 10,
  contextTypes: { feedback: ["ui", "design"] },
});
 
console.log(result.insight);
console.log(result.recommendation);
console.log(result.confidence); // "high"

Python

from locusgraph import LocusGraph
 
locus = LocusGraph(agent_secret=os.environ["LOCUS_SECRET"])
 
result = locus.generate_insights(
    task="What UI preferences have users expressed?",
    graph_id="graph_01",
    limit=10,
    context_types={"feedback": ["ui", "design"]},
)
 
print(result.insight)
print(result.recommendation)
print(result.confidence)  # "high"

Practical Pattern: Identify Recurring Issues

Use insights to detect patterns across error events:

curl -X POST https://api.locusgraph.com/v1/memories/insights \
  -H "Authorization: Bearer <agent-secret>" \
  -H "Content-Type: application/json" \
  -d '{
    "task": "What are the most common failure patterns in the last week?",
    "graph_id": "graph_01",
    "locus_query": "error failure crash timeout",
    "limit": 20,
    "context_types": {
      "error": []
    }
  }'

Related

Retrieve Memories
Store Event