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
string
required
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.
string
required
Project name or identifier. Agent Memory uses this to scope the memory profile and recall only relevant past context.
string
required
Working directory path for the session. Used to rank memories by file path proximity and build the project profile.
string
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.string
Optional title for this session, stored as both
summary and firstPrompt. Useful for labelling sessions when replaying them later in the viewer.Response
object
The full session object as stored. Includes
id, project, cwd, startedAt, status (active), and observationCount (starts at 0).string
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
string
required
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
Response
Session[]
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
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
string
required
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.string
required
Session ID to attach this observation to.
string
required
Project name for scoping.
string
required
Working directory path.
string
required
ISO 8601 timestamp for when the event occurred.
object
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
string
required
Full or short commit SHA.
string
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.
string
Branch name.
string
Commit message.
string[]
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.