Programmatic introspection of the agent's own state from inside
:code. The public state surface is deliberately small:
(session-state [session-id]) -> data map, including raw LLM diagnostics(session-report-html [session-id]) -> HTML report rendered from that dataEverything else in this namespace is implementation detail. The agent
gets the data once, manipulates it via plain Clojure (get-in,
filter, map, etc.), and renders the same data to Markdown only
when presentation is needed.
Every function is a pure read off the same DB tables the projection layer reads from (or a classpath read for the doc accessors). Failures return nil/[], never throw, so a misbehaving introspection call cannot break iteration execution.
Opt-in: not auto-loaded by default. Add this jar to the classpath to enable.
Programmatic introspection of the agent's own state from inside `:code`. The public state surface is deliberately small: - `(session-state [session-id])` -> data map, including raw LLM diagnostics - `(session-report-html [session-id])` -> HTML report rendered from that data Everything else in this namespace is implementation detail. The agent gets the data once, manipulates it via plain Clojure (`get-in`, `filter`, `map`, etc.), and renders the same data to Markdown only when presentation is needed. Every function is a pure read off the same DB tables the projection layer reads from (or a classpath read for the doc accessors). Failures return nil/[], never throw, so a misbehaving introspection call cannot break iteration execution. Opt-in: not auto-loaded by default. Add this jar to the classpath to enable.
(session-report-html)(session-report-html session-id)await session_report_html(session_id) # standalone HTML report for ANOTHER conversation Returns a self-contained HTML document (vis-light themed): every turn, iteration, code, result, answer - the same transcript data, styled to match the web TUI. Write it to a file to open in a browser. Most useful for OTHER sessions.
await session_report_html(session_id) # standalone HTML report for ANOTHER conversation Returns a self-contained HTML document (vis-light themed): every turn, iteration, code, result, answer - the same transcript data, styled to match the web TUI. Write it to a file to open in a browser. Most useful for OTHER sessions.
(session-state)(session-state session-id)await session_state(session_id=None) # current session by default; pass an id for another conversation
Returns {"session" (identity + per-turn rollup), "current_turn", "failures", "diagnosis", "session_forks", "turn_retries", "transcript", ...}. The rich one is transcript: ["totals"] (turns/iterations/tokens/cost) and ["turns"] = [{id, user_request, answer, status, iteration_count, tokens, cost_usd, iterations:[{position, status, blocks:[code/result]}]}] — iterate it in python_execution to gather answers, grep code, or diff cost; slice, don't dump.
Pick keys; the whole dict stays bound. No-arg defaults to the current session, but for
THIS conversation the live session bag already has turn, scope, utilization,
workspace, and tool state. It is also the recovery path for raw folded current-session
content: select ['transcript']['turns'] by numeric position, then filter
['iterations'][...]['blocks']. Recovery does not undo fold intents or restore them
to the model wire. For OTHER sessions, use sessions() for the index, then pass that
session id.
await session_state(session_id=None) # current session by default; pass an id for another conversation
Returns {"session" (identity + per-turn rollup), "current_turn", "failures", "diagnosis", "session_forks", "turn_retries", "transcript", ...}. The rich one is `transcript`: `["totals"]` (turns/iterations/tokens/cost) and `["turns"]` = [{id, user_request, answer, status, iteration_count, tokens, cost_usd, iterations:[{position, status, blocks:[code/result]}]}] — iterate it in python_execution to gather answers, grep code, or diff cost; slice, don't dump.
Pick keys; the whole dict stays bound. No-arg defaults to the current session, but for
THIS conversation the live `session` bag already has turn, scope, utilization,
workspace, and tool state. It is also the recovery path for raw folded current-session
content: select `['transcript']['turns']` by numeric `position`, then filter
`['iterations'][...]['blocks']`. Recovery does not undo fold intents or restore them
to the model wire. For OTHER sessions, use sessions() for the index, then pass that
session id.(sessions)(sessions channel)await sessions() # newest-first index of EVERY past conversation
Returns a list of metadata maps you filter in python_execution:
[{"id", "channel", "title", "turn_count", "created_at", "modified_at"} ...]
newest-first; modified_at is the latest turn's timestamp (falls back to created_at for
empty sessions). Pass a channel keyword to narrow to one channel. This is a METADATA-ONLY
index — the content lives behind session_state(id). To find and read one session, pick its
row off the maps, then hand the id on:
rows = await sessions()
hit = next(r for r in rows if "checkout" in (r["title"] or "").lower())
convo = await session_state(hit["id"]) # the ONLY way to read full content
Sort/filter on title/channel/modified_at to select the row — operate on the maps, do
not json.dumps and slice the raw list (a [:N] cut silently drops the session you want).
await sessions() # newest-first index of EVERY past conversation
Returns a list of metadata maps you filter in python_execution:
[{"id", "channel", "title", "turn_count", "created_at", "modified_at"} ...]
newest-first; `modified_at` is the latest turn's timestamp (falls back to `created_at` for
empty sessions). Pass a channel keyword to narrow to one channel. This is a METADATA-ONLY
index — the content lives behind session_state(id). To find and read one session, pick its
row off the maps, then hand the `id` on:
rows = await sessions()
hit = next(r for r in rows if "checkout" in (r["title"] or "").lower())
convo = await session_state(hit["id"]) # the ONLY way to read full content
Sort/filter on `title`/`channel`/`modified_at` to select the row — operate on the maps, do
not `json.dumps` and slice the raw list (a `[:N]` cut silently drops the session you want).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 |