Skip to main content

Module naming

Module naming 

Source
Expand description

Naming a session: a name derived from the opening message, and the one bounded model call that may replace it.

Two stages, and the order matters. The first is deterministic and cannot fail — the first line of what the user typed, whitespace collapsed, capped — so a list of sessions is never a column of nulls waiting for a provider to answer. The second is a small-model call that only ever replaces the first, and only if its answer survives clean_reply: a reply that reads like an explanation rather than a name is thrown away whole, because a name is not a summary and a truncated summary is worse than the first line the user wrote.

Nothing here touches the store or a provider. Both stages are pure functions of text so that the interesting part — what counts as a usable name — is testable without a model.

Constants§

MAX_NAME_CHARS
Longest derived name, in characters. The sidebar is narrow and the terminal’s column is narrower; past this a name is a paragraph with the ending cut off.
UPGRADE_INPUT_CHARS
How much of the opening message the small call reads. Enough for the ask and the reason for it, which is what a name is made of; the rest of a long paste is the same request in more words.

Functions§

clean_reply
What survives of the small call’s answer, or why nothing does.
derive
The name to show before any model has been asked: the first line of the opening message, with runs of whitespace collapsed and the cap applied at a word boundary where there is one.
upgrade_prompt
The prompt the small call is given. It asks for one JSON object and nothing else, and says so twice, because the shape is what clean_reply enforces and a model that ignores the second half of a long instruction is the normal case.