openloops.session_page#
A session, rendered as one page a person can read: pure, script-free, private by rule.
ADR-016. session_page() takes the records of one transcript (already loaded) and
returns one self-contained HTML document: one block per turn of the main thread, the
prompt and then every text the session wrote in that turn. It reads no file and writes
none; openloops.tools.page() and ol page do the reading and the writing.
The anchor. Every turn is an element whose id is t-<id of the prompt record>
(the id openloops.exchanges.Exchange.uuid carries), with any character outside
A-Za-z0-9_- replaced by _. turn_anchor() builds it, so a consumer links to
<page address>#t-<id> without guessing. The turn the address points at is
highlighted by the browser’s own :target rule; focus= additionally gives that
turn the class focus, for a page opened without a fragment.
What the page holds. The prompt (who it came from: a person, another session by name, or tooling; the sentences that ask something are marked), then the session’s texts in order, and each tool call as one line (the tool’s name and what it was pointed at). Left out: tool results, thinking, sub-agent threads and text the tooling injected. A compaction summary is shown and labelled as one.
Credentials. Text is cleaned before anything is cut: a field holding a
credential-shaped string is replaced whole by a notice naming the pattern class, never
the text, and the page says how many passages were withheld. That is
openloops.dashboard.Sanitizer’s behaviour, not openloops.egress.scrub()’s
(which refuses a whole document on the first match, wrong for a long session).
A rendered session is private data (ADR-016, rule 4): the words of a session, for the person who ran it. Nothing here publishes or uploads a page, and a page is never a fixture, a docs example or an attachment to an issue.
>>> records = [
... {"type": "user", "uuid": "p1", "timestamp": "T1",
... "message": {"content": "Why is CI slow?"}},
... {"type": "assistant", "uuid": "a1", "timestamp": "T2",
... "message": {"content": [{"type": "text", "text": "The cache was cold."}]}},
... ]
>>> html = session_page(records, focus="p1")
>>> turn_anchor("p1"), 'id="t-p1"' in html, "<script" in html
('t-p1', True, False)
Module Attributes
What every turn's |
|
Over this many characters of rendered turns, the page keeps the turns around |
|
A single text, prompt or tool line longer than this is cut (after it is cleaned). |
Functions
|
One self-contained HTML document for a transcript's records. |
|
The |
- openloops.session_page.ANCHOR_PREFIX = 't-'#
What every turn’s
idstarts with; the rest is the prompt record’s id.
- openloops.session_page.DFLT_MAX_BYTES = 400000#
Over this many characters of rendered turns, the page keeps the turns around
focus.
- openloops.session_page.DFLT_MAX_FIELD_CHARS = 20000#
A single text, prompt or tool line longer than this is cut (after it is cleaned).
- openloops.session_page.session_page(records, *, focus=None, sanitizer=None, key='', max_bytes=400000, max_field_chars=20000)[source]#
One self-contained HTML document for a transcript’s records. Pure.
focusis the id of a turn’s prompt record (Exchange.uuid; a leadingt-is accepted too). That turn gets the classfocusand, when the page is overmax_bytesof rendered turns, is the centre of the turns kept: the rest are replaced by a count of what was left out. With nofocusthe latest turns are kept.keynames the session in the header.sanitizer=is the seam (default: a freshopenloops.dashboard.Sanitizer, so each page counts its own withheld passages); any object withtext(str) -> str(escaped) and awithheldlist substitutes.No script, no external request, no event handler. See the module docstring for the anchor format, what is left out, and why a rendered session is private data.
- Return type:
- openloops.session_page.turn_anchor(prompt_uuid)[source]#
The
idof the turn whose prompt record has this id:t-<id>.A consumer’s link is
<page address>#+ this. Characters outsideA-Za-z0-9_-become_(a record id is a UUID in practice, so nothing changes).>>> turn_anchor("0f3a-91") 't-0f3a-91'
- Return type: