Skip to content

mentor.brief reports what the agent's use of Loom shows, from a call made to a graded run - #172

Merged
zlareb1 merged 33 commits into
mainfrom
feat/i160-evidence
Nov 2, 2026
Merged

zlareb1 merged 33 commits into
mainfrom
feat/i160-evidence

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Related: #160

Changelog category (leave one):

  • Improvement

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

mentor.brief reports a usage_evidence ladder for the agent's use of Loom in the window: calls made, calls that succeeded, memory.set writes that stored a row, written rows with a vector from the current embedder, reads that answered, distinct memory keys the agent reported relying on, and graded runs (the last two marked as a caller's report, not verified). It also gives the agent's oldest ledger row in the window and how long the ledger keeps the namespace's calls.

Why

Issue 160 asks that an explanation of agent usage keep apart a tool attempt, a successful read, a committed write, an indexed write, a returned hit, an explicit client acknowledgment and a task outcome, and say "not observed in this window" when that is all the evidence supports. Today mentor.brief reports calls per operation and hint adoption (a hinted op called later in the session). A call count alone cannot tell a read that answered from one that missed, or a write that stored nothing from one that did, and a client's report of what it relied on reads the same as something the server saw.

Each count needs the result column that shows it (out_noop = 'false', out_abstain = 'false', a hit, a found key), so a call that records no result, such as an idempotent replay, is an attempt and nothing more. Each rung of MentorBriefOutput.usage_evidence carries count (None when the read failed), source (server: Loom saw it; client: a caller reported it, unverified) and a meaning that says what the count is and what it does not show:

Rung Counted from
attempt the request rows the call ledger records under the agent, which is the agent a call's body names (for a call by key, the row's writer, whoever calls; not counted: any call whose body names no agent, which the ledger records under - — memory.get_by_id, an MCP memory.update that names none, and the Python SDK's memory.update by default — and any call that reads across agents, agent: * — the SDKs' default for memory.search and memory.ask, memory.outcome's default, and how the MCP transport sends memory.search, memory.list, memory.history, memory.related and memory.search_trace unless another agent is named. A brief is about one agent's rows) (loom.agent_events, kind = 'request': not the memory.ask.consistency verdict a deferred ask leaves under the asking agent); the dashboard's traffic (consumer = 'loom-ui') and mentor.brief (ledgered under the agent it names) left out
success those with success = 1; a read that found nothing counts
committed_write successful memory.set calls whose row says out_noop = 'false': not a restated memory merged into the one Loom had or a dry run (both answer noop true), and not an idempotent replay (HTTP or MCP), whose row records no result. The other write ops do not say on the ledger whether they stored a row (memory.update answers updated: false for a missing key, a bulk_set may merge every entry), so they are not counted here rather than counted as stored
indexed_write memories the agent first created in the window (one per user_id, session_id and key, the memory's identity), by any write op, with a vector from the current embedder (embedding_model = the embedder's model, embedding_dim > 0), a served status (served_status_sql), not past expires_at. When a key was first created is read from loom.memory, which carries created_at forward across versions (an embedding row's created_at is its own version's write, so a revision of an old key is not counted)
returned_hit successful memory.search / memory.ask calls that recorded out_abstain = 'false', search.query calls with a hit (out_section_hits, below), and memory.get or memory.bulk_get calls under the agent that found their key (out_found, out_found_n; a delete answers found too, and is not a read)
client_acknowledged distinct memory keys the agent reported relying on: its runs' run.complete memories_used (which keeps only keys a live row answers; chunk: ids, which name a passage, left out) and its successful memory.outcome labels by id with outcome used or positive that landed on a row (out_recorded = 'true', a field the ledger now records), resolved to the row's key. A label by key is not counted: it resolves under the row writer's agent, so the ledger records it under the writer whoever gave it. Nor are the Python SDK's outcome and outcome_by_key (no agent, recorded under *) or memory.outcome_run (no agent field); source: client
task_outcome the agent's runs that started in the window and carry a grade (run.grade pass or fail, from agent_runs.grade); source: client, since the grade is the grader's report and Loom checks no task itself

