Skip to main content

Module context_control

Module context_control 

Source
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§

ContextControl
TaskLine
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§

ContextBranches
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).