1/24
Concept flashcards for Ch 4, The Runtime Loop, based on The Claw AI Agent Ecosystem by Ava S. Barron (ISBN 979-8-2526-0474-9).
Steps in one agent turn
Event received, context assembly, model call, response parsing, tool execution, follow-up model call, memory update, response delivery.
Response parsing branch
Text only: skip to memory update and delivery. Tool calls: execute, append results, call the model again, and repeat until no tools remain.
Session history default
The whole session history loads every turn; without pruning it grows unbounded and the user pays for all of it on each message.
Model-tool-memory sub-loop
Validate the call, execute the tool, append the result, call the model again; repeat until the response is text only.
Tool results as cost multiplier
Each appended result is billed again on every later model call within the same turn.
Tool call validation checks
Tool existence, schema conformance, permission tier, and rate limit. A failure returns to the model as a tool error result.
Limit of tool validation
It checks format and permission tier, not whether the outcome matches user intent; that is SOUL.md's and AGENTS.md's job.
Wrong tool selection
The most insidious tool-generation failure, since the call may succeed while doing the wrong thing. Prevent it with explicit do-not-use lines in SKILL.md.
End-of-session memory write
A model call that turns session history into a structured summary in memory/YYYY-MM-DD.md; it can be routed to a cheaper model.
What not to log
Verbatim transcripts, facts already in USER.md or MEMORY.md, credentials, full private documents, and unconfirmed speculation.
Memory security boundary
Memory files are plaintext readable by anyone with filesystem access. Log that a communication happened and its action items, not its content.
Why promote to MEMORY.md
Only today's and yesterday's logs load by default, so durable facts must move to MEMORY.md to stay in context.
Session
Stored state with history, start time, owner (user plus channel), and memory log path. Kept in SQLite by default; survives restarts.
Session isolation key
By default sessions are separate per channel and per peer, which prevents personal and work context from bleeding together.
Summarize vs truncate
Summarize the oldest turns at the soft threshold to keep continuity; truncate at the hard threshold as a backstop that drops them.
Heartbeat benefits
Proactive task triggering, system health checks, advancing background tasks, and memory maintenance.
Heartbeat model choice
Almost always a local or cheap model; typical heartbeat work fits a 1B-3B parameter local model.
Cache-friendly context ordering
Load stable content first, keep timestamps out of the system context, and keep tool schema order fixed.
cacheControlTtl
How long cached blocks persist; default 300 seconds. Raise it when interactions are hourly or less frequent.
Silent memory write failure
For example, disk quota exceeded: the reply looks normal but nothing persists. Monitor workspace disk and alert at 80%.
Context accumulation problem
Long multi-tool tasks pile results into one turn's context. Mitigate by compressing results, limiting verbosity, or splitting into separate turns.
Task checkpointing
For tasks over five tool calls, track the plan and progress in tasks_in_progress.md so a restart can resume instead of losing work.
Graceful shutdown
Enable maintenance mode, wait for in-progress turns to drain, then stop the container.
maxTurnDurationSeconds
Per-turn timeout so a hanging tool call can't block the queue forever. Set it near the 99th percentile of legitimate turn length.
Identity file reload
Identity files load at session start, so edits to SOUL.md or AGENTS.md during a session need a session restart.