Skip to content

history

Summarizes each thread's older messages as they leave its tail, and sends agents the outline and the recent messages whole (it replaces chat's history View).

On this page 7
TypeScript
import { history } from "copilotz/plugins/agents";

What it keeps

It keeps 2 collections, 1 of them on the record.

CollectionKept asFields
outlinedocumentscount, lines, bytes, boundary, since, tail, tailAt, tailIds, tailSteps, steps, last, complete, cutAt
summarydocumentsthread, level, index, text, bytes, message, agent, at

Its named queries read for callers, as the rules let them:

QueryWho outside runs it
summary.ofthe app's code

What it lets callers do

Agents act through its tool, as whoever they work for:

ToolWhat it doesCalls
zoomOpen a line of the summarized conversation: zoom(id, n) with the line's id+n gives the two lines it was made from (n/2 messages each); zoom(id, 1) gives the message whole.

Where it shows

Its Views show elsewhere.

  • Elsewhere: history, history.since, summary.
  • Agents' tools: zoom.

What it needs

You set it in resources.history: 4 settings are required.

SettingTypeRequiredWhat it is
history.summarizerModelRefyesThe model that writes summary lines ("provider/model", …): a fast, cheap one does well.
history.linenumberyesA line's size limit, in UTF-8 bytes (512: a dense paragraph).
history.tail[number, number]yesWhole messages at the end, by what they cost a prompt (estimated tokens: text, files, tool steps): they grow to the second, then the oldest leave (shared ones as lines) until the first.
history.outline[number, number]yesThe outline: it grows to the second size, then the most due pairs merge until the first (bytes).

Until it's set, the runtime doesn't start. With nothing set, its check says: "history: set the history resource's summarizer model."

What it requires

The runtime doesn't start without chat and models: add them too.

It ships with copilotz@1.0.0-rc.38.

What it does on its own

Some of its work starts without a caller: an event, or the time.

  • history.compact runs on message.created.
  • history.erase runs on thread.deleted.

Listing

It keeps every listing rule.