Skip to content

Trajectories

Trajectories record the decisions the enterprise memory service makes while answering a recall: which retrieval hops ran, when it fell back to another strategy, and how an agentic recall loop proceeded. Use them to debug unexpected recall results.


When Trajectories Are Recorded

A trajectory is recorded when a recall runs with tracing enabled (the trace flag on the recall input). The enterprise memory service then:

  1. Starts a trajectory (ID prefixed traj_) for the query.
  2. Appends events as the recall proceeds.
  3. Returns the trajectory in the recall result’s trajectory field and hands it to the storage backend to save.

Event Types

Each event has a type, a timestamp, and a data object.

Event TypeRecorded whenTypical data
fallbackHybrid recall’s RAG pass was insufficient and the service switched to LLM modereason: "RAG insufficient", rag_threshold
fallbackThe hot tier returned fewer results than requested and cold-tier search ran (see Storage Tiering)reason: "hot tier insufficient", hot_count, limit
searchAgentic recall’s seed RAG hophop: "seed", query, added
expandAgentic recall expanded from the newest results (graph hop or cue expansion)added, reason or source
re_queryAgentic recall searched again with a rewritten queryquery, added, reason
stopAgentic recall’s controller decided the working set was sufficientreason

The event type enum also defines filter, rank, threshold, association, and rerank, but the current recall pipeline does not emit them.


Retrieve a Trajectory

The trajectory endpoints are served at /trajectories (no /v1 prefix) and require the workspace_id query parameter.

Terminal window
curl "$MEMORYLAYER_URL/trajectories/$TRAJECTORY_ID?workspace_id=$WORKSPACE_ID" \
-H "Authorization: Bearer $API_KEY"

Response:

{
"id": "traj_0f3c9a...",
"workspace_id": "my-workspace",
"query": "who owns the billing service migration?",
"events": [
{
"type": "search",
"timestamp": "2026-04-01T12:00:00.100Z",
"data": {"hop": "seed", "query": "who owns the billing service migration?", "added": 8}
},
{
"type": "expand",
"timestamp": "2026-04-01T12:00:00.420Z",
"data": {"added": 3, "reason": "follow the owning team"}
},
{
"type": "stop",
"timestamp": "2026-04-01T12:00:00.810Z",
"data": {"reason": "owner identified"}
}
],
"created_at": "2026-04-01T12:00:00.095Z",
"ttl_seconds": 86400
}

Returns 404 if the trajectory does not exist, has expired, or the storage backend does not persist trajectories.


List Trajectories

Terminal window
curl "$MEMORYLAYER_URL/trajectories?workspace_id=$WORKSPACE_ID&limit=20&offset=0" \
-H "Authorization: Bearer $API_KEY"

limit defaults to 20 (max 100).

{
"trajectories": [...],
"total_count": 128,
"limit": 20,
"offset": 0
}

Both endpoints require trajectories:read in the target workspace.


Trajectory Expiration

Trajectories are ephemeral. Each has a ttl_seconds field (default 86400 = 24 hours); expired trajectories return 404.


Debugging Recall Behavior

  • Why did recall take the slow path? Look for a fallback event with reason: "RAG insufficient" — the top RAG score was below rag_threshold, so the service rewrote the query with the LLM.
  • Why did cold memories appear? A fallback event with reason: "hot tier insufficient" means cold-tier search ran and its results were merged.
  • What did agentic recall do? Walk the search / expand / re_query / stop sequence. added shows how many new memories each step contributed; a loop that ends without stop hit its step limit or ran out of new results.
  • Where did the time go? Compare event timestamps to find the slowest step.

The admin dashboard includes a Trajectories view that reads from the /trajectories endpoints.