Skip to content
runward
runward
Product
Who it is for
Trust
Documentation
News
Try it on an example Talk to us

Docs · The doctrine · Section 08

Asynchronous work and scheduling

A quality agentic system does little while the user waits, and a great deal while their back is turned. The interactive turn stays thin; heavy, costly, or deferred work is pushed to the background. This section is the runbook for that separation: what runs synchronously, what runs asynchronously, through which triggers, and under which safeguards.

Guiding rule: anything not needed for the current turn's response leaves the turn. Extraction, consolidation, synchronization, summaries, reminders: in the background. The interactive turn pays only for indispensable latency.

Two regimes: event-driven and scheduled

RegimeTriggerUse
Event-drivenA business event is emitted (turn end, session close, reminder created)Immediate reaction but off the turn: processing starts as soon as possible, without blocking the user.
ScheduledA clock (cron expression) fires at a fixed timePeriodic maintenance: decay, pruning, cleanup, trend detection.

Diagram, the post-turn pipeline and the scheduler

interactive turnminimal latency turn completed POST-TURN PIPELINE detect commitmentsdetect follow-upsextract factsdecide on a summaryprewarm the context independent per-step retry event: session closed SESSION-CLOSE PIPELINE session archivinggraph ingestionsession factslogging independent operations in parallel SCHEDULER · crons 04:00 daily · decay05:00 Sunday · link pruning03:00 Monday · detection09:00 daily · remindersperiodic · orphan cleanup at fixed times, off the interactive turn

1 The post-turn pipeline

After each turn, an event is emitted and an asynchronous pipeline fires. It chains independent steps: detect the commitments made, detect the follow-ups to schedule, extract the facts to memorize, decide whether a conversation summary is needed, and prewarm the deep context for the next turn. Each step is isolated: it has its own per-step retry, and the failure of one step does not fail the others. This is also where the importance of memories is computed, as a by-product of extraction, with no dedicated model call.

Finally, at emission, the turn deposits its provenance fingerprint: a request ID and the signature of what was actually injected into the context. It is what makes it possible to replay exactly what the model saw, even after working memory has forgotten (cf. section 07). And this same trace feeds behavioral evaluation: a single stream emitted by the middleware, multiple consumers, provenance, evaluation (section 12), and observability.

2 The session-close pipeline

At the close of a session, a second pipeline archives the session, extracts and structures its content into the knowledge graph, derives the durable facts from it, and logs the activity. Independent operations are launched in parallel, then recombined.

3 The periodic scheduler

System maintenance is entrusted to tasks scheduled by cron expression. Sample cadences, readable directly in the configuration:

TaskCadence (cron)Role
Memory decay0 4 * * * (daily, 04:00)Updates the value score of memories; gates retrieval, does not delete.
Link pruning0 5 * * 0 (weekly, Sunday 05:00)Prunes only invalidated and old derived links, under retention.
Cold archiving0 2 * * 0 (weekly, Sunday 02:00)Compacts and cools old journal segments, kept for audit.
Trend detection0 3 * * 1 (weekly, Monday 03:00)Spots recurring patterns to capitalize on.
Expiration reminders0 9 * * * (daily, 09:00)Emits the reminders that have come due.
Imposed erasureOn demandRenders a subject's data unreadable (legal erasure) without breaking the audit chain.

4 Safeguards for asynchronous work

Poorly guarded background work is worse than no background work. Four safeguards are systematic:

  • Per-step retry: each step replays independently, with a bounded number of attempts, without replaying what has succeeded.
  • Idempotency: a replayed task produces no duplicate; the effect is the same whether it runs once or three times. It is what protects consistency when a task is delivered or replayed several times, including under concurrency. The question of ordering, a distinct one, belongs to causality (section 07), not to idempotency.
  • Bounded concurrency: the number of simultaneous tasks is capped, and often partitioned per user, to keep one actor from saturating the queue.
  • Job observability: every execution is traced; queue lag and failure rate are first-rank metrics.

Runbook, synchronous or asynchronous

OperationWhere
Produce the turn's responseSynchronous
Memory retrieval at the level required to respondSynchronous, tiered
Fact extraction, consolidation, graph ingestionAsynchronous, post-turn
Session archiving and summaryAsynchronous, session close
Decay, pruning, cleanup, trendsAsynchronous, scheduled
Prewarming the next turn's contextAsynchronous, post-turn

Talk to us

Tell us who you are, and we will get back to you.

Your details are recorded by Another Framework, publisher of runward, to get back to you. They are neither sold nor shared, and are deleted three years after our last exchange. To see or delete them: contact@runward.dev.