Skip to content

Shared Board

In the #growth thread, the analyst answers Alice's churn question. Bob asks for the breakdown by plan, and the analyst answers again. Then Alice asks how does our Team plan price compare to competitors?, and the companion routes it to the researcher. The researcher has never run in this thread, and it still knows the Team plan's churn is 3.4%.

Each of those requests ran in a different agent process, and none of them read another's tool calls. They share the conversation's board.

Entries

A conversation's board is the session's rows in memory_turns, numbered by seq. Every request the companion routes writes one entry when it commits: the user's message, the final reply, and the agent that wrote it as the author. A workflow route writes one entry with the run's input and outcome, authored by the companion.

Tool calls, tool results and thinking stay in each request's event log. The board holds what was said. When the researcher needs the numbers behind the analyst's reply, it has the reply, and the query the analyst ran stays in the analyst's log.

A request that fails leaves an entry too. It has the user's message, no reply, and the error code and message in its metadata. The next request sees it in a <failed_request> block before the new message, so a user's try again refers to something.

Each entry records two sizes:

  • tokens: the request's context size, as its provider reported it for its last model call, cached input included, plus its output.
  • board_tokens: the board's size since its last summary, this entry included. It is the previous entry's board_tokens plus this entry's tokens, so the size check reads one row.
-- src/mash/storage/migrations/026_board.sql (trimmed)
ALTER TABLE memory_turns ADD COLUMN IF NOT EXISTS seq BIGINT;
ALTER TABLE memory_turns ADD COLUMN IF NOT EXISTS tokens BIGINT NOT NULL DEFAULT 0;
ALTER TABLE memory_turns ADD COLUMN IF NOT EXISTS board_tokens BIGINT NOT NULL DEFAULT 0;
CREATE UNIQUE INDEX IF NOT EXISTS idx_memory_turns_session_seq
    ON memory_turns(session_id, seq);

The unique index holds because one event runs at a time per session, as the events post covered.

What a routed request reads

When a routed request loads its context, it reads the latest summary entry and every entry after it, in full. There is no turn window. Each entry goes in as a user message headed by its number and author, followed by the reply:

[entry 1 · analyst]
pull last week's churn
analyst: Churn was 2.1% last week, up from 1.8%.

[entry 2 · analyst]
break it down by plan
analyst: Pro 1.2%, Team 3.4%.

Labels go only in user messages, so the model does not copy them into its own replies. The researcher's request for Alice's pricing question starts from its system prompt, these entries, and her message.

flowchart LR
    subgraph board ["board: memory_turns of the session"]
        E1["entry 1\nanalyst"] --- E2["entry 2\nanalyst"] --- E3["…"] --- S["entry 40\nsummary"] --- E41["entry 41\nresearcher"] --- E42["entry 42\nanalyst"]
    end
    subgraph ctx ["context of the next routed request"]
        S2["summary"] --> E41b["entry 41"] --> E42b["entry 42"] --> M["new message"]
    end
    S -.-> S2
    E41 -.-> E41b
    E42 -.-> E42b

The context load records the number of the last entry it read as board.up_to on mash.context_load.end. A request recovered after a crash reads the board up to that number, so it rebuilds the context it first saw even if other entries landed while it was down.

The companion reads the same board, rendered as text in the classifier's BOARD section. That is how a follow-up finds the agent that wrote the entry it follows.

Older entries

A routed request also gets two tools over its own session. Neither takes a session id, so an agent reads only its own conversation's board:

  • read_board(after=, before=, limit=) returns entries by number, in full, including those before the latest summary. It returns 20 by default and at most 50.
  • search_board(query) returns matching entries with their number, author and a snippet, from the full-text indexes on the message columns.

The summary names entries by number, so an agent that needs the detail behind a line of the summary opens that entry with read_board. Neither tool reads another request's event log.

The summary

Only the companion compacts. As its request starts, before it classifies the message, it checks the board's last entry:

# src/mash/memory/board.py: compact_board (trimmed)
last = await store.last_entry(session_id)
if last is None or (last.get("metadata") or {}).get("type") == BOARD_SUMMARY:
    return None
if reason != "manual" and (threshold <= 0 or int(last["board_tokens"]) < threshold):
    return None

The threshold is the companion's compaction_token_threshold, 100,000 tokens. Past it, the companion summarizes the previous summary and every entry after it with its own model, at temperature zero, and appends the summary as the next entry. Its label is [entry N · companion · summary of the entries before it], and its metadata records the range it covers. board_tokens starts again from the summary's output tokens. The next routed request reads the summary and the entries after it.

The summary prompt asks for which agent did what, with entry numbers; key decisions, results, constraints and open questions; the user's preferences and goals; and the names, paths, links and ids the user may come back to, kept exactly.

/compact in the REPL, or POST /api/v1/agent/companion/sessions/{session_id}/compact, writes the summary on demand, which helps when a conversation finishes one phase and starts another. Other agents keep no history of their own, so the same route on them returns 400 INVALID_REQUEST.

Requests outside a conversation

A request the companion did not route has no board. A workflow's agent step is the common case: it starts from its system prompt and its message, which carries the step's input as JSON, and each run is self-contained. The step's request still writes a turn in its own session, which is how Cortex and the trace tools find it, but no conversation reads it.

Signals

Every entry also carries signals: small structured values collected when the request commits, such as token counts and tool activity. They are stored per turn in memory_signals, and the definitions come from the runtime:

GET /api/v1/agent/analyst/sessions/{session_id}/signals

definitions: { "tokens.total": {...}, "tools.invocations": {...}, ... }
turns: [ { "turn_id": "…", "created_at": …, "signals": {"tokens.total": 8412, ...} } ]

Signals answer questions across sessions, such as which threads used the most tokens, with a query over rows.

The board ends with the thread. Carol's new thread next week starts with an empty board, and what the channel learned before reaches her through the app. That's the next post.

Next: Cortex.