Agent Learning
The agent-learning subsystem turns finished turns into durable, retrievable lessons, so the same agent (and its team, and the org) improves without retraining the model.
This page describes the shipped architecture: what runs in-engine, where each piece slots into the Turn Engine and Knowledge System, and the non-goals.
Provider-agnostic by design. Learning lives in the org/data layer, not in a model checkpoint. Any llm.Provider can back any role. Model fine-tuning is never required and is not part of the in-engine learning loop.
Why tools alone are not enough
Section titled “Why tools alone are not enough”Adding memory/skill tools does not make an agent “learn.” Four layers must line up:
| Layer | What it does | Where Crewlet carries it |
|---|---|---|
| 1. Model training | Weights that know the memory/reflection protocol | Not required. Layers 2-4 do the work; any stock Claude/GPT works. |
| 2. Per-phase contract | Short system-prompt rules saying when to persist, reflect, recall | The executor and review prompt builders in internal/agent/prompts: guidance blocks injected only when the matching tool is registered. See Prompt scaffolding. |
| 3. Tool descriptions | One-line when to use text on each tool; guardrails go in descriptions, not prompts | Builtins (query_episodes, reflect_and_persist, refresh_memory, refine_skill, use_skill, mark_onboarded). |
| 4. Deterministic harness | Post-turn code that runs reflection whether or not the LLM “remembers” to | The reflect engine, the load-bearing piece. LLM cooperation is a bonus. |
Crewlet puts the weight on layers 2-4.
Subsystems
Section titled “Subsystems”Small components with one responsibility each, plus the orchestrator that wires them.
Two ways in. Everything learned from a turn arrives on one event through one dispatcher; the passes driven by a clock are their own loops and fleet singletons.
1. PersistDecider (post-turn personal memory)
Section titled “1. PersistDecider (post-turn personal memory)”A deterministic post-Review decision replaces hoping the LLM captures a durable fact.
- Trigger: after the turn settles
done, orfailed(a reviewer’sfailed, or one the engine set: a fired guard, a spent budget, an exhausted provider chain).self_iterateis a mid-state; reinforcing it would teach from incomplete work. - Decision: a small auxiliary-model prompt answering what, if anything, should persist? Defaults to NOOP. The classifier picks a tier:
LONG: durable preference / fact (no TTL).SHORT: situational, with a TTL in days (sprint focus, vacation, delegation context).DOC: team-relevant; the decider writes no personal memory but logs the recommendation. Cross-agent propagation goes through the team knowledge base, not the diary.NOOP: nothing worth persisting.
- Writing style: entries are declarative facts, not instructions.
"User prefers concise responses"✓,"Always respond concisely"✗. Instructions drift out of date and get re-discovered as contradictions; facts compose cleanly. (Adopted verbatim from Hermes’s memory guidance.) - Effect: writes a row to the agent’s
agent_diaryvialearning.Diary.Write, agent-scope only.
2. Diary and reflect_and_persist (in-flight personal memory)
Section titled “2. Diary and reflect_and_persist (in-flight personal memory)”The agent’s private observation log. Two kinds:
| Kind | TTL | Use |
|---|---|---|
diary_long | None | Durable preferences and facts (Stakeholder X prefers digests). Capped per seat at 500 entries, because recall scans and cosines every one at every turn start. Past the cap the sweep evicts by use, not age: least-retrieved first, then least-recently-retrieved, then oldest, so what goes is what has never been recalled. A use is an entry the relevance filter selected, not one it merely considered (the candidate pool is similarity ∪ recency, so counting candidates would move every counter every turn). Both read paths, the ## Personal memory block and refresh_memory’s hinted re-filter, run through that one filter, so both count. The write is detached from the turn’s context so a recall is still recorded when the turn is finishing. |
diary_short | Set | Situational state (Sprint freeze runs through 2026-05-10, Opened PR-123 from my box, awaiting review). Excluded by the read’s own SQL predicate once the TTL passes (an expired row never takes a slot in the recency window), and physically deleted by the retention sweep, on the same fleet-wide singleton tick as the other short-horizon tables. |
Two writers converge: the post-turn PersistDecider and the in-flight reflect_and_persist builtin. Both go through learning.Diary.Write, which embeds the content in the same INSERT as the row, whole and tagged with its model, so the row is reachable by vector similarity and the memory changelog carries the vector.
Embedding. The embed has a two-second budget (learning.DiaryEmbedBudget). A note whose vector cannot be had in time, or at all, or comes back with no direction (all zeros or not finite; stored, it would read as one the note has), is stored without one, never refused; an episode’s is too.
The holder fills what is missing. Once a minute the node holding a seat embeds, in batches, its live notes with no vector of the current model and width: those whose embed failed, and every note of a model or width the company has left. A minute’s fill is one pass over every seat the node holds, held to what the provider answers:
- A rate limit, timeout, refused key or model the endpoint does not serve ends the minute for every seat.
- A refused batch is split in halves until the refused note is alone; that note is held back an hour, then offered again alone.
- A note answered with a vector with no direction costs only itself: held back an hour (
memory_fill_vector_unusablenames it with its size), costing no request, then offered again with its neighbours. - A refusal that is the minute’s first answer is judged by one plain word sent alone. Refused too: the refusal is the configuration’s (a
dimensionsthe model does not take, say);memory_fill_configuration_refusedis logged and nothing is sent for an hour, or until an apply changesproviders.embeddings’ model, width, limits or endpoint; the first refusal after the hour is judged again. Accepted: it was the notes’, isolated as above. (Judging by the word rather than the notes: a rule that read two notes refused alone as the configuration’s stopped a node’s fill for an hour over two poison notes.) - What the fill holds back, notes and pause alike, concerns the provider as configured (the knowledge corpus’s rule, on the same four). An apply that changes anything else, or re-activates an unchanged revision to rotate the key, keeps it; one that changes any of the four retries every held note at once.
- A minute is bounded by what it sends, refused requests included: sixteen requests a node and a million bytes of text across the whole company, shared equally among the nodes that run seats (a provider limits an account, not a node). That is the million tokens a minute of OpenAI’s lowest paid tier for these models, about 500 notes at the 2,000-byte note bound. A minute that runs out starts the next at the seat it ran out at.
- Setting a vector stamps the note with a fresh change sequence, so the changelog carries it like a new note and a peer holding the vectorless copy takes the filled vector over it.
Reading. The ## Personal memory prefetch and refresh_memory use hybrid candidate selection: learning.Diary.Recall (vector top-K to the trigger) unioned with learning.Diary.Recent (recency top-K), deduped by row id. The halves are 50 each, so the union is the bound. An aux-LLM relevance filter picks the final digest from the pool. Vector search catches topical / semantic matches; recency catches broadly-applicable operational rules that may not match topically (e.g. “use semantic commit messages on every PR”).
Write-boundary hygiene. learning.Diary.Write has no duplicate guard of its own: duplicates are stopped upstream, by the reflect dispatcher’s redelivery guard on the work key and the PersistDecider’s prompt, which is shown the seat’s recent notes and asked not to repeat one (a byte-exact guard at the store would catch only what those already catch, none of the paraphrases). Content is stored verbatim, never length-truncated. A note past learning.MaxContentChars (2 000) is refused, never trimmed, by both writers: reflect_and_persist refuses with the limit named so the model can tighten and retry; the PersistDecider skips the row and logs it, since nobody is there to ask. Nothing is sliced for the embeddings provider: a note longer than the model’s input is split between words and its pieces’ vectors pooled. The PersistDecider is also skipped when the turn already self-persisted (the executor called reflect_and_persist in any round, read off turn_completed’s all_tool_names, not its last-round tool_sequence). Prompt-injection scanning at this boundary is a separate concern, not bundled here.
The diary is read by:
- The
## Personal memoryprefetch block (see Personal memory prefetch + refresh). - The mid-turn
refresh_memorybuiltin, which re-runs the same diary query with an enriched context hint.
3. Profiler (entity modeling)
Section titled “3. Profiler (entity modeling)”Crewlet’s multi-party equivalent of Hermes’s “model of who you are.”
- Input: observed interactions per counterparty (colleague, stakeholder, external human): the inbound messages a turn’s notification trigger carries, from a chat surface, the tracker or a code host. On Worklet and Doclet a change names its writer by the kind its record holds, so a colleague’s or person’s comment is profiled under the same handle as their chat messages; the engine’s own notices (a work item it reports unblocked) are nobody’s to profile. An agent-to-agent ask carries none (an internal trigger, like a schedule’s fire or a sandbox completion), so the asking colleague is not profiled from it. A coalesced trigger runs one observation pass per distinct sender (
Profiler.subjectsOfgroups a sender’s messages in order first). A seat never profiles itself. - Output: one
learning.Profilerow per(observer_handle, subject_handle | subject_external_id, subject_platform): preferred communication style, past decisions, sensitivities, topics of interest. Stored incounterparty_profiles(not the diary; not Confluence). Both are handles (see A seat is keyed on its handle). - Scope: per-observer always; a fact one agent learns about Bob is private to that agent. Cross-agent propagation goes through humans and the team knowledge base, not auto-merging.
- Retrieval: the turn-start prefetch injects the trigger counterparties’ profiles into the executor’s prompt (one block per distinct sender with a stored profile).
lookup_colleagueresolves who a colleague is and returns no profile.
4. Episodes and query_episodes (search own past)
Section titled “4. Episodes and query_episodes (search own past)”Agents can search their own prior turns.
- Source: the
episodestable in the node’s own store, replicated onto the memory changelog under the seat’s id and keyed in the row by the seat’s handle, so it follows the seat across nodes. One row per completed turn (agent_handle,task_summary,askand theask_provenancelabel it was asked under,plan_summary,tool_sequence,skills_used,review_outcome,started_at,ended_at,duration_ms,embeddingand theembedding_modelit came from), filed against the work item the turn was charged to as its backend-qualified ref (native:<id>,jira:<id>; see Which work a turn is on); a turn on nothing, and every compacted row, is filed against none. The column iswork_item(renamed fromtask_idby node migration0033). - Vector: each turn is embedded as ONE text, whole (a text past the model’s input is split between words and its pieces’ vectors pooled): the label of the waking event (
task_summary, the line a feed shows: “Message from Ana: Slack message”), what it was asked (each interaction’s body; for a wake with no interactions, such as a colleague’s question, a schedule’s task or the resumed half of a coding turn, theaskfieldturn_completedcarries, parked with the conversation across a suspension), and what it did (plan_summary: the last review’s account of what had landed, or the final answer). The label alone is the same line for every message on a surface. A scheduled turn’s label names its schedule (swe was assigned scheduled work weekly-report), never the fire’s run id, which differs every fire and would make two fires of one schedule unalike to similarity search. - Fill: the ask is stored on the row (
ask, node migration0042), whole, so the vector is a function of the row alone and the holder fills it like a diary note’s (for a row written while the embedder was unreachable, and for every raw row after a model or width change), under the same once-a-minute pass and budget (above). A row whose text is longer than a minute’s pass sends (an ask is bounded only by the event that carried it) is sent a request at a time: the pieces each request embeds are kept on the node,memory_fill_input_continuednames the row and how many pieces are in, and the next minute sends the rest. The vector is still the pool of the whole text. A piece the provider refuses, or answers with no direction, holds the row back an hour with the earlier pieces kept, so the retry resumes at that piece and the rows and seats behind are filled meanwhile. A failure not about the row (rate limit, timeout, server error) ends that minute and the next sends that request again. Until filled, a row is found by recency and conversation only. A turn told nothing stores no ask and is filled from its label and what it did. - Cost of storing the ask: not bounded by a count of rows. The lifecycle’s threshold only makes a pass due, and a pass keeps raw every settled turn of the last thirty days, the two exemplars of every cluster it folds, and, with no horizon, every settled turn that called tools and never joined a cluster of three; a compacted summary keeps no ask. That is about thirty days of asks on each node holding a copy (1.5 MB at fifty turns a day of a kilobyte each) plus what never folds; on the memory changelog (one message per row, no deletes) every ask ever asked, about 18 MB a year at the same rate, beside a vector already 6 KiB a row at 1 536 dimensions.
- Builtin:
query_episodes(query?, conversation?, outcome_filter?, limit?), available to the executor and scoped to the calling seat by its handle: similarity to each past turn’s text whenqueryis given, the seat’s own turns in one conversation whenconversationis, recency otherwise. Each turn is answered with what woke it (the waking event’s label, markedwoken by:, because unmarked a model read “Message from Ana: Slack message” as the question it had been asked), what it was asked (asked:, the stored ask; none shown if the turn was told nothing), how it ended, and what it did (what it did:,plan_summary).- What it was asked is fenced as whoever wrote it, under the turn’s own token and the label the row keeps (ADR-0040): a stranger’s month-old message is not the seat’s own memory because it was recalled, so it reads as that stranger’s words and nothing it spells (the turn’s closer, a forged opener) gets out. An ask that was the company’s own (a schedule’s task) is neutralised in place, as is everything else on the line: the label, the account, a compacted row’s summary and the scope asked for. The tool, the turn-start block and the summary’s input render a past turn through one function (
learning.RenderPastTurn). - The ask and the account are each on one line, whole up to 600 bytes (
learning.EpisodeAccountBytes) and past that condensed by the seat’s auxiliary model and marked as a rewrite, or named by its size where no rewrite can be had in time. All rewrites of one answer, four at a time, share one thirty-second deadline (learning.EpisodeRewriteTimeout). - A compacted row is answered as its pattern: the dates it spans, how many turns it stands for, how many ended
done(counted from the members), and what varied. - A
queryanswer is headed as most similar first, and says how many of the seat’s turns its search could not reach (rows with no vector of the current model yet, which the holder is filling), namingconversationand recency as the way to read them. An empty answer means “this is new work” only when there were no unreachable rows. - A
querythat cannot run says what stopped it, because each cause sends the seat somewhere different: a company with no embeddings (stop asking by meaning); an embedder that refuses its configuration (rejected key, missing model or endpoint, a vector width the store was not sized for:embeddings.ErrConfiguration), which no query gets past until an operator fixesproviders.embeddings; an embedder that refuses this query (embeddings.ErrRefused), which only a different query may get past; an embedder that could not answer now (429, 5xx, network failure, timeout), which may answer if called again; anything else, such as an unreadable episode store, said as what it was with no promise; and a registry with no search wired. Each namesconversationand recency as the paths that still work.
- What it was asked is fenced as whoever wrote it, under the turn’s own token and the label the row keeps (ADR-0040): a stranger’s month-old message is not the seat’s own memory because it was recalled, so it reads as that stranger’s words and nothing it spells (the turn’s closer, a forged opener) gets out. An ask that was the company’s own (a schedule’s task) is neutralised in place, as is everything else on the line: the label, the account, a compacted row’s summary and the scope asked for. The tool, the turn-start block and the summary’s input render a past turn through one function (
- An episode is a turn’s account; its transcript is its session. What a past turn read, called and wrote is the seat’s executor session in the object store, which the executor reads with
list_sessionsandread_session(A seat reads its own). - Auxiliary summarization: the turn-start block’s hits go through the role’s
llm_auxiliarymodel (a cheap one), which writes one short briefing, at most four bullets (a length the prompt asks for, since no harness takes a per-call output cap), keeping the system prompt small (learning.reflect.summarize_episodes). Falls back to the raw entries when off or when no aux model answers.query_episodesis never summarised. - Frozen-at-turn-start: the
## Similar prior workprefetch resolves once per turn and bakes the summary into the system prompt. Aself_iterateround reuses the same prefix so the provider’s prompt cache keeps working.
5. Synthesizer (skill induction)
Section titled “5. Synthesizer (skill induction)”Mines recurring successful trajectories and drafts a new procedural skill.
- Single-turn induction runs inline in the reflect engine: a settled turn (
doneorfailed) that used ≥min_tool_callstools is offered to the auxiliary model, which drafts a skill or declines. Declining is the ordinary answer, so a turn with no reusable shape costs one cheap call and writes nothing. Every post-turn worker’s prompt describes the turn as woken by (the waking event’s label: what kind of event, nothing of what it said), asked (the PersistDecider renders each interaction with its sender instead) and what it did (the review’s account, or the final answer), never as a “task” and a “plan”, which a model reads as the whole ask and the intent. - Gates, all before the model call, because a draft made only to be discarded is wasted money: the per-seat cap (
max_skills_per_agent), and a duplicate check comparing the turn’s tool set against the seat’s existing skills by Jaccard similarity (duplicate_jaccard_threshold). The comparison is over the tool set, not the ordered run: the same tools in a different order are the same procedure. A draft returned without a name, summary or body is dropped. - Clustered synthesis (
scheduler_enabled,cluster_*) catches what single-turn induction cannot: a shape a seat arrives at over a fortnight, invisible from inside any one turn. A daily singleton pass reads each seat’s lastepisode_fetch_limit(default 200) turns, greedy-clusters them by tool-sequence Jaccard atcluster_jaccard_threshold(default 0.6), and drafts from the largest cluster of size ≥cluster_min_size(default 3). It is off by default (scheduler_enabled: false) because it costs an auxiliary call per seat per day and a young company has nothing to cluster.- One draft per seat per pass, largest cluster first: a seat with three patterns learns them over three days, strongest evidence first, and no single tick can fill the per-seat cap.
- A cluster the seat has already learned is skipped, not a stop; the next one down may be new. It uses the same
duplicate_jaccard_thresholdas the inline path, deliberately stricter than the pooling threshold: pooling asks “same kind of work”, rejecting a draft asks “same skill”. - Only raw, settled turns with ≥
min_tool_callstools are evidence. A compacted row already summarises a cluster and would count a fold as one turn; aself_iterateround is work judged incomplete. - The stored
tool_sequenceis a run that actually happened (the cluster’s representative), not a union of members, because the duplicate check compares stored sequences with new turns and a union nobody performed matches everything loosely. - Each member reaches the call as what woke it, how it ended and its tools, and what it did (the recall block’s rendering), never as a “task” and a “plan”. No member’s ask is shown, and every line has the fence’s two escapes applied, as do the turns episode compaction reads and the skills promotion reads, because each pass writes back something its seats read as their own.
- The
skill_synthesizedevent carriestrigger: clusteredand thecluster_size, and noturn_id: naming one member would put a trace on the event that explains none of the others.
- Output: a row in
synthesized_skillskeyed by(agent_handle, name), agent-scope only. The body is stored in SKILL.md Markdown shape, whichuse_skillreturns verbatim. - Cross-agent promotion is the third path, and its output is deliberately not a skill row: a skill is a procedure one seat follows, while a procedure several seats arrived at independently is something the team has, which is documentation. When ≥
min_sibling_countdistinct seats in one unit converge on a similar tool run, a daily singleton pass distils the cluster into a draft page in the team knowledge base under the unit’sAuto-Drafted Skillsparent, for a lead to review.- Distinct seats, not skills. One seat with four near-identical skills needs curating; counting rows would present one agent’s habit as the unit’s practice.
- Direct members only. A parent unit does not pool its children’s catalogues, which would re-draft a child’s promotion a level up, naming a team that never converged.
- The draft is hidden until a person publishes it. The
## Relevant knowledgesearch excludes the auto-drafted subtree (and, as a fail-closed backstop where a backend has no parent chain, the[Auto-draft]title prefix), so an unvetted draft never reaches another agent. A lead adopts one by moving it out of that parent; it is then an ordinary knowledge-base page reachable through query-time search. Rejecting one is a delete; it is re-drafted only if the team converges again. - One backend, matched. The pass writes through the
learning.PromotionWriterseam:confluence.PromotionWriterposts rendered storage-format XHTML under the unit’sspace, creating theAuto-Drafted Skillsparent if the space has none, and refusing the draft rather than filing it at the space root if that parent cannot be created (a page outside the subtree is readable by every agent). The container is the unit’s wiki space, never its tracker project: filing under the tracker’s key would create a page in whatever space shared the name, or fail. - Cross-tick dedup is the writer’s job, because the pass re-clusters the same rows every tick. Confluence keys on the title, unique within a space: one cluster yields one page, and a tick that finds the existing draft stays quiet.
- A unit with no container is soft-skipped with the field to set in the log (a company may configure knowledge for one team and not another). A write failure announces nothing; the next tick retries.
- Success publishes
skill_promotedcarrying the unit, thecontainer_key, thepage_id/page_title, and bothsibling_countanddistinct_agents, because one agent repeating itself and five converging are different findings. - The engine carries no unit-scope skill rows.
- Collision guard: the synthesizer rejects names that already exist in the agent’s own
synthesized_skillstable. There is no global skill registry; shared procedures live in the team knowledge base.
6. Refiner and refine_skill (improve skills during use)
Section titled “6. Refiner and refine_skill (improve skills during use)”When a synthesized skill was central to a successful turn, append an observed-in-practice bullet; when it contributed to a failed turn, a counter-example.
- Auto path: the reflect engine dispatches the refiner after every settled turn (
doneorfailed) whoseskills_usedis non-empty. Aself_iterateround is not refined: a lesson from work the agent judged incomplete may be contradicted next round, and the turn emits anotherturn_completedwhen it settles. The auxiliary model picks one observation (or NOOP):Observed in practice: …on success,Counter-example: …on failure. - One call, one bullet, at most one skill. The turn’s whole offered catalogue goes into a single prompt and the model chooses which skill, if any, learned something (per-skill calls would cost a completion per skill per turn for mostly NOOP answers). A name the model invents is dropped, not matched to the nearest candidate: a bullet on the wrong procedure is worse than none.
- NOOP is the expected answer, not an error. A model asked what a turn taught will produce something for any turn, and a skill growing a bullet per turn becomes a diary. The prompt says twice that answering nothing is correct.
- Only skills that still exist.
skills_usedis a list of ids captured when the prompt was built; the refiner intersects it with the live catalogue, so a skill the curator archived meanwhile is not resurrected. A turn whose skills are all archived costs no model call. - Bullets collect under one
## What practice addedheading at the end of the body, so a reader sees the procedure first and what practice added second. - Manual path: the
refine_skillbuiltin lets the executor correct its own skills mid-turn. It takesskill_name, the full correctedcontentand an optionalreason; the new text replaces the body entirely. Whole-body replacement rather than a patch, because a model asked for a diff produces something that does not apply, and a half-applied edit leaves a procedure that is neither old nor new (the prior body is already archived by then). A seat that finds a skill outdated corrects it at once rather than waiting for a consolidation pass. A seat may only refine its own skills. - Versioning: every refinement archives the prior state to
synthesized_skill_versionsand bumps the live row’sversion. Rollback is a forward step (the archived body becomes the body of a new version), so rewinding then un-rewinding loses no history. History is bounded bymax_versions_kept(default 10) per skill. - Body cap:
max_body_chars(default 20 000). A refinement that would breach it is refused, never truncated (a clip lands mid-step and the model reads the remainder as the whole procedure). The auto path skips silently and logs it; the manual tool refuses with the field name, so the model can tighten and retry. enabledgates both halves.learning.skill_refinement.enabled: falsewithdraws therefine_skilltool and leaves the post-turn refiner unwired, since both write the same rows through the same version archive.use_skillis unaffected. Setting bothauto_refine_on_successandauto_refine_on_failureto false is refinement-off spelled the long way, and the engine leaves the worker unbuilt rather than skipping every turn.
7. Reflector (the orchestrator)
Section titled “7. Reflector (the orchestrator)”The deterministic harness. Owns when reflection runs and coordinates the workers above.
- Hooks: reflection runs on the node holding the seat. When a turn closes, the node that ran it publishes
turn_completed(the record) and areflection_duewake carrying that turn onto the seat’s own reflection subject (crewlet.agent.<seat-id>.reflect, groupagent-<seat-id>-reflect). The node that acquires a seat attaches that subject after hydrating the seat’s memory and lets it go on release, before the release’s last memory flush, as it does the seat’s sandbox control subject; a wake published while the seat is moving waits for the next holder. The subject is per seat because reflection writes the seat’s memory into the store of the node that runs it, and only the holder carries that memory onward and answers reads of it; a fleet-wide group would write rows no holder ever reads. A node withoutseatsreflects on nothing; a node withoutdatareflects on its seats exactly as a data node does (memory is node-local on both). - What a move costs. A release does not wait for a pass already running (the fenced release must not wait on an auxiliary model), so a pass that finishes after the flush writes rows this node no longer carries, lost like whatever the flush does not reach (what a crash and a handoff lose). A wake still waiting when a seat is removed from the company is deleted with the seat’s other subscriptions when its mailbox retires.
- One wake, not one per writer. Everything a seat learns comes from one turn and every writer is gated on the same questions, so one subscription means one redelivery window and one place to find a company that learns nothing.
- One dispatcher per process, not per config revision. A config apply swaps the org and worker set behind it; the subscriptions and the redelivery guard stay. Rebuilding per revision would empty the guard and classify a redelivery twice (two auxiliary calls, two rows for one fact). A refused worker set leaves the previous one serving: a stale org is a smaller wrong than not reflecting. A node that boots with no company builds the dispatcher on its first apply; a wake arriving earlier is acknowledged and logged (none can carry a turn, since no seat has run one).
- Gates, in order. Each is reported by name, per worker, per turn, so “this company never learns” says which gate closed:
- No workers — nothing is wired.
- No role — the turn came from a seat this revision no longer has (a seat whose handle changed is in this class: a removal and a creation). Learning about it would write memory under an identity nothing can read back.
- Per-role opt-out —
learning_enabled: falseopts a noisy or sensitive role out without disabling the subsystem. Unset inherits the company-wide setting. - No budget — the company or the seat is at its
token_budgetceiling, so the pass declines to start (a pass that discovers it is over budget has already spent its auxiliary calls). It sits before the duplicate ring because it is the one transient refusal: a turn skipped for it stays reflectable when the ceiling moves or its window turns over. A counter that cannot be read declines it too (budget_unknown): reflection is optional, and a pass run against a ceiling nobody could read is spend past a limit the company set. - Duplicate — a bounded ring of recently-processed RUN ids (not work keys: a redelivered trigger genuinely runs again and its reflection is a second pass over a second execution; the episode row’s work-key index collapses that). Reflection is not idempotent: each pass is a fresh auxiliary call that can write a differently-worded row for the same fact. The ring is per-process and not durable, so a second node reflecting the same turn writes a second diary row: the bounded duplication the engine promises, not exactly-once. It evicts past the bound, far outside any backend’s redelivery window.
- No engagement — the turn was skipped (
review_outcome: skipped), or finisheddonehaving called no tool. The agent processed nothing externally observable, and a fact read off the trigger would teach a directive it never received. - Per-worker skip — each worker states its own applicability: the persist decider must not run on an unsettled turn, the counterparty profiler must.
- Only a turn that did something is learned from. A turn engaged when it committed something (
movedorwords, the turn ledger’s outcome) or when a successful call of it could reach somebody outside the engine (actedonturn_completed: a reply through a chat vendor’s tools, which the ledger’s outcome does not count). Otherwise, however many tools it read with, no reflection pass starts (no diary row, episode, profile or skill) andreflection_skipped_no_engagementlogs the outcome andactedit was decided by. A turn with no stated outcome (a parked segment) keeps the older test: skipped, or done having called no tool. - Learning keeps to its share of the day.
learning.max_share(default 0.15) is the most of an agent’s company day of spend its learning may take. Every learning call (diary decision, profiler, synthesis, refinement, compaction, clustering, promotion) is counted on the agent’s learning counter beside its own; once the counter reaches the share, the next learning call is not made (learning_share_reachedin the log, the reflection worker skipped aslearning_share) until the next company day. The compaction the raw-episode cap asks for is counted and never held, since it keeps a seat’s rows bounded. 1 leaves learning uncapped. - Failure mode: every dispatch is best-effort and each worker runs under its own panic recovery, so one worker’s bug costs neither the remaining workers nor the sentinel. A failed worker logs and the next runs; a failed reflect never fails the parent turn. The handler always acks: a nak would redeliver a finished turn to spend more auxiliary tokens reaching the same conclusion.
What the turn event has to carry
Section titled “What the turn event has to carry”The node that takes a wake is the seat’s holder then, which after a move is not the node that ran the turn and never saw its trigger. Everything the gates read therefore rides on the turn_completed payload: the tool sequences, the outcome and the opt-out decision, the skills the prompt offered, the inbound interactions with senders resolved and each body’s label, and, for a wake with no interactions, what the turn was asked (ask) and whose words it was (ask_provenance). A missing field is a fact no worker can consult, and the gates fail open-looking: an absent tool sequence reads as “engaged with nothing”, silently skipping every worker on the successful turns worth learning from while the dispatcher reports a clean pass.
Prompt scaffolding
Section titled “Prompt scaffolding”Short, conditional guidance fragments are appended to the executor’s system prompt, only when the matching tool is registered for the role. They come from the Tool Skills registry (knowledge-base pages, such as Confluence, that operators edit at runtime), not engine prose. The bundled examples/tool-skills/ files ship ready-made versions:
| Bundled skill | Trigger | What it teaches |
|---|---|---|
examples/tool-skills/reflect-and-persist.md | tool: reflect_and_persist | Persist declarative facts, not instructions to yourself. |
examples/tool-skills/refine-skill.md | tool: refine_skill | Patch a loaded skill when it goes stale; don’t wait to be asked. |
examples/tool-skills/retrieval-research.md | any_of of query_episodes / search_knowledge / get_work_item / refresh_memory | The consolidated retrieval re-search rule, below. |
examples/tool-skills/observed-directives.md | any_of of the chat posting tools (post_message, reply_in_thread, send_dm, mattermost_post_message, slack_conversations_add_message) | Share team-relevant directives via the agent’s broadcast surface. |
examples/tool-skills/getting-unstuck.md | any_of of colleague-surface tools (post_message, reply_in_thread, send_dm, mattermost_post_message, slack_conversations_add_message, comment_on_work_item, comment_on_page, a2a_ask) | Manager-handoff conventions: when stuck, mention the manager on the surface where the problem lives. |
examples/tool-skills/channel-discovery.md | any_of of the room-listing, joining and posting tools of the company’s own chat (list_channels, join_channel, post_message) and Mattermost’s and Slack’s channel, post and user-search tools | How to choose the right room or surface, and how to fall back when membership is missing. |
The retrieval-research skill carries the consolidated retrieval re-search block. The three relevance prefetches (## Similar prior work, ## Relevant knowledge, ## Personal memory) derive from the triggering message as it stood at turn start, before any recon, so they share one rule: after recon gives a richer query, re-query the corresponding tool, even when the initial block already had entries. The skill’s preamble states it once, with one terse line per re-query tool: query_episodes, search_knowledge and refresh_memory. The body is fixed text, so all three lines reach every seat the skill is offered to, whichever trigger tool brought it. On a thin trigger the turn-start message is a bare pointer (the thin-trigger gate skips the prefetch); on a substantive one it is the whole message but still pre-recon.
Plus four always-on prefetch blocks (rendered when the data exists):
## Similar prior work— top 3 episode-search hits, each as what woke it (woken by:), its outcome and tools, what it was asked (asked:, fenced as whoever wrote it under the turn’s token) and what it did (what it did:). Whenlearning.summarize_episodesis on, the aux model summarises the same lines, each ask fenced under a token minted for that call. The summary reads each ask and account whole, up to a sixth of one auxiliary call’s input (about 11 KB, so three turns fit one call; past that a text is condensed first), because its briefing replaces the bullets. The bullets condense an ask or account past 600 bytes, asquery_episodesdoes, only where they are what the seat is shown: summary off, or not answering. Both render throughlearning.PastTurns: at most four rewrites run at once and all of one render’s share one thirty-second deadline (learning.EpisodeRewriteTimeout), here and inquery_episodes; a text no rewrite reached is named by its size. The block holds everything it asks a model (rewrites and summary) to one auxiliary deadline (prefetch.AuxTimeout, thirty seconds) past the recall: with the summary off it waits at most that for its rewrites; with it on, the bullets a non-answering summary falls back to get what is left of the same deadline. Worst case: the turn’s embed (two seconds) plus thirty seconds, the memory block’s own bound.## Personal memory— diary entries selected via hybrid vector ∪ recency candidate selection, then filtered for relevance to the current task / trigger by the aux model.## Synthesized skills you've learned— names + descriptions of the agent’s own synthesized skills, loadable viause_skill.## Relevant knowledge— knowledge-base pages from a live query-time search: the aux LLM generates a short search query from the trigger, and theknowledge.Searcherruns it scoped to the role’s accessible containers. See Relevant-knowledge prefetch below.
Plus the conditional prefetches:
## The thread so far— the chat thread this turn was woken in, read at turn start on the seat’s own chat credential and handed over. Rendered only for a chat thread reply (a top-level message has no earlier conversation). Bounded by whole messages (8000 bytes): past it, the messages between the root and the newest are condensed by the seat’s auxiliary model rather than dropped (left out with the count reported only where no rewrite can be had). The root and the newest of what was read always survive; a root with nothing readable (an alert app’s attachment-only post, a deleted opening) keeps its place as a line saying so. Senders are resolved through the party registry and the seat’s own replies marked. A thread that could not be read, one that was read and empty, and one too long for the backend to read to its end (newest messages missing) each render a different sentence. It is not a learning prefetch and not gated by the thin-trigger gate: it makes a thin trigger thick. See Agent Runtime.
First-turn onboarding is not a block of the executor’s prompt: it is a pass of its own before the executor, on its own budget; the executor neither reaches mark_onboarded nor is told to onboard. The pass’s prompt lists the Onboarding knowledge-base pages on the agent’s unit chain. Markers live in agent_onboarding_markers, keyed by agent_id and stamped with a chain_hash, so an org-chain change invalidates the marker and the pass runs again.
These blocks are layer 2 from the four-layer table above. The reflect engine (layer 4) runs whether or not the LLM follows them: the scaffolding is an optimization, not a dependency.
Personal memory prefetch + refresh
Section titled “Personal memory prefetch + refresh”The ## Personal memory block runs once at turn start (prefetch.Fetcher.personalMemory): it assembles a candidate pool of the agent’s diary rows, filters them by relevance to the trigger via the aux model, and renders a digest into the system prompt, which is not re-queried mid-turn.
Hybrid candidate selection
Section titled “Hybrid candidate selection”Fetcher.memoryCandidates returns the union of two top-K reads against the agent’s diary:
- Vector top-K —
learning.Diary.Recallranks by cosine distance against the diary’s embedding column, scoped to the agent’s id, to unexpired rows and to vectors of the query’s own model (embedding_model): two models of one width are two spaces, and a row from another is no match. The database computes the distance (vector_distance_cos), so only rows above the relevance floor cross the driver boundary. This catches topical / semantic matches. - Recency top-K —
learning.Diary.Recentreads the most-recent unexpired rows of the agent’s id. This catches broadly-applicable operational rules (“use semantic commit messages on every PR”, “always tag the security channel before merging auth changes”) that the vector half misses when the trigger is unrelated to the rule’s topic.
The sets are deduped by row id. Their sizes (50 each, memoryVectorLimit and memoryRecencyLimit) bound the pool (at most 100). The aux-LLM relevance filter judges from this pool. Pure vector would miss the broadly-applicable rules; pure recency falls off for long-lived agents with >100 LONG entries, where old-but-relevant rows never reach the filter.
PersistDecider’s write-side dedup reads the diary’s recency list alone (Diary.Recent, up to 50 rows), the right shape for “is this paraphrase already in the diary?”.
One person is named one way. The filter is told who triggered the turn (Current sender:), because its one hard rule rejects a memory about somebody not party to the task, and the persist decider attributes every fact to its requester. Both, like the counterparty profile block and the profiler’s prompt, name a person by name and then the identity that outlives a rename (seat handle or platform id): Sam (slack:U1) or Dev Bot (dev) (learning.Subject.Label). By name alone, two people called Sam on two surfaces would be one person to the filter.
Failure modes
Section titled “Failure modes”The prefetch filters against the salient inbound message, the raw message and not the notification builder’s enriched task description (see Salient-body sourcing). Two failure modes follow:
- Context-thin triggers (“yes”, “+1”, a thread reply with little content) — the filter has nothing to match on and the block is empty. If the agent has memory rows, the block then renders the gate-path hint nudging the seat to refresh after recon.
- Richer triggers can give a non-empty block, but the entries chosen at trigger time may not be the most relevant once the executor has read the thread / fetched the ticket / queried knowledge and learned what the conversation is actually about.
The refresh_memory(context_hint=…) builtin fixes both. The refresh_memory line of the bundled retrieval-research Tool Skill (examples/tool-skills/retrieval-research.md) tells the executor to call it after any tool call that materially changed its understanding, even when the initial block had entries. The tool re-runs the filter, and the similarity half of its pool, against the executor’s context_hint alone (its own account of the task once recon has made it real). It tells the filter who triggered the turn exactly as the turn-start filter was told, on the resumed half of a coding turn too, which re-reads no trigger and so is told the senders its turn parked with beside the ask. It returns the freshly-rendered digest as the tool result. Bounds:
- Per-turn cap —
learning.personal_memory.max_refreshes_per_turn(default 3). A hint beyond the cap is refused with the count spent, so the model learns the limit instead of silently no-op’ing. A hint whose filter call failed still spends its slot (else a failing call is retryable without bound), but retrying that same hint is allowed and re-runs the filter. - Idempotency cache — a repeat of a hint already used this turn (case- and whitespace-normalised) is answered from the ledger without a fresh auxiliary call, including an answer of “nothing bears on this”. It is free because it is answered from here; re-running the filter free would leave the cap bounding nothing, as a model alternating two hints could spend a completion per round forever. The filtered rows are cached, not the rendered text, so a repeat asking for a larger
limitgets the extra notes. - Per-turn isolation — state keyed by the RUN id (
turn_id, one execution; see a turn’s two identities) and bounded to the most recent 256 turns, far more than a node runs at once (nothing tells the tool when a turn ended, so the bound makes it a cache rather than a leak). Per run rather than per unit of work: a redelivered trigger runs with a fresh context and must not inherit the spend or answers of the attempt it repeats. State from one turn never leaks into another. - Frozen-prefix-cache safe — refresh output lands as a tool-result message, not a system-prompt rewrite, so the LLM provider’s prompt cache stays valid across iterations.
Relevant-knowledge prefetch
Section titled “Relevant-knowledge prefetch”The ## Relevant knowledge block surfaces team-published documents (playbooks, runbooks, ADRs, conventions, design docs, anything in the agent’s accessible knowledge-base containers) without the seat guessing names against use_skill or remembering to call the knowledge-search tool first. It runs a live knowledge-base search once per turn through the knowledge.Searcher seam (Confluence CQL, one backend per org). Its closest sibling is the Personal memory prefetch, which reads the private diary.
Why “knowledge” and not “skills”
Section titled “Why “knowledge” and not “skills””A special “team-skill” label for pages meant as procedures would reintroduce an operator-curated/synthesized skill split, two parallel skill surfaces to maintain, which the project avoids. A knowledge-base page is a knowledge-base page: the search runs against the agent’s accessible containers, the backend’s own relevance ranking decides what comes back, and the engine has no “skill” label for pages.
Source: query-time knowledge-base search
Section titled “Source: query-time knowledge-base search”For each turn:
- The searcher gate runs:
Searcher.CanSearch(seat, org), a cheap, no-I/O check that a search could return anything (the role has accessible containers, or its own backend credentials for an unscoped search). When it says no, the aux-LLM query-generation call is skipped entirely. - The role’s auxiliary model (
role.llm_auxiliary) turns what the turn was asked (its ask, not the integration’s wrapping, whose scaffolding would become search terms) into a short plain-text keyword query (the user prompt endsKnowledge-base search query:). Scope is not the aux model’s job: the searcher derives it from the org-wideknowledge.*list via accessible containers. There is no per-unit/role union: a unit’sspaceis integration identity (webhook routing + write home), not read scope. - The searcher runs the query as the agent’s own backend user (the seat’s Confluence credential from its
mcp_env, falling back to the org-level token) as a CQLtext ~ "..."clause narrowed byspace IN (...). The backend enforces page permissions, so restricted pages never appear; unreviewed auto-drafts are excluded by the query’s default ancestor exclusion (knowledge.AutoDraftedParent, “Auto-Drafted Skills”).
Loading full bodies
Section titled “Loading full bodies”The bullets render title + snippet, enough to decide which pages to open. For a full body or a fresh search the executor calls search_knowledge or the backend’s MCP tools, confluence_get_page / confluence_search. The block prose describes the capability, never a hardcoded tool name.
Hardening
Section titled “Hardening”- Show-nothing on a failed query. When query generation fails there is nothing to search with; the block renders nothing rather than erroring the turn.
- A search that did not run says so. When the backend could not be reached, or no copy of the knowledge base answered, so the outcome served no mode (
ServedModeempty), the block renders the could-not-be-searched hint (UnsearchedKnowledgeHint), neverEmptyKnowledgeHint. “Nothing surfaced” claims something about what the company has written down; told it, a seat concludes the page does not exist and writes a duplicate. Neither path errors the turn (Searchis best-effort by the seam’s contract), andsearch_knowledgeanswers a no-mode search the same way. - The gate-path hints render when the block would otherwise go silently empty, each pointing at
search_knowledgeas the mid-turn escape hatch.EmptyKnowledgeHintwhen the thin-trigger gate skipped the search or it ran and returned nothing (mirrorspersonal_memory’s hint);UnsearchedKnowledgeHintwhen the search did not run, which says nothing about whether a page exists. - Fenced as somebody else’s words. A page’s title and opening are written by whoever wrote the page, so the bullets sit inside one fence of the turn’s token (
knowledge.Render, shared withsearch_knowledge), labelledpage_bodyat the trust the finding backend decides: the engine’s own pages are a colleague’s with nobody named (every write there is a company principal’s, and the index does not say which); a Confluence page isexternalwith nobody named (a result never says one person wrote every word, and the site is not the company’s alone). The backend stamps that label on every hit (knowledge.Hit.Provenance), so a node rendering another node’s hit uses the finding backend’s label. A page that spells the turn’s closer stays inside; the pointer sentence after the list stays outside, being the engine speaking. - Frozen at turn start. The block is part of the system-prompt prefix, so a
self_iterateround reuses it and the provider’s prompt cache stays valid. - Once per turn. The query is generated and the search runs once; anything more the agent asks for.
The executor asks instead (thin triggers)
Section titled “The executor asks instead (thin triggers)”On a thin-trigger turn the turn-start prefetch is gated off (a query from a bare pointer is noise), leaving no relevant-knowledge block until the agent has done its recon inside the turn.
The search_knowledge builtin closes the gap. The gated block renders a hint to search again once the task’s real shape is known, and the executor calls the tool with a query it writes itself, over the same knowledge.Searcher seam, with the same auto-draft exclusion, as the same seat. The result is an ordinary tool result in the conversation the agent is already in; the frame that did the recon is the frame that searches, so the engine runs no second search between phases.
A backend that is unreachable, unconfigured, or scoped to nothing answers with a sentence saying which, rather than an empty block the agent must interpret.
Telemetry
Section titled “Telemetry”The turn-start prefetch_summary event records relevant_knowledge_hit, relevant_knowledge_bytes and relevant_knowledge_selection_count beside the other prefetch blocks. Where the hit is true, a non-zero selection count means real pages rendered; zero means a hint rendered instead: the gate-path hint (thin-trigger gate skipped the search, or it ran and returned nothing), the could-not-be-searched hint, or the still-indexing one. Pivot on this field to tell “no signal” from “hint nudge only”.
A block stuck at 0% hit rate over a representative window is almost always one of:
- No
knowledge.scopeconfigured and the agent has no per-agent backend credentials, so it can’t search unscoped (a credential-less / fallback-token agent with no containers searches nothing, andCanSearchgates the whole prefetch off). - No
integrations.confluenceconfigured, so no searcher is wired, or no pages in the read scope match. Also check the seat’s own page permissions: the search runs as that account, so a space it cannot read contributes nothing (see Confluence § Knowledge search). - Aux LLM unavailable (
llm_auxiliarynot configured and the role’s primaryllmdoesn’t resolve as an aux provider), so query generation cannot run.
Thin-trigger gate
Section titled “Thin-trigger gate”All three relevance-driven turn-start prefetches (## Personal memory, ## Relevant knowledge, ## Similar prior work) run an aux-LLM call against the bare trigger before any recon. For a self-contained trigger (a full task assignment, a detailed issue body) that is high-value.
For an event-driven turn the trigger is a pointer, not the context: a Jira webhook says “POC-518 got a comment”, a Slack reply says “+1”; the context exists only after the agent fetches the issue or reads the thread. Filtering on the bare pointer is near-guaranteed low-value, and rendering “nothing matched, go look later” wastes prompt space, so the common webhook turn would pay twice for a result the agent redoes via tools.
The gate skips the aux call when the trigger is a pointer. It is pure logic, no LLM call: the decision is read from notification metadata (issue_key / thread_ts / event_type).
| Stage | Carries the signal |
|---|---|
| Notification builder | notify.Prompt.RequiresRecon: true when the trigger is a pointer at the real thing rather than the thing itself. Jira and Confluence page events (whose prompt carries a ## Get full context block naming what to fetch), GitHub review_requested (the diff must be read), chat thread replies (the engine hands the thread over at turn start). The generic builder returns false, because its body is the message. |
| the notification service | Carries the builder’s answer onto the notification it publishes, so nothing downstream re-derives it. |
| The inbound interaction | The flag is read off the trigger event into the interaction: the one normalized, platform-agnostic property workers may branch on (not an event-type check). A coalesced trigger yields one interaction per constituent message, all carrying the event-level merged flag, and the whole-trigger predicate is true when any is. A2A and internal task_assigned triggers carry their own context, so always false. |
| Prefetch | All three relevance prefetches read it. When set, skip the aux call (personal memory: the relevance filter; relevant knowledge: query generation and live search; episode recall: the vector query). All three render a gate-path hint so the block stays visible and self-explanatory: EmptyMemoryHint, EmptyKnowledgeHint and EmptyRecallHint respectively. The matching per-tool line in the retrieval re-search guidance carries the same nudge. |
The signal lives at the builder because the builder decides whether its trigger is a pointer; classifying from event.type downstream would duplicate that decision and let the two drift. A token-count heuristic fails: a webhook task_description is long (title, event metadata, the prompt’s own ## How to handle this scaffolding) but thin on substance.
Per block on a thin trigger:
- Personal memory still does its cheap diary recency list (a DB read, no LLM) so it renders the hint only when the agent has memory rows to refresh. The vector half and the aux filter are skipped; nothing is embedded.
- Empty ask: a trigger whose ask is empty is gated the same way (nothing to judge relevance against);
trigger_requires_reconstays the builder’s flag and reads false for it. This is rare: a chat parser drops a message with no text before routing and an attachment arrives as a line naming the file, so it is a wake carrying nothing readable as an ask (a source sending neither subject nor message, or an event whose payload holds no text). - Relevant knowledge skips query generation and live search; it only needs
CanSearchto confirm a search could return anything (so the search-tool nudge is actionable) before rendering the hint. - Episode recall skips the vector query and renders its hint unconditionally: the only way to know whether an agent has matching past episodes is the vector query the gate skips. The hint is conditional (“if this task resembles something you have done before…”) so it reads correctly for an agent with no episodes.
Observability. The summary’s trigger_requires_recon records the gate decision once per turn. Without it a gated prefetch and a filter that ran-and-found-nothing look identical (false *_hit, zero selection count); with it, an empty ## Relevant knowledge block is distinguishable as gated rather than broken. The trace view’s summary line shows the count of blocks that hit out of eight (prefetch: N/8 hits), marked as a thin trigger with its filters gated when the gate fired. The denominator is the length of the engine’s block list, so a newly added block never reads “9/8”.
The prefetch is thus an optimization for rich triggers; for event-driven turns the tool-call path is the primary retrieval path and re-query-after-recon is the expected pattern. The agent pulls mid-turn via refresh_memory / search_knowledge / query_episodes, guided by the retrieval re-search guidance.
Two blocks are not gated, deliberately. The first is ## The thread so far: on a chat thread reply the gate fires because the trigger is a pointer, and the thread is what it points AT, so gating it would withhold context on the turns that need it most. Reading it is one HTTP call on a credential the node already holds (no embedding, no aux LLM), so the gate saves nothing. The flag stays true regardless: it describes the trigger body, and the three filters still have only “+1” to judge by.
The second is the conversation’s own session. A pointer-shaped trigger is very often a follow-up on a conversation this seat already worked (the second comment on POC-518, a reply in a thread it answered yesterday), and its turn continues the session the conversation’s last turn left, told how the earlier turns ended. That lookup is a keyed read of the executor log on the trigger’s conversation identity, not a similarity match: no embedding, no aux LLM, nothing for the gate to save. So when all three prefetches go quiet, the seat still arrives with what it last said and did in this conversation, which stops it answering the same question twice while it re-reads the thread.
Salient-body sourcing
Section titled “Salient-body sourcing”The relevance prefetches, the counterparty profiler, the PersistDecider, and refresh_memory all reason about what the sender said, not the notification builder’s scaffolding.
A source’s notify.Prompt builds the enriched body: for a Slack message, the sender, the seat’s handle and id, the ## Triage guidance (or, on a message the engine reads as addressed, its verdict) before the message, and the channel, thread and mention lines after it. It becomes the turn’s task text (the executor needs the triage contract). A relevance judgement against it is made mostly against scaffolding identical on every Slack turn: embedded, it dominates the vector, and its names for the seat and its groups read to a model as people, roles and search terms.
So the raw message rides separately. The notification’s SalientBody carries the inbound body verbatim beside the enriched body. InboundInteraction.body is sourced from it (falling back to the enriched body for events with no salient_body); a coalesced trigger sources one interaction body per constituent message, and the merged notification’s salient_body is those messages joined chronologically with sender attribution (Alice: …).
The turn’s ask. At turn start the engine derives from the trigger what the turn was asked (prefetch.Request.Ask), beside the executor’s task: each notification’s salient body, led by its subject where the source says the subject is part of what was sent (an issue’s key and title, a page’s title, a monitor’s alert, a tracker comment’s topic); a chat message’s subject is only the surface’s name (“Slack message”), so a chat turn’s ask is what was said (notify.Prompt.SubjectIsLabel, stamped on the wake as subject_is_label); a coalesced burst’s merged salient body; a colleague’s question with who asked; a schedule’s name and task. Every relevance judgement is made against it:
| Surface | Reads |
|---|---|
| Counterparty profiler / PersistDecider | InboundInteraction.body, one entry per constituent; the PersistDecider is also shown turn_completed.ask for a wake with no interactions (a colleague’s question, a schedule’s task) |
| Synthesizer / Refiner | the turn’s ask as turn_completed records it: the interactions’ bodies, or its ask |
| The episode’s vector | the turn’s label, its ask and what it did, as one text; see Episodes |
## Personal memory prefetch | the ask: the similarity half’s vector, and the aux filter prompt |
## Relevant knowledge prefetch | the ask: aux-LLM query generation + knowledge-base search |
## Similar prior work (episode recall) | the ask: the vector query, and the episode summary prompt |
refresh_memory | its context_hint, the executor’s own account of the task after recon |
turn_completed holds its ask and every interaction’s body redacted, so every surface reading them after the turn reads them redacted; the turn-start prefetch reads the ask as it came.
The three auxiliary judgements read the ask fenced. The memory filter, the knowledge-query writer and the episode summary are model calls handed, on most wakes, somebody else’s words, and their answers decide what the seat is shown. Each reads the ask inside a fence labelled as the trigger labels the same body (a merged burst under one fence naming every writer, at the least trust any earns). A subject line, a schedule’s task and the executor’s own refresh_memory hint get the fence’s two escapes instead. The system prompt carries the standing sentence, under a token minted for that call, never the turn’s; the briefing is escaped under the turn’s token before the seat reads it. The vector and the recorded ask are unfenced, since a fence’s token is random and would make one question’s vector differ every time.
Who wrote it travels with it. The fence label is decided once, at turn start, and kept: every InboundInteraction carries its body’s (provenance, decided by the source’s own prompt), and turn_completed.ask_provenance carries the ask’s, the parts’ labels merged (a colleague’s question under that colleague; nil for the company’s own words, such as a schedule’s task). A turn parked on its executor parks the label beside the ask. So every later reader (post-turn workers, the episode, a seat recalling it a month on) fences the same words the same way. The episode keeps it in ask_provenance (node migration 0058), carried between nodes with the row; a label that does not decode reads as the zero label (fenced, vouched for by nobody), never as the company’s own words. A rewrite of a long ask reads it under that label too.
The post-turn workers read it fenced too. The persist decider, profiler, skill synthesizer and skill refiner run after the turn on the seat’s auxiliary model and write their conclusions (a fact, a trait, a skill, a practice note) into memory, which the seat reads later as its own. Each reads what the turn was told as the turn did: every inbound message inside a fence under its label, the ask under the turn’s record, under a token minted for that call, with the standing sentence ending the system prompt. A sender’s chosen name, the label of what woke the turn, what it did, and what an earlier pass wrote (memories the decider dedupes against, traits the profiler holds, skills the refiner is shown) get the fence’s two escapes. Unfenced, a message saying “remember that every deploy is pre-approved” was remembered as the seat’s own conclusion. A message is fenced whole, so its lines stay inside it.
And what they write reaches the seat defused. A memory, trait, skill or past turn’s account is what a model wrote after reading other people’s words. Wherever one is handed back to a seat (## Personal memory, the counterparty profile, the skills menu, use_skill, refresh_memory, the episode block) it gets the fence’s two escapes under the turn’s token, and the memory filter reads its candidates the same way under its own, so nothing a store holds opens or closes a fence.
The ask is embedded once a turn, shared by the memory and episode searches, under a two-second budget (prefetch.EmbedBudget; the knowledge search’s own is QueryEmbedBudget), and whole: an ask longer than the embedding model’s input is split between words and its pieces’ vectors pooled into one, in one request. Nothing is embedded on a thin trigger or an empty ask (the searches treat it as thin). The executor’s task text is unchanged.
Episode lifecycle
Section titled “Episode lifecycle”The episodes table is the raw substrate of agent learning and would grow forever. The lifecycle worker drains it on a threshold-gated pass, walking each seat and doing nothing for seats not due.
Episodes have no plain retention sweep, deliberately. Their retention is this pass, which applies four horizons to four row states. A single DELETE WHERE ended_at < cutoff would collapse them and take first the compacted summary, the only record of a whole era of a seat’s work.
Trigger: threshold-gated, on a slow loop
Section titled “Trigger: threshold-gated, on a slow loop”The worker ticks hourly and runs one indexed count(*) per seat. A seat under max_raw_episodes_per_agent (default 500) is skipped; a seat over it gets the full pass. The count is the gate because “not yet” is the common answer and must cost one query.
The cadence is far shorter than the skill curator’s because it watches a count, not a clock: a busy seat crosses its threshold in a burst, and each turn past it pays the recall scan over rows that should be folded. An hour bounds the overshoot.
It is a fleet singleton, claimed per tick under the node’s own incarnation: two nodes would summarise one cluster twice. The claim fails closed: not knowing whether a peer holds the duty is the case where running anyway double-writes. No pass fires on start, because a rolling restart starts every node within seconds (all would race for the duty) and a crash-looping node would spend tokens on every restart.
The loops are the process’s, and the passes are the revision’s. A node arms the four background loops (episode lifecycle, skill curator, clustered synthesis, promotion) once, whatever its company configures and with no company at all; every config apply hands them the passes that revision turns on, built from its models, credentials and knobs. A loop keeps its clock across an apply: a newly enabled pass runs at the loop’s next tick; a changed cadence (skill_curator.interval_hours, skill_synthesis.scheduler_interval_seconds) restarts from the apply; an unchanged one keeps its next tick, so a company edited more often than its curator ticks still curates. A loop whose pass is off claims no duty. So a fresh node’s first company (every dashboard-created company) runs its passes without a restart, and compaction, clustering and promotion (the three that call a model) start on the apply that gives a company with no providers.llm its first provider.
Compaction needs a summarizer. The pass folds a cluster by asking the seat’s own llm_auxiliary chain to describe what its members had in common, per seat, so each seat’s memory is compacted by its own model. With no auxiliary model configured anywhere the pass does not run: what it could still do is delete, the half an operator least wants unsupervised. Rows stay raw and readable.
One worker, four actions
Section titled “One worker, four actions”For each seat over its threshold the worker runs:
- Drop non-terminal episodes older than
non_terminal_max_age_days(default 14).self_iterateis a mid-state: the reflect engine’s terminal-outcome gate already excludes it from skill synthesis, and it only feedsquery_episodesas noise. SQL DELETE; no LLM. - Drop tool-free turns older than
tool_free_max_age_days(default 90). A turn with no tool calls cannot be compacted (clustering pools by tool-sequence overlap), so a chat-only seat’s raw rows would grow for the deployment’s life and each be scanned and cosined at every turn start. The horizon is far longer than its neighbours because this drops the only record of real work: a fact worth keeping past a quarter belongs in the diary viareflect_and_persist. SQL DELETE; no LLM. Its deletions are irrecoverable, soepisode_lifecycle_passcarriestool_free_droppedbeside the other per-pass counts. Watch it before shortening the horizon: theCompactionCompletedevent folds the same number intonon_terminal_dropped, so the log is the only place it is visible alone. - Drop skill-consolidated episodes older than
consolidated_grace_days(default 30). The synthesizer stampsconsolidated_into_skill_idon each source row of a drafted skill; the skill now carries the learning, and the grace lets operators audit bad consolidations first. - Compact the rest. Takes the oldest
compaction_batch_size(default 200) remaining raw episodes older thancompaction_min_age_days(default 30) that a fold could take: never a tool-free turn (nothing can pool it) nor a summary’s retired exemplar (kept raw on purpose); both would collect at the old end and take batch slots until a pass found nothing to fold. It greedy-clusters them by tool-sequence Jaccard and, for each cluster of at leastcompaction_min_cluster_size(default 3), calls the role’sllm_auxiliaryto summarise into a compacted row (common_task_pattern,common_outcome,subjects_involved,notable_patterns). The row’ssuccess_rate, and thereview_outcomederived from it, are computed from the members’ own outcomes, never asked of the model (whose word once filed a 90%-failed cluster underdone). It writes onekind='compacted'row and deletes the originals except 2-3 exemplars kept raw for drill-down (the row’sexemplar_turn_ids). Each member reaches the call as its task, outcome, whole tool sequence and date. A task or outcome past 280 bytes is first condensed by the seat’s auxiliary model and labelled(condensed), never cut (a stack trace’s first 280 bytes is not what the turn was for); one whose rewrite fails is carried whole. A long-lived seat’s outcomes are mostly over that line, so a full cluster is a few hundred small rewrites, run four at a time, charged to the seat like any auxiliary call. - Optional: evict ancient compacted entries older than
compacted_max_age_days(default 0 = disabled). A hard long-tail storage cap; off by default since compacted summaries are 10-100× smaller than the rows they replaced.
Two physical row shapes share the same table
Section titled “Two physical row shapes share the same table”episodes rows distinguish on kind:
| Field | kind='raw' | kind='compacted' |
|---|---|---|
count | always 1 | N original episodes collapsed |
task_summary / plan_summary / tool_sequence / review_outcome | per-turn detail | the cluster’s common values |
started_at / ended_at | one turn’s timestamps | the cluster’s window |
common_task_pattern / common_outcome / subjects_involved / notable_patterns | unused | LLM-summarised aggregate |
success_rate | unused | the share of members that ended done, computed |
exemplar_turn_ids | empty | 2-3 raw rows kept as drill-down anchors |
consolidated_into_skill_id | set when a skill drafted from this row | always NULL |
Similarity recall reads raw rows only. A compacted row would read in a prompt like one turn that did everything, so it is never embedded and learning.Episodes.Recall filters on kind = 'raw'. Time-window reads return both kinds, and callers branch on kind:
query_episodesbuiltin: itsquerypath is similarity, so raw only; its recency andconversationpaths return both, rendering a compacted row as its pattern, count, outcome tally and variations.## Similar prior workprefetch block: similarity, so raw only.Synthesizer: raw only, on both paths. Aggregates are too coarse to draft a skill body from, and the clustered pass would count one fold as one turn.Refiner: reads no episodes. It is shown the skills the turn was offered and the turn itself (what woke it, what it was asked, what it did, tool sequence, outcome).
What this protects
Section titled “What this protects”- Storage growth:
max_raw_episodes_per_agentis when a pass runs, and it binds: a seat holding that many raw turns folds settled tool-using turns down to the synthesizer’s window (skill_synthesis.cluster_window_hours, a week by default) rather than waiting forcompaction_min_age_days, so raw rows stop growing without the synthesizer losing a turn it would draft from. A pass removes mid-state turns after 14 days, tool-free after 90, absorbed after the grace, and folds settled tool-using turns past 30 days into summaries ~10-100× smaller. Not bounded: a settled tool-using turn that never joins a cluster of three stays raw for the seat’s life, as do each fold’s two exemplars unlesscompacted_max_age_daysevicts them; and a pass clusters only inside its batch of the oldest candidates, so turns of one kind spread thinner than three per batch are never folded, and once the batch’s oldest rows are all such turns it folds nothing. - Recall pollution: non-terminal noise drops fast; old patterns become aggregates instead of crowding similarity hits.
- Learning drift: once a skill captures a workflow, its source episodes leave the seat’s view (after grace), so the agent is not shown stale per-turn detail.
- Long-tail signal preservation: routine work that never becomes a skill survives as a compacted aggregate, so the seat can still answer “you’ve done this kind of work N times”.
What does NOT happen
Section titled “What does NOT happen”- No work on the caller’s path: nothing about compaction runs inside a turn; reads and the write that crossed the threshold pay no latency.
- Compaction never feeds skill synthesis: the hierarchy is one-directional (raw → skill, raw → compacted). A compacted entry is never re-promoted; if the pattern recurs, the new raw episodes form a fresh cluster.
- No work for idle seats: a seat under its threshold costs one indexed count per tick.
Skill curator
Section titled “Skill curator”A synthesized skill nothing uses should leave the catalogue, and one used again should return. That is a clock, not an event, so it is the second background pass: a fleet singleton on the same claim discipline as the episode lifecycle, ticking daily, because its transitions are measured in tens of days and an hourly pass would make the same zero transitions 24 times a day.
The state machine is active → stale → archived on disuse, and stale → active on use:
| Transition | When | Effect |
|---|---|---|
active → stale | unused for stale_after_days (default 30) | Still listed and loadable; the prefetch renders it with an ageing marker. |
stale → archived | unused for archive_after_days (default 90) | Listings hide it and the loader refuses it. Archived is not deleted: the row stays readable, so restoring one is an operator edit, not a re-synthesis. |
stale → active | the skill is used again | Revival happens in the same transaction as the use, so the skill is in the very next turn-start prefetch, not after the curator’s next tick (up to a day on the default schedule). |
An archive window inside the stale window is a misconfiguration (taken literally it archives rows the same policy calls fresh); it is widened to the stale window.
Skills the operator has pinned are exempt from every automatic transition. Nothing promotes a skill to pinned.
Being offered is being used
Section titled “Being offered is being used”A skill’s staleness clock is its last-used stamp, moved by the turn-start prefetch offering the skill, not by the model loading its body. A rendered skill is in the catalogue and what the seat is asked to work from; whether the model loaded the body is about that turn, not the skill’s currency. Keying on the load would age out every skill whose menu line was enough: the well-written ones.
The ids follow the prompt’s character budget: a skill whose menu line did not fit was never offered, so its clock does not move. A stamp that cannot be written is announced as a telemetry failure, because an operator must see a clock that stopped before the curator archives a hot skill. Without this the catalogue would age out over a quarter while the prefetch shows it to a model throughout, and the menu would simply get shorter.
Telemetry harness
Section titled “Telemetry harness”Without per-surface measurement an operator cannot answer two questions about the learning loop’s artefacts (synthesized skills, diary entries, counterparty profiles, episodes):
- Are skills being used? Berlot-Attwell et al. (2024) showed that in some library-learning systems the apparent gain from skill induction comes from extra LLM sampling, not skill reuse. Whether Crewlet’s skills earn their keep is empirical and needs telemetry.
- Are the turn-start prefetches actually firing? A block stuck at 0% hit rate (e.g.
episode_recallempty every turn) is almost always a configuration or data problem, visible only if hit / miss is recorded.
| Surface | What’s tracked | Where it lands |
|---|---|---|
synthesized_skills.use_count / load_count / last_used_at | Per-skill offer count, load count and latest-use timestamp | use_count is bumped by learning.Skills.MarkUsed, called from the SkillUse reflection worker for every skill a turn was offered; load_count by learning.Skills.MarkLoaded, called from the use_skill builtin after a successful resolution. Both revive a stale skill. The seat’s Memory tab and Doclet’s learned skills show offers, loads and load rate (loads over offers; none for a never-offered skill). |
skill_used event | One per use_skill(name) resolution (source_kind: synthesized) and per load_tool_skill(key) (source_kind: registry, naming the tool skill’s page in source_page_id / source_container) | crewlet.events.skill_used; correlated to the host turn via trace_id / span_id. |
knowledge_read event | One per knowledge-base read (a get_page, a search_knowledge, the turn-start knowledge block, a tool-skill load, a phase’s tool-skill catalogue), naming the pages reached. See Knowledge System § What agents read. | crewlet.events.knowledge_read. |
skill_synthesized / skill_refined / skill_promoted events | Lifecycle markers: induction, refinement, cross-agent promotion | crewlet.events.skill_*; the dashboard groups them by trace. |
prefetch_summary event | One per turn after the six context prefetches resolve: per-block hit (bool) + bytes (rendered size), the knowledge selection_count, the chat thread’s thread_context_posts / _read / _stopped_short, the trigger_requires_recon gate decision, and turn_embedding, what became of the one vector the memory and episode searches rank by: embedded, failed (the embedder refused or missed the two-second budget, so those searches did not run; an empty ## Similar prior work is then not “nothing similar”), unconfigured, or absent where no search asked for one. Every block but the knowledge and chat-thread ones (which say in words when their source could not be read) degrades silently, so this is the only signal distinguishing an unreachable store from one with nothing to say. | crewlet.events.prefetch_summary, once per turn. |
persist_decider_completed classification / ttl_until | Tier label (LONG / SHORT / DOC / NOOP) + TTL on SHORT writes | Existing event, extended so dashboards can plot each agent’s tier distribution. |
learning_health SQL view | Per-agent rollup: total_skills, skills_used_at_least_once, total_skill_uses (offers), total_skill_loads, skill_load_rate (loads over offers, NULL when nothing was offered), most_recent_skill_use, avg_uses_per_skill, avg_skill_age_days | Created by the store’s 0002_learning.sql migration, rebuilt with the loads by 0065_a_skill_counts_its_loads.sql; query it directly from the store. |
Berlot-Attwell threshold
Section titled “Berlot-Attwell threshold”The load-bearing metric is avg_uses_per_skill from learning_health, with the literature’s working threshold:
avg_uses_per_skill < 0.1 → the library isn't doing what it claims; investigate retrieval, granularity, or whether the gain is just from extra samplingA new agent sits at zero until alive long enough to retrieve. Combine with avg_skill_age_days to discount young rows.
Best-effort rule
Section titled “Best-effort rule”Every telemetry write (Skills.MarkUsed and Skills.MarkLoaded, the skill_used and knowledge_read publishes, the prefetch_summary publish) is best-effort: a failure is logged once and swallowed so the host path (skill load, turn) is never broken by measurement. Test mode (no event queue / no DB) is a silent no-op.
What the auxiliary calls cost
Section titled “What the auxiliary calls cost”Every completion made on a seat’s behalf, the auxiliary calls here included, is charged to the seat’s token_budget counter and the company’s, in the windows current when it returns. ONE SEAM does it for the auxiliary calls: the learning workers, turn-start prefetch, every compaction and a person’s answered question resolve their model through the engine’s auxiliary seam, stating whose cost the call is (its stage: turn, reflection, background, operator; its purpose; the turn it serves). The seam charges the call and records an auxiliary_spend event, so a worker added later is charged and counted without wiring. A call whose attribution names no stage or purpose is refused before a model is resolved. An auxiliary call’s size is known only from its answer, so each is recorded after it returns, past the ceiling included; where a gate reads the room left first, it decides whether the work starts at all. See Budgets and spend § Auxiliary spend for where each stage’s spend is drawn:
| Path | Calls | Gate before it starts |
|---|---|---|
| Turn loop | every round of a phase on the engine host: the reviewer’s, a delegated worker’s, the onboarding pass’s | the round’s own meter |
| Round-cap extension judge | one call per exhausted phase | the turn’s meter, asked before the judge is consulted and again once its evidence is condensed; charged on it after it answers |
| Executor run | the seat’s executor: its harness’s whole run in a box, whose requests the engine never sees one by one | the turn_engine.executor_min_budget_tokens floor with the launch’s brief beside it, left in every capped window of the seat and company at each launch; the run’s spend is post-charged once, when collected |
| Turn-start prefetch | memory filter, knowledge query, episode summary | the budget park: a seat with no room has its delivery parked, so no prefetch runs; then the turn’s meter, as for in-turn calls |
| In-turn rewrites | every rewrite the turn’s ledger, judge, tools and workers need | the turn’s meter: a window one fills is held before the next round is sent, and none is made while it holds a full window, except the task card’s, written after the last round as the turn’s record |
| Reflection pass | persist decider, profiler, refiner, single-turn induction | the pass’s no-budget skip |
| Background learning | episode compaction, clustered synthesis, skill promotion | the same pre-flight as reflection’s: before its first model call each pass reads the seat’s and the company’s capped windows (the company’s alone for a unit a person leads), and one with no room, or whose counter cannot be read, does not start and runs again at its next cycle, its declines counted by crewlet.auxiliary.declined. The probe of a model entry parked at its usage limit is the one background call it does not hold: it is how the entry is found usable again |
Integration points
Section titled “Integration points”| Touchpoint | Role |
|---|---|
internal/engine (the turn’s telemetry) | Emits turn_completed when a turn closes, carrying what the reflection gates read: what the turn did, what it was asked where no interaction says (ask), its outcome, the final round’s tool sequence and every tool name called, the review outcome, the skills the prompt offered, and the inbound interactions with senders resolved. |
internal/agent/prompts | The executor’s prompt builder injects guidance blocks gated on tool availability. |
internal/knowledge, internal/confluence | The knowledge-search seam and its one backend, the Confluence searcher (CQL), backing the ## Relevant knowledge prefetch and search_knowledge; the org-wide read scope narrows it by space. See Knowledge System. |
internal/agent/builtin | Builtins, registered into internal/tools: query_episodes, reflect_and_persist, refresh_memory, refine_skill, use_skill, mark_onboarded. |
internal/events | turn_completed, episode_written, persist_decider_completed, counterparty_profile_updated, reflection_completed, skill_synthesized, skill_refined, skill_promoted, skill_used, skill_staled, skill_archived, skill_revived, skill_telemetry_write_failed, prefetch_summary, knowledge_read, compaction_requested, compaction_completed. |
internal/store | Holds episodes, agent_diary and the dashboard’s event log, in the node’s own file. |
internal/learning/memsync | Makes that file a cache, not the only copy: every memory row is published to a compacted changelog on the stream, and a node acquiring a seat replays it into its store before the mailbox attaches, a table at a time so a skill is written before its versions. A row not carried yet is the file’s alone, which is what a crash or lost file costs. Without it a seat that moved node would forget everything. See A seat’s memory follows it. |
internal/learning/memread | Reads a seat’s memory from the node that HOLDS the seat (the copy memsync keeps current): the reader follows the seat’s lease, answers here, asks the holding incarnation on an ephemeral scatter, or answers empty for a seat no node holds; every answer names who gave it (held_by). Every node answers for the seats it holds. The OVERVIEW (memory_overview) is the same rule for every agent at once, in one round: one listing of the seat leases, one scatter naming each holder’s seats, one reply per holder, and a coverage naming any holder that did not answer. See A seat’s memory follows it. |
internal/learning | The reflect dispatcher (Reflector) and per-turn workers (PersistDecider, Episodist, Profiler, SkillUse, Synthesizer, Refiner), the background passes behind Background (episode Lifecycle, the skill curator, clustered synthesis, cross-agent Promoter), Skills for synthesis and refinement, Diary, and the onboarding marker store. The turn-start prefetches are internal/agent/prefetch. |
internal/config | learning: block: per-role enable flag, reflection budget, promotion thresholds, lifecycle knobs. See Configuration. |
internal/api | GET /agents/{id}/memory (and the agent_memory query) serves the diary, episodes, synthesized skills and counterparty profiles (each a page with its counted total), plus the latest reflection and when the seat onboarded, for the seat page’s Memory tab, its Overview and one agent’s page under Doclet › Agent diaries; the memory_overview query serves that screen’s list: every agent seat’s totals and newest note, each counted by its holder. Rows are projected by memread, not marshalled from the domain types. See API endpoints. |
Data model summary
Section titled “Data model summary”A seat is keyed on its handle
Section titled “A seat is keyed on its handle”A seat’s handle is its identity and immutable: a document that changes one removes the seat and creates another (ADR-0013). Every table below names a seat by it: agent_diary and agent_onboarding_markers by the agent id derived from it; episodes, both skill tables and counterparty_profiles (observer and, for a colleague, subject) by the handle itself (agent_handle, observer_handle, subject_handle). Memory replication carries a row between nodes by its column names.
| Table | What it holds | Keyed by |
|---|---|---|
episodes | One row per completed turn (raw) or per cluster (compacted) | id; indexed by started_at |
agent_diary | The agent’s private observation log; rows carry an embedding and its embedding_model for the vector half of the ## Personal memory prefetch’s hybrid candidate selection | id; indexed by agent_id, created_at; no vector index: recall is a per-agent scan the database ranks |
synthesized_skills | Auto-drafted skills, agent-scope | id; unique on (agent_handle, name) |
synthesized_skill_versions | Refinement history | id; references skill_id |
counterparty_profiles | One row per (observer, subject, platform) | composite |
agent_onboarding_markers | mark_onboarded bookkeeping | agent_id (PK) |
Shared knowledge has no table here: on Doclet it is rows in the REPLICATED estate (pages and their derived vectors), and on Confluence there is no local copy, only a live query (see Knowledge System).
Deliberate non-goals
Section titled “Deliberate non-goals”- Single-user persona model. Crewlet is multi-party; a counterparty profile is per-identity and observer-scoped.
- Model-level fine-tuning as a core feature. Optional, downstream of a stable trajectory dataset. No role requires a learning-aware model.
- Cross-org knowledge leakage. Synthesized skills are agent-scope only; cross-agent promotion lands as a knowledge-base draft for human review, not an engine-side row.
- Black-box self-modification. Every synthesized skill edit is versioned and rollback-able. Counterparty profiles are written through a single observer, never auto-merged.
- Auto-promotion of casual remarks to team rules. A directive issued in Slack to one agent reaches another only when (a) a human or authorized agent updates the relevant knowledge-base page, (b) the receiving agent broadcasts to the team, or (c) someone with structural authority decides to formalise. Personal counterparty-profile observations are never auto-promoted to unit-shared knowledge.
- A monolithic “learning agent.” Six small, independently testable components beat a single reflective super-loop.
Prior art: Hermes Agent
Section titled “Prior art: Hermes Agent”The learning subsystem was designed with Nous Research’s Hermes Agent as a reference, reimplemented rather than depended on. Hermes is a vertically-integrated single-user CLI agent, not a library: its memory manager, skill tools and session search are threaded through a 600k-line monolith assuming home-directory storage, a single user and agent, and no hierarchy, incompatible with Crewlet’s org model. Several of its design choices are adopted:
| Hermes pattern | Adopted where |
|---|---|
| Conditional prompt-guidance blocks injected only when the matching tool is registered | Prompt scaffolding |
| “Declarative facts, not instructions to yourself” memory-writing rule | PersistDecider writing-style rule |
| “Patch skills on encounter; don’t wait to be asked” | Refiner patch-on-encounter norm |
| 5-tool-call default threshold for treating a turn as skill-worthy | Synthesizer default trigger |
| Cheap auxiliary model for summarizing session/episode-search hits | query_episodes + ## Similar prior work prefetch |
| Frozen memory snapshot at session start for prefix-cache stability | Context prefetches frozen at turn start |
Pluggable MemoryProvider interface (mem0, honcho, supermemory, …) | Validates the agent_diary store shape |
Explicitly rejected:
- Monolithic CLI coupling: Hermes’s learning loop is threaded through its agent entry point; ours sits behind the
EventQueueas its own package. - LLM-nudge-only triggers: Hermes fires only if the model invokes the tool; ours pairs nudges with the deterministic reflect dispatcher.
- Single-user
USER.mdpersona: replaced by multi-party counterparty profiles keyed by(observer, subject, platform). - Home-dir file storage: replaced by tables in the engine’s own store, each row carrying its embedding and source model (no vector index; recall is a per-seat scan the database ranks).
- Unversioned skill overwrites: Crewlet keeps prior revisions for rollback.
- No model fine-tuning requirement: Hermes also runs on stock models; Crewlet’s in-engine learning never touches weights.
Part of Crewlet. Generated from crewlet/crewlet main at 3f5565e.