POST /agentmemory/session/start
Starts a new session and returns a context block recalled from past memories. Thecontext field is ready to inject directly into the agent’s first turn.
You must pass
sessionId, project, and cwd — Agent Memory uses cwd to scope the project profile and rank relevant memories by path proximity.Request
A unique identifier for this session. Generate a UUID or use your agent’s native session ID. Used to scope observations and link memories back to the session.
Project name or identifier. Agent Memory uses this to scope the memory profile and recall only relevant past context.
Working directory path for the session. Used to rank memories by file path proximity and build the project profile.
Agent identifier for scoped memory. In multi-agent setups, set this to the agent’s role (e.g.
"architect", "developer", "reviewer"). Falls back to the AGENT_ID environment variable on the server. When AGENTMEMORY_AGENT_SCOPE=isolated, only memories tagged with this agentId are recalled.Optional title for this session, stored as both
summary and firstPrompt. Useful for labelling sessions when replaying them later in the viewer.Response
The full session object as stored. Includes
id, project, cwd, startedAt, status (active), and observationCount (starts at 0).Recalled memories formatted as a human-readable context block. Inject this into the agent’s first turn. Empty string if no relevant memories exist yet.
POST /agentmemory/session/end
Ends an active session and fans out the session-stopped lifecycle event. This triggers the consolidation pipeline asynchronously — sessions are summarised, knowledge graph nodes are extracted (ifGRAPH_EXTRACTION_ENABLED=true), and slot reflection runs (if AGENTMEMORY_REFLECT=true).
Request
The session ID returned by
/session/start. The session’s status is set to completed and endedAt is recorded.Response
The consolidation pipeline runs asynchronously after the response is returned — the
200 response does not mean consolidation is complete.GET /agentmemory/sessions
Lists all sessions. By default, returns all sessions visible to the current agent scope. Filter byagentId query param for multi-agent setups.
Request
| Query param | Type | Description |
|---|---|---|
agentId | string | Filter sessions by agent. Pass * to bypass scope isolation and see all agents’ sessions. |
Response
Array of session objects sorted by
startedAt descending. Each session includes id, project, cwd, startedAt, endedAt (if ended), status (active | completed | abandoned), observationCount, agentId, summary, and commitShas.GET /agentmemory/observations
Lists compressed observations for a specific session. Observations are the processed, deduplicated records captured from hook events during the session.Request
| Query param | Type | Description |
|---|---|---|
sessionId | string (required) | The session to retrieve observations for. |
agentId | string | Filter by agent ID. Pass * to bypass scope isolation. |
Response
POST /agentmemory/observe
Captures a raw observation directly — without going through a full session lifecycle. Use this from custom integrations, scripts, or agents that manage their own hook dispatch.Request
The lifecycle event type. One of:
session_start, prompt_submit, pre_tool_use, post_tool_use, post_tool_failure, pre_compact, subagent_start, subagent_stop, notification, task_completed, stop, session_end.Session ID to attach this observation to.
Project name for scoping.
Working directory path.
ISO 8601 timestamp for when the event occurred.
The raw event payload. For tool-use hooks, include
toolName, toolInput, and toolOutput. For conversation hooks, include userPrompt and assistantResponse.Response
Returns201 with the result of the observation pipeline, including whether the observation was deduplicated (SHA-256 content dedup runs within a 5-minute window) or successfully compressed.
POST /agentmemory/session/commit
Links a Git commit SHA to a session. Agent Memory uses these links to display commit history in the viewer and to surface commit-scoped context in searches.Request
Full or short commit SHA.
Session ID to link this commit to. A commit can be linked to multiple sessions — multiple calls with the same SHA merge their session IDs.
Branch name.
Commit message.
Files changed in the commit.
Response
GET /agentmemory/session/by-commit
Looks up all sessions associated with a given commit SHA.{ "commit": CommitLink, "sessions": Session[] }, or 404 if no sessions are linked to that SHA.