search.query (loom_search over MCP) answers with a hit list per plane and no top-level abstain, so its ledger row now records out_section_hits, the hits across its memory, document and conversation sections (a section that abstained keeps its below-threshold hits as evidence and is not counted; the profile section, which falls back to matching by meaning and answers nearly any query, and the tracker's duplicate-check verdict, which answers whether a defect is filed rather than what is remembered, are not counted) (server/observability/event_args.py::_read_outcome_columns). A build one release older writes neither new field (out_section_hits, out_recorded), so its search.query calls count as attempts but not as returned hits, and its memory.outcome labels are not acknowledgments: until it is replaced, and then for one window, while its rows are still inside it.

The ladder is read at each brief, after the profile and not from it, over the window the brief reports (a cached profile keeps the window it was read over), so it answers when the mentor is off too: the profile is warmed by the agent's own calls, so a count cached from the first call of a session would miss everything after it. ledger_from is the agent's oldest ledger row in the window, of any kind (one scan computes it with the counts, each count carrying its own condition), and ledger_retention_days how long the configured retention keeps the namespace's ledger rows: the namespace's own retention_days when it sets one, else LOOM_RETENTION_AGENT_EVENTS_DAYS (0: until deleted). It is the configuration, which the table's TTL takes on at the next retention reconcile, not the TTL read back from the table. A window longer than the retention leaves the rungs read from the ledger (attempt, success, committed_write, returned_hit) covering less than it names; the CLI table says how many days the ledger keeps when it keeps fewer than all.

Scope and risk

  • Read-only; five statements per brief, run together after the profile answers (two of them scan the agent's slice of the call ledger: the evidence counts and the labelled ids inside the reported-keys statement), each filtered on (org, namespace, agent) (the call ledger's and the embedding table's sort-key prefix) or (org, namespace). None replaces an existing read. The memory keys the runs reported (_CREDITED_KEYS) are one SQL fragment shared with the profile's existing credited-keys read.
  • Measured locally on a private ClickHouse with 300,000 call rows for one agent: the call-ledger statement reads 300,003 rows in 34 ms at the median (35 ms at most, 7.6 MiB); a brief answers in about 80 ms once the profile is cached (the first, cold one 362 ms).
  • The indexed writes read the agent's memories created in the window from loom.memory as an IN set of (user_id, session_id, memory_key) with use_index_for_in_with_subqueries = 0: pruning the embedding table's granules by a set of 300,000 keys took 1.23 GiB and about 2 s, while the (org, namespace, agent) prefix alone reads 626,000 rows in 94 MiB and about 250 ms (system.query_log, 300,000 memory and embedding rows under the briefed agent; about 95 ms once warm).
  • The reported keys are one statement: the run keys, and the keys of the agent's labelled rows through memory_id IN ( the labelled ids from the agent's ledger slice ), with no FINAL (a memory's key never changes across versions). With no labels the IN set is empty and ClickHouse reads no loom.memory granules: on a namespace of 300,000 memory rows and 300,000 call rows, all under the briefed agent, the statement read 300,020 rows (the agent's ledger slice and its runs; 293 KiB) in 16 ms at the median (system.query_log; the first, cold one 229 ms).
  • Each read stands alone: a failed one leaves its rungs with no count and is named in skipped (calls, indexed_writes, reported_keys, graded_runs, retention), and the rest of the brief still answers.
  • The dashboard's mentor panel does not show the ladder yet; the Assistant page that reads it is a separate change.

Compatibility, rollout and rollback

  • Ledger: a search.query row gains args['out_section_hits'], and a result that answers recorded (memory.outcome, among others) gains args['out_recorded'].
  • Wire: MentorBriefOutput gains usage_evidence[] of UsageRung (named apart from hints[].evidence, the counts a rule fired on) (rung, count, source, meaning), ledger_from and ledger_retention_days. No input changes.
  • Plugins: the loom-mentor skill reference names usage_evidence; both plugin manifests go to 1.2.2. The plugin evals grade the loom-memory write guidance only, which this does not change.
  • Operator steps: none.
  • Rollback: revert; nothing is stored.

Tests

  • Unit (tests/unit/test_event_args.py): an outcome records whether its label landed (out_recorded); a sectioned search records its hits across sections, zero when it found none or its memory section abstained, the profile and tracker sections not counted, and nothing for a result with no sections.
  • Unit (tests/unit/test_mentor.py): the ladder in order with each rung's count and source (attempt, success, committed write, indexed write, returned hit), the client's report and the graded runs marked client and read live rather than from the cached profile, and the ladder's rows in the CLI table; the namespace's retention winning over the ledger default, and the default shown when it sets none; a failed read leaving its rungs uncounted and named in skipped while the other reads answer (the full skipped list asserted), a failed retention read leaving the retention unknown, the ladder counting the cached profile's window when the brief asks for another, an embedder that fails leaving only indexed_write uncounted, a brief about no agent in particular having no ladder, the indexed-writes statement run on clickhouse-local against the real tables (an old key revised today not counted, one user's new key that is not embedded yet not counting another user's old embedded row under the same key, and three users who each created the same key counted as three), and the ladder answering when the mentor is off.
  • Integration (tests/integration/test_mentor_evidence.py, private ClickHouse and server): an agent writes a fact and retries the write with the same Idempotency-Key (answered as a replay), restates it under another key (a no-op), dry-runs a third write, reads the fact and a missing key, bulk-reads both, reads the fact by id (recorded under no agent, so not counted), runs a memory.search that abstains, a search.query with a hit and a memory.ask, a memory.search across agents (agent: *, recorded under *, so not counted), and over MCP a loom_memory_get, a loom_search and, with a token, a loom_memory_update that names no agent (recorded under none, so not counted), writes and deletes a scratch row (the delete answers found and is not a hit), completes a run reporting the fact as relied on, has a grader pass the run, stores a second fact and labels it used through memory.outcome by its id, a third and labels it positive by key (recorded under the writer, not counted), and labels a key that holds no row (recorded: false, not counted); a dashboard read under the agent's name, a failed memory.ask.consistency verdict row and the briefs the test polls with are left out. The brief counts 22 attempts and 22 successes, four committed writes (not the replay), three indexed writes (the deleted row no longer counts), six returned hits (seven when the ask answered), two keys acknowledged by the client, one graded run, a ledger_from, and a known retention.
  • The analyzer corpus (tests/analyzer) runs the five new statements (mentor_evidence case).
  • make format lint typecheck, the unit tests named above and the generator checks.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code. Checked each rung's predicate against the ledger columns the transports write, and the integration run against a live server.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • make format-check, make lint, make typecheck and make test-unit pass; the integration suite passes if server behaviour changed.
  • Generated files are regenerated in this PR, not by hand.
  • A new migration is additive and numbered after the latest on main; no merged migration is edited. (No migration.)
  • A behaviour change to any file a plugin ships bumps both plugin manifests' version. (The loom-mentor skill reference changes; both manifests go to 1.2.2.)
  • The frontend builds (npm --prefix frontend run build) and its tests pass, if frontend/ changed. (No frontend change.)
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers.
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

🤖 Generated with Claude Code

@zlareb1
zlareb1 force-pushed the feat/i160-evidence branch 2 times, most recently from bd77d79 to 3541f1f Compare November 1, 2026 19:58
@zlareb1 zlareb1 changed the title mentor.brief reports what the agent's use of Loom shows, from a call made to a task outcome mentor.brief reports what the agent's use of Loom shows, from a call made to a graded run Nov 1, 2026
@zlareb1
zlareb1 force-pushed the feat/i160-evidence branch from c16ed88 to 6320cf3 Compare November 1, 2026 23:35
zlareb1 and others added 21 commits November 2, 2026 00:30
…tcome, with the ledger's retention

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…e mentor's own calls, and counts distinct reported keys

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…d search records its hits on the ledger

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ead is a returned hit; chunk ids are not memory keys

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… hit; a replayed set is no committed write; indexed means servable

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ped; bulk and by-id reads are tested as hits

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…s name the sections they leave out

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…t the current embedder's vectors; unattributed calls are named

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… agent; retention is the configured one; by-id reads are not found reads

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ent; a missing aggregate row is a failed read

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ts are recorded

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… the test mints with the fixture

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… is resolved inside its read

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… acknowledgments; the docs show the ladder as a table

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…er records recorded; stale wording fixed

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…pe the ledger rule to the ledger rungs

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…els resolve without FINAL; a landed by-key label is tested

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…read is None; graded runs are a filtered count

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…come labels use the counted-call rule

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…tover evidence names follow UsageRung

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 force-pushed the feat/i160-evidence branch from c2d7f17 to d25324a Compare November 2, 2026 00:30
zlareb1 and others added 4 commits November 2, 2026 00:49
…nly when there are labels

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…l line says what the ladder counts

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ger calls

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
zlareb1 and others added 8 commits November 2, 2026 01:36
…d comment

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…eader and the rung docstring say usage evidence

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…loom.memory

The embedding row's created_at is its version's write, so a revision of an old key
passed the window filter. The key set skips granule pruning, which cost 1.2 GiB for
300,000 keys.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Matching on the key alone counted one user's old embedded row for another user's new
key, and counted a key that several users created once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…s leave out

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 merged commit c034008 into main Nov 2, 2026
21 of 22 checks passed
@zlareb1
zlareb1 deleted the feat/i160-evidence branch November 2, 2026 02:59
@pufit pufit mentioned this pull request Nov 2, 2026
9 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant