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

actionNeedsWhat it does
startStarts a session and returns its id.
turnsessionId, contentAppends a conversation turn.
pin_turnsessionId, turnId or turnIndexPins a turn, or unpins it with unpin: true.
pinfactIdPins a fact, or unpins it with unpin: true.
scratchsessionId, contentSaves an ephemeral note in the session.
collapsesessionIdCloses the session and extracts knowledge from it.
discardsessionIdDrops the session without extracting anything.
feedbacksessionId, ratingRates the session up or down.
getsessionIdReturns one session.
listLists sessions.

Arguments

NameTypeRequiredDefaultNotes
actionstringyesOne of the ten actions above.
sessionIdstringper actionSession id returned by start.
contentstringper actionText of the turn or the note. Up to 20,000 characters.
rolestringnouser for turnuser, assistant or system. For turn and scratch.
turnIdstringnoId for a turn in turn. Selects the turn in pin_turn.
turnIndexintegernoSelects the turn in pin_turn by position.
factIdstringper actionFact to pin or unpin.
unpinbooleannofalseFor pin and pin_turn.
ratingstringper actionup or down.
collapseHintstringnoFor collapse. Forces a full extraction pass instead of the automatic heuristic.
agentIdstringnoFor start. Agent assigned to the session.
metadataobjectnoFor start, turn and scratch.
idempotencyKeystringnoFor 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" }. Use id as sessionId.
  • turn: { "appended": true, "sessionId" }.
  • pin_turn: { "pinned", "sessionId" } plus the turnId or turnIndex you sent.
  • pin: the updated fact.
  • scratch: { "scratched": true, "sessionId" }.
  • collapse: { "accepted", "sessionId", "status" }. accepted means the request was processed, not that knowledge was extracted. status is completed, skipped, failed or collapse_pending. When it is skipped, skipReason says why: too_few_turns, low_recurrence_signal, llm_unavailable or no_pin.
  • discard: { "discarded": true, "sessionId" }.
  • feedback: { "feedback": true, "sessionId", "rating" }.
  • get and list: the session records.
  • 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_start and memory_episode_end start and close a session with a single call each.