Expand description
ctx.* (port of the request side of ultron/context-control.ts) and the context-edit semantics it relies on
(applyContextEdits / contextEditsOf of packages/agent/src/harness/session/context.ts).
The model edits what it sees, never the durable transcript: every change is an entry appended to the calling
lane’s conversation branch (a context_edit custom entry for forget/summarize, its own custom entries for pins
and notes), and only that branch sees it. Guard rails: the current user message, a tool call still waiting for
its result, and pinned items are never edited; entries before the newest compaction are out of reach. A summary
moves tool calls and their results together. Entries appended while a turn runs are not on the branch until the
turn’s next boundary; this module keeps them as pending so later reads in the same cell already see them.
The branch itself lives in the session/harness: ContextBranches is what this module reads and appends.
Entries are the TS Entry JSON ({id, parentId, seq, timestamp, type, ...}).
Structs§
- Context
Control - Task
Line - A finished task as it stands in the root’s context after collapse on return.
Constants§
- COMPACTION_
TRIM_ ENV - CONTEXT_
KEPT_ MESSAGE_ TYPE - CONTEXT_
NOTE_ CUSTOM_ TYPE - CONTEXT_
NOTE_ MESSAGE_ TYPE - Custom message type of a note in the model’s context.
- CONTEXT_
PIN_ CUSTOM_ TYPE
Traits§
- Context
Branches - The conversation branches of the session’s lanes, as the harness keeps them.
Functions§
- collapsed_
cell_ text collapsedCellText: the collapsed form of a cell output that returned finished tasks.- message_
text - Readable text of a message, for previews and kept items (
messageText). - project_
note CONTEXT_ENTRY_PROJECTORS[CONTEXT_NOTE_CUSTOM_TYPE]: a note is a custom message at its place in the branch (“Note (ctx.note): …”); a note without text projects nothing.- task_
line taskLine: one line that stands for a finished task.- trimmed_
result_ text trimmedResultText: head and tail of a tool result trimmed before compaction (UTF-16 offsets).