Context compaction verbs and the durable context snapshot.
Implements the verbs that fold settled work, checkpoint and rebase a session's context, and the folded-context view they produce, so a session keeps working once its transcript outgrows the context window.
Context compaction verbs and the durable context snapshot. Implements the verbs that fold settled work, checkpoint and rebase a session's context, and the folded-context view they produce, so a session keeps working once its transcript outgrows the context window.
(checkpoint-fold! environment ctx)A fold is acknowledged only after its current turn version has saved the checkpoint.
A fold is acknowledged only after its current turn version has saved the checkpoint.
(compaction-verbs ctx-atom & [session-rebase-atom checkpoint!])Build the model-facing compaction verb bound into the sandbox as
fold_session, closing over ctx-atom. It records a :session/summaries
intent the wire applies via apply-summaries, and returns a visible
confirmation string for stdout.
The verb takes exactly TWO arguments: a KEY and an optional GIST. The key is
a STRING in the ctx-engine/fold-key grammar — "t2/i5" one step, "t2" a
whole turn, "t2/i1-i56" a range, "-t2/i56"/"t2/i5-" an open one, commas
to union several — disjoint RANGES included (a list of key strings works
too). Anything that is not a step key, or that resolves to neither settled
steps nor a settled turn, is refused BY NAME with the grammar. The gist is
OPTIONAL: pass it to KEEP a one-line takeaway; OMIT it
to discard the step with no summary line. Recorded intents are string-keyed
because they persist inside the ctx blob; ctx-engine/expand-through owns
their shape and apply-summaries renders them.
Build the model-facing compaction verb bound into the sandbox as `fold_session`, closing over `ctx-atom`. It records a `:session/summaries` intent the wire applies via `apply-summaries`, and returns a visible confirmation string for stdout. The verb takes exactly TWO arguments: a KEY and an optional GIST. The key is a STRING in the `ctx-engine/fold-key` grammar — "t2/i5" one step, "t2" a whole turn, "t2/i1-i56" a range, "-t2/i56"/"t2/i5-" an open one, commas to union several — disjoint RANGES included (a list of key strings works too). Anything that is not a step key, or that resolves to neither settled steps nor a settled turn, is refused BY NAME with the grammar. The gist is OPTIONAL: pass it to KEEP a one-line takeaway; OMIT it to discard the step with no summary line. Recorded intents are string-keyed because they persist inside the ctx blob; `ctx-engine/expand-through` owns their shape and `apply-summaries` renders them.
(durable-context-snapshot environment ctx)Normalize both in-turn checkpoints and terminal context snapshots for resume.
Normalize both in-turn checkpoints and terminal context snapshots for resume.
(rebase-session-context! standing-ctx-atom session-rebase-atom cur)Materialize cur as both the same-turn full delta and next-turn standing
snapshot when a fold crossed the rebase threshold. Returns nil otherwise.
Materialize `cur` as both the same-turn full delta and next-turn standing snapshot when a fold crossed the rebase threshold. Returns nil otherwise.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |