Programmatic introspection of the agent's own state from inside
:code. The public state surface is deliberately small:
(read-session [target]) -> canonical data map, including usage and raw LLM diagnostics(get-session [target]) -> ONE session's descriptor, no transcript(list-sessions [search]) -> metadata-only index, RANKED when search is givenEverything else in this namespace is implementation detail. The agent gets the data once and manipulates it with ordinary Python collection operations when filtering or 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.
Gated: the extension registered at the bottom of this namespace binds its
symbols and prompt only while the introspection toggle is ON (default OFF).
Programmatic introspection of the agent's own state from inside `:code`. The public state surface is deliberately small: - `(read-session [target])` -> canonical data map, including usage and raw LLM diagnostics - `(get-session [target])` -> ONE session's descriptor, no transcript - `(list-sessions [search])` -> metadata-only index, RANKED when `search` is given Everything else in this namespace is implementation detail. The agent gets the data once and manipulates it with ordinary Python collection operations when filtering or 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. Gated: the extension registered at the bottom of this namespace binds its symbols and prompt only while the `introspection` toggle is ON (default OFF).
(get-session)(get-session target)await get_session(target=None) # ONE session's descriptor; current session by default
String-keyed row: {id,channel,title,turn_count,created_at,modified_at,is_current}, plus provider/model/provider_model and last_turn ({id,outcome,user_request}) when known. target is an id, an unambiguous prefix, or the copied vis_session_id#<uuid> marker. None when nothing matches. No transcript - the content is read_session(id), the whole index is list_sessions().
await get_session(target=None) # ONE session's descriptor; current session by default
String-keyed row: `{id,channel,title,turn_count,created_at,modified_at,is_current}`, plus `provider`/`model`/`provider_model` and `last_turn` (`{id,outcome,user_request}`) when known. `target` is an id, an unambiguous prefix, or the copied `vis_session_id#<uuid>` marker. `None` when nothing matches. No transcript - the content is `read_session(id)`, the whole index is `list_sessions()`.(list-sessions)(list-sessions search)await list_sessions(search=None) # newest-first conversation index
String-keyed rows: {id,channel,title,turn_count,created_at,modified_at}. search is THE session search the TUI and the companion app run: the SERVER ranks title (rank 0), request (1), reply (2) and thinking (3) and answers best band first, newest first inside a band - paint that order, never re-sort it. Matched rows add rank, is_in_title/is_in_request/is_in_reply/is_in_thinking and the request_snippet/reply_snippet windows. One row: get_session(id). Content: read_session(id). Filter in python_execution; don't stringify or slice blindly.
await list_sessions(search=None) # newest-first conversation index
String-keyed rows: `{id,channel,title,turn_count,created_at,modified_at}`. `search` is THE session search the TUI and the companion app run: the SERVER ranks title (`rank` 0), request (1), reply (2) and thinking (3) and answers best band first, newest first inside a band - paint that order, never re-sort it. Matched rows add `rank`, `is_in_title`/`is_in_request`/`is_in_reply`/`is_in_thinking` and the `request_snippet`/`reply_snippet` windows. One row: `get_session(id)`. Content: `read_session(id)`. Filter in python_execution; don't stringify or slice blindly.(read-session)(read-session target)await read_session(target=None) # current session by default; pass an id for another
String-keyed fields: session, current_turn, failures, diagnosis, session_forks, turn_retries, "usage", transcript. "usage" is compact token/cost/outcome/error/routing; tool rows overlap, so never sum them. Filter transcript/turns/iterations/blocks (code/result) in python_execution; don't dump. Use live session for current state. This is the recovery path for raw folded current-session content; it does not undo fold intents or restore them. target takes a bare id, a prefix, or the copied vis_session_id#<uuid> marker. Find ids via list_sessions(search="…"); one row alone is get_session(id).
await read_session(target=None) # current session by default; pass an id for another String-keyed fields: `session`, `current_turn`, `failures`, `diagnosis`, `session_forks`, `turn_retries`, "usage", `transcript`. "usage" is compact token/cost/outcome/error/routing; tool rows overlap, so never sum them. Filter `transcript/turns/iterations/blocks` (`code`/`result`) in python_execution; don't dump. Use live `session` for current state. This is the recovery path for raw folded current-session content; it does not undo fold intents or restore them. `target` takes a bare id, a prefix, or the copied `vis_session_id#<uuid>` marker. Find ids via `list_sessions(search="…")`; one row alone is `get_session(id)`.
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 |