Skip to main content
Use this when a user talks to a model over several requests and each answer should know what was said before. Prerequisites: Call an LLM works for you. This guide matches example 09, which you can run end to end. Add -H "X-API-Key: $YUKTA_API_KEY" if your server has keys.

Steps

1

Wire load, model, append

A chat turn is a SESSION_MEMORY node in load mode, the model, and a SESSION_MEMORY node in append mode. Save as session.json (this one uses a local Ollama through its OpenAI-compatible endpoint):
session.json
  • load adds history: [{role, content}] to the payload, the newest maxTurns turns (default 20).
  • append records the user turn and the model’s reply (default ${payload.content}); its sessionId defaults to ${metadata.sessionId}.
  • messages is an expression on purpose: a ${...} reference would turn the list into text.
  • With Ollama, set YUKTA_SECRET_LLM_API_KEY to any non-empty value, or drop apiKey.
2

Send two turns with the same conversation id

The conversation id is payload.sessionId here (user-42). It is not the Yukta session chat. Each conversation id has its own history.
3

Forget a conversation

Use mode: delete with the conversation id to remove its history, for example from a separate workflow wired to a “new chat” button:

Verify it worked

Read the result of the second run:
payload.content answers along the lines of “Your name is Ada”. If it does not know, the first run did not finish before the second started, or you used a different payload.sessionId.

Variations

  • Memory is per server process. It lives in memory and a restart clears it. Plan for that if conversations must outlive a restart.
  • Trim long chats. Lower maxTurns on both memory nodes to bound the prompt size and the token cost: Set token budgets.
  • Several agents. Give each agent its own conversation id (or a prefix) so they do not share history.