memory_session
Alpha, on the 3.6.x line. The API can still change within 3.x.
Controls a session: the working memory of one conversation. You start it, add turns and notes, and then collapse it into durable knowledge or discard it.
Actions
action | Needs | What it does |
|---|---|---|
start | Starts a session and returns its id. | |
turn | sessionId, content | Appends a conversation turn. |
pin_turn | sessionId, turnId or turnIndex | Pins a turn, or unpins it with unpin: true. |
pin | factId | Pins a fact, or unpins it with unpin: true. |
scratch | sessionId, content | Saves an ephemeral note in the session. |
collapse | sessionId | Closes the session and extracts knowledge from it. |
discard | sessionId | Drops the session without extracting anything. |
feedback | sessionId, rating | Rates the session up or down. |
get | sessionId | Returns one session. |
list | Lists sessions. |
Arguments
| Name | Type | Required | Default | Notes |
|---|---|---|---|---|
action | string | yes | One of the ten actions above. | |
sessionId | string | per action | Session id returned by start. | |
content | string | per action | Text of the turn or the note. Up to 20,000 characters. | |
role | string | no | user for turn | user, assistant or system. For turn and scratch. |
turnId | string | no | Id for a turn in turn. Selects the turn in pin_turn. | |
turnIndex | integer | no | Selects the turn in pin_turn by position. | |
factId | string | per action | Fact to pin or unpin. | |
unpin | boolean | no | false | For pin and pin_turn. |
rating | string | per action | up or down. | |
collapseHint | string | no | For collapse. Forces a full extraction pass instead of the automatic heuristic. | |
agentId | string | no | For start. Agent assigned to the session. | |
metadata | object | no | For start, turn and scratch. | |
idempotencyKey | string | no | For start, pin and collapse. Prevents applying the operation twice on a retry. |
Example
{
"name": "memory_session",
"arguments": {
"action": "turn",
"sessionId": "<session id>",
"role": "user",
"content": "Firmware 4.2 ships to the Larkspur warehouse fleet on Friday."
}
}Returns
It depends on the action:
start:{ "id", "agentId", "status", "createdAt", "label" }. UseidassessionId.turn:{ "appended": true, "sessionId" }.pin_turn:{ "pinned", "sessionId" }plus theturnIdorturnIndexyou sent.pin: the updated fact.scratch:{ "scratched": true, "sessionId" }.collapse:{ "accepted", "sessionId", "status" }.acceptedmeans the request was processed, not that knowledge was extracted.statusiscompleted,skipped,failedorcollapse_pending. When it isskipped,skipReasonsays why:too_few_turns,low_recurrence_signal,llm_unavailableorno_pin.discard:{ "discarded": true, "sessionId" }.feedback:{ "feedback": true, "sessionId", "rating" }.getandlist: the session records.
Related
- Session memory and collapse, the concept
- REST:
POST /session/start,POST /session/{id}/turn,POST /session/{id}/pin,POST /session/{id}/scratch,POST /session/{id}/collapse,POST /session/{id}/discard,POST /session/{id}/feedback,GET /session/{id},GET /session/list memory_episode_startandmemory_episode_endstart and close a session with a single call each.