Skip to main content

Module window

Module window 

Source
Expand description

A bounded, agent-consumable render of a session: the actual conversation (not a lossy summary), but with tool-output bulk folded to head+tail and an optional total budget that keeps the recent tail. This is what a caller (an agent via MCP, or show --window) reads to know what another session is doing without flooding its own context. The four things that make it parseable: an orientation header, role labels, tool CALLS kept but tool RESULTS folded, and a drill-down hint to show <id> --full.

Structs§

WindowOpts

Constants§

TURN_SCHEMA
Schema id for a single drilled-down turn (session_window with turn).
TURN_TEXT_CAP
Char cap for a single drilled-down turn’s full text, sized to stay inside the MCP text-content window; clipped reports when the original was longer.
WINDOW_SCHEMA
Schema id for the JSON window returned over MCP. Bump the version ONLY on a breaking change to field names or semantics, so a consuming agent can rely on the contract.

Functions§

render_turn_json
Render ONE turn’s full RETAINED text as JSON (schema TURN_SCHEMA) - the drill-down for session_window(id, turn=i). “Full” means untruncated by the window’s folding/cap; tool outputs are already capped at parse time, so this recovers folded-out lines, not adapter-dropped bulk. Bounded to TURN_TEXT_CAP chars for MCP transport; clipped and bytes report the true size. None if i is out of range.
render_window
Render the bounded window for session.
render_window_json
Render session as the versioned, agent-parseable JSON window (schema WINDOW_SCHEMA): orientation header, role-labelled turns with tool output folded, the recent tail kept within budget_chars. Pure and deterministic for a fixed (session, opts) - the MCP layer handles neutralization and the final size guard.