2. Conversation with memory
In step 1 you deployed a stateless echo bot. In this step you give the agent working memory: it can record facts the user shares and have them re-injected into its context on later turns.
The change is small: add the memory module under tools.modules
and let the default capability policy grant the memory actions.
The agent automatically gains four memory tools (Remember, SetGoal, TaskCreate, TaskUpdate) that it calls when it
judges something is worth keeping.
Prerequisites
Same as step 1: a running daemon, the digitorn CLI installed, and
an authenticated user. This page assumes a DeepSeek credential
named deepseek_main is provisioned for your user; swap the
brain block if you use a different provider.
The YAML
Save this as memory-bot.yaml:
app:
app_id: memory-bot
name: Memory Bot
version: "1.0"
runtime:
mode: conversation
max_turns: 10
timeout: 60
agents:
- id: main
role: assistant
brain:
provider: deepseek
model: deepseek-chat
backend: openai_compat
credential:
ref: deepseek_main
scope: per_user
provider: deepseek
config:
api_key: "{{env.DEEPSEEK_API_KEY}}"
base_url: https://api.deepseek.com/v1
temperature: 0.3
max_tokens: 256
system_prompt: |
You are a helpful assistant. When the user tells you something
worth keeping (a name, a preference, an ongoing task), call the
Remember tool with a short fact. Stored facts are automatically
re-injected into your context on later turns.
tools:
modules:
memory: {}
capabilities:
default_policy: auto
ui:
greeting: "Hi! Tell me anything; I'll remember the bits that matter."
Deploy and chat
digitorn install memory-bot.yaml
digitorn chat memory-bot
Live transcript
Two real turns against a running daemon, with the verbatim
output captured by the live test client. The model is the
DeepSeek deepseek-chat configured above.
Turn 1
> My name is Paul and I prefer terse replies.
Noted.
The agent fired one tool call before answering:
Remember(content="User's name is Paul. Prefers terse replies.")
Turn 2
> What's my name?
Paul.
No tool call this turn: the fact was still in the agent's window
from turn 1, so it answered directly. When the live conversation
gets compacted out, the memory module re-injects the relevant
stored facts into the next turn's system context automatically.
The two-line replies aren't styled by the doc; the system prompt asked for terse, and the model obliged. To replay the same trace:
digitorn chat memory-bot
> My name is Paul and I prefer terse replies.
> What's my name?
What changed vs step 1
Two lines under tools:
tools:
modules:
memory: {} # adds the memory tools
capabilities:
default_policy: auto # grants them automatically
That's it. The agent now sees Remember, SetGoal, TaskCreate, TaskUpdate in its tool list and calls them when relevant.
Going further
- Persistence: facts and the goal live in the session's own
event log, the same durable store as the rest of the
conversation - they survive compaction and daemon restarts for
that session. There's no separate config to enable this and no
kv_backend/ database option on the module; a new session still starts with empty memory. See the memory module reference. - Working memory + goals: tell the agent its overall goal at
session start and it will use
SetGoalandTaskCreateto keep track. See the memory module reference.
Next: 3. Add a tool: give the agent the ability to read your files.