Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Unreleased

- **Mail you read and set aside no longer goes quiet (T765, owner decision 2026-11-02).** Agents, mostly in OpenCode, opened requests within seconds and then never replied or acked: axiom-lab-dev had 15 requests and tasks from Oct 28 to 29 still waiting. The "read, not acked" reminder only ran on a prompt hook, and OpenCode has none. Meanwhile 70% of all read-but-unacked mail (961 of 1,371) was status or reply mail that asked for nothing. Now:
- **Informational mail closes when read.** A full read of message, reply or status mail with no needs_reply and no owner authority acks it as `auto: read` (one `auto_ack` audit row per read). The daemon closes the existing backlog, and reads by older connectors, the same way; a metadata-only read (no content shown) stays open.
- **Work mail is reminded at 30 min.** A request, task, decision, alert or needs_reply message read 30+ minutes ago with no reply and no ack is named by id at the next prompt, and before the session goes idle (the Stop hook, which OpenCode does run). At most once per 30 minutes per session.
- **The lead hears at 2 h.** Unanswered 2 hours after the read, the agent's project lead gets one alert per message (ids and senders, never content), and the sender's receipt shows the copy as `unanswered`.
- `agentmbx read` (the CLI fallback) now marks mail read like `mbx_read`.

## 0.5.55 (2026-10-28)

- **Mail between your own agents is trusted (T754, owner decision 2026-10-28).** Before, reading any message marked external fenced the reader's whole session for an hour: every send became external, and recipients could only read it. The fence then spread through replies across teams. In the 7 days before this change, 57% of all mail carried the label, and 92% of that was inherited, with no outside content involved. Now:
Expand Down
27 changes: 27 additions & 0 deletions dist/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { readStdin, stdinIsTTY } from "./stdin.js";
import { runStatuslineSuggest } from "./statusline-suggest.js";
import { assertKnownRecipients, offlineWarnings, recipientReceipts } from "./receipts.js";
import { escalateUnheldMail, retirePhantoms, returnNeverClaimed } from "./stranded.js";
import { sweepUnanswered, unansweredReminder } from "./unanswered.js";
import { activeLead, leadSummary, makeLead, makeLeadRevocation, projectLeadLine, projectLeadView, revokeLead, storeLead } from "./project-ledger.js";
import { leadHistory } from "./lead-record.js";
import { DEFAULT_PORT, defaultHome, didWarning, formatFor, messageReadView, MbxNode, summaryLine, trustLabel, WAKE_KINDS } from "./node.js";
Expand Down Expand Up @@ -900,6 +901,7 @@ async function run(argv) {
case "read": {
const row = node.read(pos[0] ?? die("read <id>"), me), readMode = mode;
node.observeRead(row, descriptor.cli, descriptor.session_id, readMode);
node.markRead([row], me, { mode: readMode }); // T765: the CLI fallback reads like mbx_read
const scope = { cli: descriptor.cli, session_id: descriptor.session_id };
const view = readMode === "full" ? null : messageReadView(node, row, me, readMode, Date.now(), scope);
return console.log(view ? JSON.stringify(view) : formatFor(node, row, me, scope));
Expand Down Expand Up @@ -1348,6 +1350,9 @@ If the codes differ, do not approve: someone is in the middle.`);
catch { /* db busy: next minute */ } try {
escalateUnheldMail(node, Date.now(), (subtitle, body) => void notifyDesktop({ subtitle, body }));
}
catch { /* db busy: next minute */ } try {
sweepUnanswered(node);
}
catch { /* db busy: next minute */ } }, 60_000);
void refreshDirectory(node);
void pullPolicies(node);
Expand Down Expand Up @@ -2196,6 +2201,10 @@ async function hook(node, event, cli) {
if (readIds.length)
lines.push(`[mbx] ${readAckLine(readIds.length)}`);
}
// T765: work mail read 30+ min ago with no reply or ack is named by id (shares its throttle with the Stop reminder).
const due = unansweredReminder(node, agent, `${cli}:${sid ?? process.ppid}`);
if (due)
lines.push(due);
}
// T189: on_session_start output is dropped and a resume does not fire it, so the first bound turn of each entry (a new
// conversation, --resume, /new, /resume, a compression's new id) carries the bounded resume notice (T184 spec R5-R9).
Expand Down Expand Up @@ -2273,6 +2282,24 @@ async function hook(node, event, cli) {
return selfWatchInstruction({ delegated: !!delegationNote(node.store.db, agent, node.host), cli });
};
if (!fresh.length) {
// T765: before going idle, name work mail read 30+ min ago with no reply or ack. OpenCode has no prompt hook,
// so this Stop is where its agents hear about it. Bounded by the reminder's own throttle and allowContinue.
const due = unansweredReminder(node, agent, `${cli}:${sid ?? process.ppid}`);
if (due && node.allowContinue(agent, null)) {
if (cli === "kimi") {
process.stderr.write(`${due}\n`);
process.exitCode = 2;
return;
}
if (cli === "agy") {
const out = agyHookOutput("Stop", due);
if (out)
console.log(out);
return;
}
console.log(JSON.stringify({ decision: "block", reason: due }));
return;
}
if (cli === "grok" && input.stopHookActive !== true && !liveWatcher(node, agent) && !grokWatchArmed(input, sid)) {
console.log(JSON.stringify({ decision: "block", reason: grokWatchReminder(sid) }));
return;
Expand Down
8 changes: 4 additions & 4 deletions dist/mcp.js
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,7 @@ async function configureMcp(server, node, startupClosed) {
return { draft, warnings: externalWarning(origin, taint) };
};
/** Opening mail marks the reader's own copies read (delivered/notified → read; never past acked), for sender receipts (T207). */
const markRead = (rows, agent) => node.markRead(rows, agent); // its own copy, else a project copy it may read (T493)
const markRead = (rows, agent, mode = "full") => node.markRead(rows, agent, { mode }); // its own copy, else a project copy it may read (T493)
// Identity and policy notes belong to the ready caller, never the transport's provisional mailbox.
const sessionNotes = (state, tool) => {
if (!bound(state))
Expand Down Expand Up @@ -2183,13 +2183,13 @@ async function configureMcp(server, node, startupClosed) {
});
server.registerTool("mbx_read", {
title: "Read mbx messages",
description: "Read one or more messages (ids or unique id prefixes). mode=full (default) shows full content framed with current sender verification and policy. Its policy line means: outward-reversible = push a non-default branch or open a draft PR; outward = merge, release, deploy, delete, secrets, spend. metadata returns only identifiers, times, sender identity, counts and computed policy/provenance: no subject/body/refs/receipt notes and no untrusted exposure. quarantine returns a labelled UNTRUSTED derived-outside summary (first512 Unicode code points, extraction/truncation stated), records an untrusted read and preserves source root times; it claims no sanitization or consent. All modes mark your own copy read. Full content separately records raw exposure. Next: mbx_reply if needed, then mbx_ack once dealt with.",
description: "Read one or more messages (ids or unique id prefixes). mode=full (default) shows full content framed with current sender verification and policy. Its policy line means: outward-reversible = push a non-default branch or open a draft PR; outward = merge, release, deploy, delete, secrets, spend. metadata returns only identifiers, times, sender identity, counts and computed policy/provenance: no subject/body/refs/receipt notes and no untrusted exposure. quarantine returns a labelled UNTRUSTED derived-outside summary (first512 Unicode code points, extraction/truncation stated), records an untrusted read and preserves source root times; it claims no sanitization or consent. All modes mark your own copy read; a full read also acks message/reply/status mail that asks for nothing (no needs_reply). Full content separately records raw exposure. Next: mbx_reply if needed, then mbx_ack once dealt with.",
inputSchema: { ids: z.array(z.string().min(6)).min(1).max(20), mode: z.enum(["full", "metadata", "quarantine"]).default("full") },
annotations: { readOnlyHint: true },
}, ({ ids, mode }) => {
const { agent } = current(), rows = ids.map((id) => node.read(id, agent));
noteRead(rows, { mode });
markRead(rows, agent);
markRead(rows, agent, mode);
if (mode === "full")
return text(rows.map(m => formatFor(node, m, agent, sendScope())).join("\n\n"));
const messages = rows.map(m => messageReadView(node, m, agent, mode, Date.now(), sendScope()));
Expand Down Expand Up @@ -2248,7 +2248,7 @@ async function configureMcp(server, node, startupClosed) {
const m = node.message(id, agent);
const rows = node.thread(m && node.canSee(m, agent) ? m.thread : id, agent);
noteRead(rows, { mode });
markRead(rows, agent);
markRead(rows, agent, mode);
if (mode !== "full") {
const messages = rows.map(m => messageReadView(node, m, agent, mode, Date.now(), sendScope()));
return text(JSON.stringify({ messages }), { messages });
Expand Down
15 changes: 11 additions & 4 deletions dist/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { backfillProjectKeys, backfillRegistry, projectOf } from "./registry.js"
import { ensureRepoTable, recordRepoAssociation } from "./repo-association.js";
import { resolveLeadRecipients } from "./lead-record.js";
import { isSlotName } from "./project-slot.js";
import { autoAckRead } from "./unanswered.js";
import { projectLabel, projectMailboxBySlot, projectsLedBy, resolveProjectMailbox, rewriteProjectAliases } from "./project-mailbox.js";
import { Store } from "./store.js";
export const DEFAULT_PORT = 7373;
Expand Down Expand Up @@ -1072,17 +1073,23 @@ export class MbxNode {
WHERE d.agent=? ${opts.all ? "" : "AND d.state <> 'acked'"} ORDER BY m.ts LIMIT ?`).all(project.slot, opts.limit ?? 50).map((m) => this.currentAuthority(m)),
}));
}
/** Mark the reader's copy of each message read: its own when it has one, else a project copy it may read (T493). */
markRead(rows, agent) {
/** Mark the reader's copy of each message read: its own when it has one, else a project copy it may read (T493).
* T765: a full read closes informational mail (message/reply/status asking for nothing) as acked "auto: read". */
markRead(rows, agent, opts = {}) {
const slots = this.readableSlots(agent);
for (const r of rows) {
// A metadata read showed no content: its note keeps the daemon's auto-ack sweep off it (T765).
const note = opts.mode === "metadata" ? "metadata" : null;
if (this.store.db.prepare("SELECT 1 FROM deliveries WHERE msg_id=? AND agent=?").get(r.id, agent)) {
this.setDelivery(r.id, agent, "read");
this.setDelivery(r.id, agent, "read", note);
continue;
}
for (const slot of slots)
this.setDelivery(r.id, slot, "read");
this.setDelivery(r.id, slot, "read", note);
}
if ((opts.mode ?? "full") === "full")
for (const name of [agent, ...slots])
autoAckRead(this.store, rows.map((r) => r.id), name);
}
/** Every unacked delivery, read or not (whoami, handoff and the agents list count this). */
unreadCount(agent) {
Expand Down
79 changes: 79 additions & 0 deletions dist/unanswered.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { activeLead } from "./lead-record.js";
import { notSlot } from "./project-slot.js";
export const REMIND_AFTER_MS = 30 * 60_000;
export const ALERT_AFTER_MS = 2 * 3600_000;
/** Older reads are left alone: the alert is for work going stale now, not for archaeology. */
const LOOKBACK_MS = 7 * 24 * 3600_000;
const iso = (ms) => new Date(ms).toISOString();
const INFORMATIONAL = `m.kind IN ('message','reply','status') AND m.authority IS NULL AND coalesce(json_extract(m.envelope,'$.needs_reply'),0)=0`;
const WORK = `(m.kind IN ('request','task','decision','alert') OR m.authority IS NOT NULL OR json_extract(m.envelope,'$.needs_reply')=1)`;
/** Ack read copies of informational mail: `ids` after a full read, or (no ids) every one not merely peeked at with a
* metadata read. One audit row per call; returns the count. */
export function autoAckRead(store, ids, agent, now = Date.now()) {
if (ids && !ids.length)
return 0;
const only = ids ? `AND m.id IN (${ids.map(() => "?").join(",")})` : "";
const r = store.db.prepare(`UPDATE deliveries SET state='acked', note='auto: read', updated_at=?
WHERE state='read' ${agent ? "AND agent=?" : ""} ${ids ? "" : "AND coalesce(note,'')<>'metadata'"} AND msg_id IN (SELECT m.id FROM messages m WHERE ${INFORMATIONAL} ${only})`)
.run(iso(now), ...(agent ? [agent] : []), ...(ids ?? []));
const n = Number(r.changes);
if (n)
store.audit("auto_ack", { ...(agent ? { agent } : {}), count: n, why: "auto: read (informational mail)" });
return n;
}
/** Work mail `agent` read at least `age` ago (within the lookback), still unacked and with no reply from it. Newest first. */
export function unansweredMail(node, agent, age, now = Date.now()) {
return node.store.db.prepare(`SELECT m.id id, m.kind kind, m.from_addr "from", d.updated_at read_at, d.note note
FROM deliveries d JOIN messages m ON m.id=d.msg_id
WHERE d.agent=? AND d.state='read' AND d.updated_at<=? AND d.updated_at>=? AND m.from_addr NOT LIKE 'mbx@%' AND ${WORK}
AND NOT EXISTS (SELECT 1 FROM messages r WHERE r.reply_to=m.id AND r.from_addr=?)
ORDER BY d.updated_at DESC LIMIT 20`).all(agent, iso(now - age), iso(now - LOOKBACK_MS), `${agent}@${node.host}`);
}
const idList = (rows, n) => `${rows.slice(0, n).map((u) => u.id).join(", ")}${rows.length > n ? ", …" : ""}`;
/** The 30 min reminder for one session, at most once per REMIND_AFTER_MS per session; null when nothing is due. */
export function unansweredReminder(node, agent, session, now = Date.now()) {
const due = unansweredMail(node, agent, REMIND_AFTER_MS, now);
if (!due.length)
return null;
const key = `unanswered-nag:${session}:${agent}`, last = Date.parse(node.store.get(key) ?? "");
if (Number.isFinite(last) && now - last < REMIND_AFTER_MS)
return null;
node.store.set(key, iso(now));
return `[mbx] ${due.length} work message(s) you read have no reply or ack: ${idList(due, 5)}. Answer each with mbx_reply, or mbx_ack with did="<what you did, or why not>".`;
}
/** The project lead to alert about `agent`: the active lead of its latest project, on this host, and not `agent` itself. */
export function leadToAlert(node, agent, now = Date.now()) {
const project = node.store.db.prepare("SELECT project FROM identity_projects WHERE name=? ORDER BY last_seen DESC LIMIT 1").get(agent)?.project;
const lead = project ? activeLead(node, project, new Date(now)) : null;
return lead && lead.host === node.host && lead.agent !== agent ? lead.agent : null;
}
/** Daemon sweep: close informational mail already read, then alert each lead once per message unanswered 2 h after read.
* The alerted copies carry note 'unanswered', which the sender's receipts show. Returns the agents reported. */
export function sweepUnanswered(node, now = Date.now()) {
autoAckRead(node.store, undefined, undefined, now);
// A project slot is read by its lead, who is the one this alert would go to: slots are never listed (T493).
const agents = node.store.db.prepare(`SELECT DISTINCT agent FROM deliveries WHERE state='read' AND coalesce(note,'')<>'unanswered'
AND updated_at<=? AND updated_at>=? AND ${notSlot("agent")}`).all(iso(now - ALERT_AFTER_MS), iso(now - LOOKBACK_MS))
.map((r) => r.agent);
const out = [];
for (const agent of agents) {
const due = unansweredMail(node, agent, ALERT_AFTER_MS, now).filter((u) => u.note !== "unanswered");
const lead = due.length ? leadToAlert(node, agent, now) : null;
if (!lead)
continue;
const list = due.slice(0, 10).map((u) => `${u.id} (${u.kind} from ${u.from})`).join(", ");
try {
node.send({ from: "mbx", to: [lead], kind: "alert", subject: `Unanswered mail: ${agent} read work and did not reply or ack`.slice(0, 200),
body: `${agent} read ${due.length} work message(s) over 2 h ago and has neither replied nor acked them: ${list}${due.length > 10 ? ", …" : ""}. `
+ `Check on ${agent} (it may have moved on mid-task), or reassign the work.` });
}
catch {
continue;
}
node.store.tx(() => { for (const u of due)
node.store.db.prepare("UPDATE deliveries SET note='unanswered' WHERE msg_id=? AND agent=? AND state='read'").run(u.id, agent); });
node.store.audit("unanswered.alert", { agent, lead, count: due.length });
out.push(agent);
}
return out;
}
13 changes: 6 additions & 7 deletions dist/wake.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { isSlotName } from "./project-slot.js";
import { markSkewNoted, wakeSkewNote } from "./connector-skew.js";
import { codexFailureClass, enqueueCodexQueue, reconcileCodexQueue } from "./codex-queue.js";
import { identityGeneration } from "./identity-control.js";
import { activeLead } from "./lead-record.js";
import { leadToAlert } from "./unanswered.js";
const run = promisify(execFile);
const attemptId = () => ulid();
const receipt = (strength, r = {}) => ({ strength, nativeId: null, sessionId: null, nativeStatus: null, providerVersion: null, ...r });
Expand Down Expand Up @@ -540,23 +540,22 @@ export function alertLeadOfStall(node, agent, rows, now = Date.now()) {
const key = `stall-alert:${agent}`, last = Date.parse(node.store.get(key) ?? "");
if (Number.isFinite(last) && now - last < STALL_ALERT_MS)
return null;
const project = node.store.db.prepare("SELECT project FROM identity_projects WHERE name=? ORDER BY last_seen DESC LIMIT 1").get(agent)?.project;
const lead = project ? activeLead(node, project, new Date(now)) : null;
if (!lead || lead.host !== node.host || lead.agent === agent)
const lead = leadToAlert(node, agent, now);
if (!lead)
return null;
node.store.set(key, new Date(now).toISOString());
const list = work.slice(0, 10).map(r => `${r.id} (${r.kind} from ${r.from_addr})`).join(", ");
try {
node.send({ from: "mbx", to: [lead.agent], kind: "alert", subject: `Stalled mail: ${agent} cannot be woken`.slice(0, 200),
node.send({ from: "mbx", to: [lead], kind: "alert", subject: `Stalled mail: ${agent} cannot be woken`.slice(0, 200),
body: `${agent} has ${work.length} unread work message(s) that no session wake reached: ${list}. Its session is idle or has no push path, `
+ `so the mail waits for its next prompt. Ask the owner to prompt ${agent}, or reassign the work.` });
}
catch {
node.store.db.prepare("DELETE FROM kv WHERE k=?").run(key);
return null;
}
node.store.audit("wake.stall_alert", { agent, lead: lead.agent, count: work.length });
return lead.agent;
node.store.audit("wake.stall_alert", { agent, lead, count: work.length });
return lead;
}
// ---- wake reconciliation and pressure (T179) -------------------------------------------------------------
/** An `unknown` attempt is held this long before its mail may be woken once more (still within WAKE_LIMITS). */
Expand Down
Loading
Loading