Skip to content

graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs

Python

fix(gui): preserve generated notification provenance

justrach5fccbc499c5e
diff --git a/TUI/app.zig b/TUI/app.zig
index c17b834f..586c0a1d 100644
--- a/TUI/app.zig
+++ b/TUI/app.zig
@@ -42,6 +42,7 @@ pub const ToolInfo = struct {
pub const Entry = struct {
kind: EntryKind,
+ notification: bool = false,
text: []const u8,
folded: bool = false,
/// Non-null on every `.tool` row a live turn produces. Null on a legacy
diff --git a/TUI/bgop.zig b/TUI/bgop.zig
index adc06f0e..0dae2aa0 100644
--- a/TUI/bgop.zig
+++ b/TUI/bgop.zig
@@ -142,10 +142,11 @@ fn applyCompact(self: *Model, op: *Op) void {
self.clearHistory();
if (op.compact.note.len > 0) self.push(.system, op.compact.note) catch {};
for (op.compact.turns) |t| {
- self.push(switch (t.role) {
+ self.push(if (t.notification) .system else switch (t.role) {
.user => .user,
.assistant => .assistant,
- }, t.text) catch {};
+ }, t.text) catch continue;
+ self.history.items[self.history.items.len - 1].notification = t.notification;
}
}
diff --git a/TUI/engine_types.zig b/TUI/engine_types.zig
index 2ff1db35..1293b4c7 100644
--- a/TUI/engine_types.zig
+++ b/TUI/engine_types.zig
@@ -14,6 +14,7 @@ pub const Mode = enum { normal, plan, always_approve };
pub const Turn = struct {
role: Role,
text: []const u8,
+ notification: bool = false,
pub const Role = enum { user, assistant };
};
diff --git a/TUI/resume.zig b/TUI/resume.zig
index 83e68c7c..6ec9277b 100644
--- a/TUI/resume.zig
+++ b/TUI/resume.zig
@@ -120,7 +120,11 @@ pub fn run(self: *app.Model, spec: []const u8) void {
}
self.clearHistory();
for (out.turns) |turn| {
- self.push(if (turn.role == .user) .user else .assistant, turn.text) catch {};
+ self.push(if (turn.notification) .system else if (turn.role == .user) .user else .assistant, turn.text) catch {
+ self.alloc.free(turn.text);
+ continue;
+ };
+ self.history.items[self.history.items.len - 1].notification = turn.notification;
self.alloc.free(turn.text);
}
if (out.turns.len > 0) self.alloc.free(out.turns);
diff --git a/TUI/turn.zig b/TUI/turn.zig
index 4bf1d788..05a6ed9b 100644
--- a/TUI/turn.zig
+++ b/TUI/turn.zig
@@ -24,14 +24,14 @@ pub fn paramsOf(self: *const Model) engine.Params {
pub fn startJob(self: *Model) void {
var turns = std.array_list.Managed(engine.Turn).init(self.alloc);
for (self.history.items) |e| {
- const role: ?engine.Turn.Role = switch (e.kind) {
+ const role: ?engine.Turn.Role = if (e.notification) .user else switch (e.kind) {
.user => .user,
.assistant => .assistant,
else => null,
};
if (role) |r| {
const t = self.alloc.dupe(u8, e.text) catch continue;
- turns.append(.{ .role = r, .text = t }) catch {
+ turns.append(.{ .role = r, .text = t, .notification = e.notification }) catch {
self.alloc.free(t);
continue;
};
@@ -75,7 +75,8 @@ pub fn maybeJobWake(self: *Model) void {
const f = engine.g_idle_wake_fn orelse return;
var buf: [512]u8 = undefined;
const text = f(engine.g_turn_ctx, &buf) orelse return;
- self.push(.user, text) catch return;
+ self.push(.system, text) catch return;
+ self.history.items[self.history.items.len - 1].notification = true;
startJob(self);
}
pub fn finishJob(self: *Model) void {
diff --git a/TUI/turn_spawn_tests.zig b/TUI/turn_spawn_tests.zig
index e5b11923..2e0709b9 100644
--- a/TUI/turn_spawn_tests.zig
+++ b/TUI/turn_spawn_tests.zig
@@ -131,6 +131,8 @@ test "idle wake spawn failure is reapable without a thread or model work (#537)"
try std.testing.expectEqual(@as(usize, 1), Fake.wake_calls);
try expectFailedStart(&term);
try std.testing.expectEqualStrings("automatic follow-up", term.model.history.items[0].text);
+ try std.testing.expectEqual(app.EntryKind.system, term.model.history.items[0].kind);
+ try std.testing.expect(term.model.pending.?.history[0].notification);
// Model.deinit's alternate cleanup path also sees threaded=false: the
// undefined thread handle is never joined, and all Job ownership is freed.
diff --git a/apps/native/components/site/ChatTranscript.tsx b/apps/native/components/site/ChatTranscript.tsx
index e21ead8b..e5abb69a 100644
--- a/apps/native/components/site/ChatTranscript.tsx
+++ b/apps/native/components/site/ChatTranscript.tsx
@@ -1,6 +1,7 @@
"use client";
import { memo, useCallback, useLayoutEffect, useRef, useState } from "react";
import { AssistantBody, UserBubble } from "./ChatBubbles";
+import SessionNotice from "./SessionNotice";
import type { Msg } from "./harness-types";
import { pinScrollerTail } from "@/lib/follow-scroll";
import { transcriptPageStart } from "@/lib/transcript-window";
@@ -63,7 +64,9 @@ export default memo(function ChatTranscript({ messages, register, following, onO
setStart(transcriptPageStart(messages, start)); setShown(shown + 1);
}}>Show earlier messages ({start})</button>}
{messages.slice(start).map((message, index) => message.role === "user"
- ? <UserBubble key={message.id} text={message.text} />
+ ? message.origin === "notification"
+ ? <SessionNotice key={message.id} text={message.text} />
+ : <UserBubble key={message.id} text={message.text} />
: <AssistantBody key={message.id} turn={message.turn} onOpenPath={onOpenPath} onReview={onReview}
scroller={scroller} following={following && start + index === messages.length - 1} snapshot={snapshot} />)}
</div>
diff --git a/apps/native/components/site/GraffHarness.tsx b/apps/native/components/site/GraffHarness.tsx
index 612fed65..2ed6ef6f 100644
--- a/apps/native/components/site/GraffHarness.tsx
+++ b/apps/native/components/site/GraffHarness.tsx
@@ -434,7 +434,7 @@ export default function GraffHarness() {
const next = queuesRef.current[thread.id]?.[0];
if (runningRef.current.has(thread.id) && next) steerQueued(thread.id, next.id);
} : undefined,
- history: mergeHistory(history, thread.messages.flatMap(m => m.role === "user" ? [m.text] : [])),
+ history: mergeHistory(history, thread.messages.flatMap(m => m.role === "user" && m.origin !== "notification" ? [m.text] : [])),
busy: busyIds.has(thread.id), onStop: () => {
const live = sessionsRef.current.get(thread.id);
if (!live) { setCancelError(current => ({ ...current, [thread.id]: "Nothing to interrupt yet." })); return; }
diff --git a/apps/native/components/site/SessionNotice.tsx b/apps/native/components/site/SessionNotice.tsx
new file mode 100644
index 00000000..c825d200
--- /dev/null
+++ b/apps/native/components/site/SessionNotice.tsx
@@ -0,0 +1,7 @@
+/** Engine-generated context has its own identity, even when its wire role is user. */
+export default function SessionNotice({ text }: { text: string }) {
+ return <details data-session-notice className="min-w-0 rounded-lg border border-line px-3 py-2 text-[12.5px] leading-relaxed text-ink-2">
+ <summary className="cursor-pointer select-none">Session notification</summary>
+ <p className="mt-2 whitespace-pre-wrap [overflow-wrap:anywhere]">{text}</p>
+ </details>;
+}
diff --git a/apps/native/components/site/harness-types.ts b/apps/native/components/site/harness-types.ts
index a8a3483b..b19ad12a 100644
--- a/apps/native/components/site/harness-types.ts
+++ b/apps/native/components/site/harness-types.ts
@@ -1,6 +1,6 @@
import type { AssistantTurn } from "@/lib/acp";
export type Msg =
- | { id: number; role: "user"; text: string }
+ | { id: number; role: "user"; text: string; origin?: "notification" }
| { id: number; role: "assistant"; turn: AssistantTurn };
/** `model` is what this tab's own agent was spawned with; the harness-level
diff --git a/apps/native/lib/session-projection.test.ts b/apps/native/lib/session-projection.test.ts
index d1905b96..558173d4 100644
--- a/apps/native/lib/session-projection.test.ts
+++ b/apps/native/lib/session-projection.test.ts
@@ -165,3 +165,24 @@ test('#912: snapshot uses saved todos over stale historical writes, and honors c
if (legacy?.role === 'assistant') expect(legacy.turn.todos[0].status).toBe('in_progress');
} finally { file.cleanup(); }
});
+
+
+test("#912: generated notices survive raw and projected loads without claiming matching user text", async () => {
+ const file = fixture();
+ const text = "[job 1 exited 0: check]";
+ const messages = [
+ { role: "user", content: text, _graff_origin: "notification" },
+ { role: "user", content: text },
+ { role: "assistant", content: "Read the output." },
+ ];
+ try {
+ writeFileSync(path.join(file.root, ".graff/sessions/example.session.json"), JSON.stringify({ title: "Untitled session", messages }));
+ for (const view of [undefined, "transcript"]) {
+ const body = await (await GET(new NextRequest(file.url(view)))).json();
+ const loaded = sessionFromResponse(body);
+ expect(loaded.messages[0]).toEqual({ role: "user", text, origin: "notification" });
+ expect(loaded.messages[1]).toEqual({ role: "user", text });
+ expect(loaded.meta.title).toBe(text.slice(0, 80));
+ }
+ } finally { file.cleanup(); }
+});
diff --git a/apps/native/lib/session-store.ts b/apps/native/lib/session-store.ts
index 1c283ad3..c11c4b41 100644
--- a/apps/native/lib/session-store.ts
+++ b/apps/native/lib/session-store.ts
@@ -91,7 +91,7 @@ type HeaderPeek = Header | null;
export function recoveredSessionTitle(title: unknown, messages: unknown): string | null {
if (title !== "Untitled session" || !Array.isArray(messages)) return str(title);
for (const item of messages) {
- if (!item || typeof item !== "object" || item.role !== "user") continue;
+ if (!item || typeof item !== "object" || item.role !== "user" || item._graff_origin === "notification") continue;
const content = typeof item.content === "string" ? item.content : Array.isArray(item.content)
? item.content.filter((part: any) => part && (part.type === "text" || part.type === "input_text") && typeof part.text === "string")
.map((part: any) => part.text).join("\n") : "";
diff --git a/apps/native/lib/sessions.ts b/apps/native/lib/sessions.ts
index 03466c79..ed82b792 100644
--- a/apps/native/lib/sessions.ts
+++ b/apps/native/lib/sessions.ts
@@ -36,7 +36,7 @@ export type SessionPage = {
export type SessionScope = "all" | "local" | "elsewhere";
export type TranscriptMsg =
- | { role: "user"; text: string }
+ | { role: "user"; text: string; origin?: "notification" }
| { role: "assistant"; turn: AssistantTurn };
export type SessionResponse = StoredSession & {
@@ -194,7 +194,7 @@ export function groupSessions(rows: StoredSession[], now = Date.now()): { group:
}
type RawCall = { id?: unknown; function?: { name?: unknown; arguments?: unknown } };
-type RawMsg = { role?: unknown; content?: unknown; tool_calls?: unknown; tool_call_id?: unknown };
+type RawMsg = { _graff_origin?: unknown; role?: unknown; content?: unknown; tool_calls?: unknown; tool_call_id?: unknown };
function textOf(content: unknown): string {
if (typeof content === "string") return content;
@@ -270,7 +270,7 @@ export function transcriptFromMessages(raw: unknown[], model?: string, savedTodo
const text = withoutGuiSkillContext(textOf(msg.content).trim());
if (!text) continue;
flush();
- out.push({ role: "user", text });
+ out.push({ role: "user", text, ...(msg._graff_origin === "notification" ? { origin: "notification" as const } : {}) });
continue;
}
if (msg.role === "assistant") {
diff --git a/docs/adr/0099-gui-saved-sessions-are-snapshots.md b/docs/adr/0099-gui-saved-sessions-are-snapshots.md
index a34a13af..d42d5090 100644
--- a/docs/adr/0099-gui-saved-sessions-are-snapshots.md
+++ b/docs/adr/0099-gui-saved-sessions-are-snapshots.md
@@ -29,6 +29,12 @@ stale or rejected proposals and must not override that saved state. Older
files without the field retain history-based reconstruction. This does not
turn a saved checklist into live execution status.
+Generated wakes retain `_graff_origin: "notification"` in saved message objects.
+Their provider role remains `user`, but wire serializers omit this internal field.
+The GUI renders these as expandable session notices and excludes them from prompt
+recall and title recovery. Text prefixes are not evidence of notification origin;
+older unmarked job notices retain their historical presentation.
+
## Consequences
Opening and refreshing history never bootstrap an ACP session. The composer
diff --git a/evals/harness_behavior.jsonl b/evals/harness_behavior.jsonl
index 4f9c70ea..10254942 100644
--- a/evals/harness_behavior.jsonl
+++ b/evals/harness_behavior.jsonl
@@ -85,3 +85,4 @@
{"id": "mcp-wire-name-normalization", "why": "#930: loading a tool with spaces in its server name and punctuation in its tool name must emit an API-safe definition and retain original MCP dispatch.", "env": {"GRAFF_MCP_SCHEMA_BUDGET": "0", "GRAFF_MCP_PROBE": "0", "GRAFF_LEARN_AUTO": "off"}, "workspace_seed": {".mcp.json": "{\"mcpServers\": {\"docs server\": {\"command\": \"python3\", \"args\": [\"mock_mcp.py\"]}}}", "mock_mcp.py": "import json, sys\nfor line in sys.stdin:\n r = json.loads(line)\n if 'id' not in r: continue\n method = r.get('method')\n if method == 'initialize':\n result = {'protocolVersion':'2025-06-18','capabilities':{'tools':{}},'serverInfo':{'name':'fixture','version':'1'}}\n elif method == 'tools/list':\n result = {'tools':[{'name':'room.for_branch','description':'Find a room','inputSchema':{'type':'object','properties':{}}}]}\n elif method == 'tools/call':\n result = {'content':[{'type':'text','text':'original name routed' if r['params']['name'] == 'room.for_branch' else 'WRONG NAME'}]}\n else: result = {}\n print(json.dumps({'jsonrpc':'2.0','id':r['id'],'result':result}),flush=True)\n"}, "prompt": "Load the docs server tool, call it and report completion.", "script": [{"tool": "load_tool_schemas", "arguments": {"server": "docs server"}}, {"tool": "mcp__docs_x20server__room_x2efor_branch", "arguments": {}}, {"text": "routing complete"}], "assert": [{"request_contains": {"index": 1, "text": "mcp__docs_x20server__room_x2efor_branch"}}, {"request_lacks": {"index": 1, "text": "mcp__docs server__room.for_branch"}}, {"request_contains": {"index": -1, "text": "original name routed"}}, {"final_text_contains": "routing complete"}]}
{"id": "peer-inbox-preserves-live-body-865", "why": "#865: inject a device-room user message after the first drain; full body must survive deliverInbound and inbox tool dispatch without entering the wake.", "prompt": "Run the fixture injection, then read the peer inbox twice.", "script": [{"tool": "bash", "arguments": {"command": "python3 -c 'import json,os,pathlib; p=pathlib.Path(os.environ['\"'\"'HOME'\"'\"'])/'\"'\"'.graff/live/chan-all.jsonl'\"'\"'; p.parent.mkdir(parents=True,exist_ok=True); f=p.open('\"'\"'a'\"'\"'); f.write(json.dumps({'\"'\"'from_pid'\"'\"':2147483000,'\"'\"'from_session'\"'\"':'\"'\"'fixture-peer'\"'\"','\"'\"'from_user'\"'\"':True,'\"'\"'text'\"'\"':'\"'\"'prefix full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload BODY_END_865'\"'\"'})+'\"'\"'\\n'\"'\"'); f.close()'"}}, {"tool": "peer_message", "arguments": {"action": "inbox"}}, {"tool": "peer_message", "arguments": {"action": "inbox"}}, {"text": "fixture complete"}], "assert": [{"request_lacks": {"index": 1, "text": "[peer message from fixture-peer"}}, {"request_contains": {"index": 2, "text": "[peer message from fixture-peer"}}, {"request_contains": {"index": 2, "text": "[peer message from fixture-peer \\u00b7 device]: prefix full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload BODY_END_865"}}, {"request_contains": {"index": 3, "text": "inbox empty"}}, {"no_event": {"type": "tool_call_finished", "name": "peer_message", "is_error": true}}]}
{"id": "peer-inbox-live-multidrain-overflow-unicode-clear-865", "why": "#865: two live device-room drains overflow the eight-slot ring cumulatively (10 then 5: 2 then 7 lost); exact tool results prove retained 7..14 order and full 211-character Unicode bodies/device flags, read clears messages and loss, and later arrival has no stale loss. Assertions bind complete tool-result objects to call IDs to exclude scripted-command/history false positives.", "prompt": "Inject the two fixture batches, read the inbox twice, inject the fresh fixture, and read twice again.", "script": [{"tool": "bash", "arguments": {"command": "python3 -c 'import json,os,pathlib; p=pathlib.Path(os.environ['\"'\"'HOME'\"'\"'])/'\"'\"'.graff/live/chan-all.jsonl'\"'\"'; p.parent.mkdir(parents=True,exist_ok=True); f=p.open('\"'\"'a'\"'\"'); [f.write(json.dumps({'\"'\"'from_pid'\"'\"':2147483000,'\"'\"'from_session'\"'\"':'\"'\"'overflow-fixture'\"'\"','\"'\"'from_user'\"'\"':True,'\"'\"'text'\"'\"':'\"'\"'item-%02d:'\"'\"'%i+chr(0x754c)*211+'\"'\"':tail-%02d'\"'\"'%i})+'\"'\"'\\n'\"'\"') for i in range(0,10)]; f.close()'"}}, {"tool": "bash", "arguments": {"command": "python3 -c 'import json,os,pathlib; p=pathlib.Path(os.environ['\"'\"'HOME'\"'\"'])/'\"'\"'.graff/live/chan-all.jsonl'\"'\"'; p.parent.mkdir(parents=True,exist_ok=True); f=p.open('\"'\"'a'\"'\"'); [f.write(json.dumps({'\"'\"'from_pid'\"'\"':2147483000,'\"'\"'from_session'\"'\"':'\"'\"'overflow-fixture'\"'\"','\"'\"'from_user'\"'\"':True,'\"'\"'text'\"'\"':'\"'\"'item-%02d:'\"'\"'%i+chr(0x754c)*211+'\"'\"':tail-%02d'\"'\"'%i})+'\"'\"'\\n'\"'\"') for i in range(10,15)]; f.close()'"}}, {"tool": "peer_message", "arguments": {"action": "inbox"}}, {"tool": "peer_message", "arguments": {"action": "inbox"}}, {"tool": "bash", "arguments": {"command": "python3 -c 'import json,os,pathlib; p=pathlib.Path(os.environ['\"'\"'HOME'\"'\"'])/'\"'\"'.graff/live/chan-all.jsonl'\"'\"'; p.parent.mkdir(parents=True,exist_ok=True); f=p.open('\"'\"'a'\"'\"'); [f.write(json.dumps({'\"'\"'from_pid'\"'\"':2147483000,'\"'\"'from_session'\"'\"':'\"'\"'overflow-fixture'\"'\"','\"'\"'from_user'\"'\"':True,'\"'\"'text'\"'\"':'\"'\"'item-%02d:'\"'\"'%i+chr(0x754c)*211+'\"'\"':tail-%02d'\"'\"'%i})+'\"'\"'\\n'\"'\"') for i in range(15,16)]; f.close()'"}}, {"tool": "peer_message", "arguments": {"action": "inbox"}}, {"tool": "peer_message", "arguments": {"action": "inbox"}}, {"text": "fixture complete"}], "assert": [{"request_contains": {"index": 1, "text": "[peer] 8 unread; 2 dropped"}}, {"request_contains": {"index": 2, "text": "[peer] 8 unread; 7 dropped"}}, {"request_contains": {"index": 3, "text": "{\"role\": \"tool\", \"tool_call_id\": \"call_3\", \"content\": \"[peer inbox: 7 dropped message(s) could not be retained; the room log keeps the originals]\\n[peer message from overflow-fixture \\u00b7 device]: item-07:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-07\\n[peer message from overflow-fixture \\u00b7 device]: item-08:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-08\\n[peer message from overflow-fixture \\u00b7 device]: item-09:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-09\\n[peer message from overflow-fixture \\u00b7 device]: item-10:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-10\\n[peer message from overflow-fixture \\u00b7 device]: item-11:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-11\\n[peer message from overflow-fixture \\u00b7 device]: item-12:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-12\\n[peer message from overflow-fixture \\u00b7 device]: item-13:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-13\\n[peer message from overflow-fixture \\u00b7 device]: item-14:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-14\\n(inbox cleared \\u2014 reply with peer_message; omit session for the room, or name one peer to DM)\"}"}}, {"request_contains": {"index": 4, "text": "{\"role\": \"tool\", \"tool_call_id\": \"call_4\", \"content\": \"inbox empty\"}"}}, {"request_contains": {"index": 6, "text": "{\"role\": \"tool\", \"tool_call_id\": \"call_6\", \"content\": \"[peer message from overflow-fixture \\u00b7 device]: item-15:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-15\\n(inbox cleared \\u2014 reply with peer_message; omit session for the room, or name one peer to DM)\"}"}}, {"request_contains": {"index": 7, "text": "{\"role\": \"tool\", \"tool_call_id\": \"call_7\", \"content\": \"inbox empty\"}"}}, {"events_at_least": {"match": {"type": "tool_call_finished", "name": "peer_message", "is_error": false}, "count": 4}}, {"no_event": {"type": "tool_call_finished", "is_error": true}}, {"request_lacks": {"index": 1, "text": "[peer message from overflow-fixture"}}, {"request_lacks": {"index": 2, "text": "[peer message from overflow-fixture"}}, {"request_lacks": {"index": 3, "text": "[peer message from overflow-fixture \\u00b7 device]: item-00:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-00\\n"}}, {"request_lacks": {"index": 3, "text": "[peer message from overflow-fixture \\u00b7 device]: item-01:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-01\\n"}}, {"request_lacks": {"index": 3, "text": "[peer message from overflow-fixture \\u00b7 device]: item-02:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-02\\n"}}, {"request_lacks": {"index": 3, "text": "[peer message from overflow-fixture \\u00b7 device]: item-03:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-03\\n"}}, {"request_lacks": {"index": 3, "text": "[peer message from overflow-fixture \\u00b7 device]: item-04:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-04\\n"}}, {"request_lacks": {"index": 3, "text": "[peer message from overflow-fixture \\u00b7 device]: item-05:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-05\\n"}}, {"request_lacks": {"index": 3, "text": "[peer message from overflow-fixture \\u00b7 device]: item-06:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-06\\n"}}]}
+{"id": "notification-wake-wire", "why": "Generated job wakes remain model-visible user context while saved provenance never reaches provider requests.", "env": {"GRAFF_NO_CODEDB_GUARD": "1"}, "prompt": "Start a background check, do another step, then read the completed check.", "script": [{"tool": "bash", "arguments": {"command": "sleep 0.1; echo notification-ready", "run_in_background": true}}, {"tool": "bash", "arguments": {"command": "sleep 1; echo independent-step"}}, {"tool": "bash_output", "arguments": {"id": 1}}, {"text": "Check completed."}], "assert": [{"request_contains": {"index": 2, "text": "do not poll"}}, {"request_lacks": {"index": 2, "text": "_graff_origin"}}, {"final_text_contains": "Check completed."}]}
diff --git a/src/agent_request_body_responses.zig b/src/agent_request_body_responses.zig
index dc17917e..860ffd8a 100644
--- a/src/agent_request_body_responses.zig
+++ b/src/agent_request_body_responses.zig
@@ -56,7 +56,7 @@ pub fn write(self: *Agent, s: *std.json.Stringify, tools: ?[]const u8, force_too
// this item server-side, so only a full anchor writes it.
if (!chain and explicit_cache) try writeCacheAnchor(s);
const from = if (chain) self.codex_sent_upto else 0;
- if (!self.ws_prewarm) for (self.messages.items[from..]) |m| try s.write(m); // prewarm: NO input items; turn 1 chains onto the warmup id
+ if (!self.ws_prewarm) for (self.messages.items[from..]) |m| try @import("session_wake.zig").writeWire(s, m); // prewarm: NO input items; turn 1 chains onto the warmup id
try s.endArray();
if (tools) |t| {
const payload = blk: {
diff --git a/src/agent_server_compact.zig b/src/agent_server_compact.zig
index c1ace552..69835102 100644
--- a/src/agent_server_compact.zig
+++ b/src/agent_server_compact.zig
@@ -151,7 +151,7 @@ pub fn compactBody(self: *const Agent) ![]u8 {
try s.objectField("model");
try s.write(self.provider.model);
try s.objectField("input");
- try s.write(std.json.Value{ .array = self.messages });
+ try @import("session_wake.zig").writeWireArray(&s, self.messages.items);
try s.objectField("instructions");
try s.write(self.systemPrompt());
try s.endObject();
@@ -437,7 +437,7 @@ fn buildCompactBody(self: *Agent) ![]u8 {
try s.objectField("model");
try s.write(self.provider.model);
try s.objectField("input");
- try s.write(std.json.Value{ .array = self.messages });
+ try @import("session_wake.zig").writeWireArray(&s, self.messages.items);
try s.endObject();
return aw.toOwnedSlice();
}
diff --git a/src/interactions_wire.zig b/src/interactions_wire.zig
index 99a58c70..02632f3c 100644
--- a/src/interactions_wire.zig
+++ b/src/interactions_wire.zig
@@ -56,7 +56,7 @@ pub fn write(self: *Agent, s: *std.json.Stringify, tools: ?[]const u8, force_too
}
try s.objectField("input");
try s.beginArray();
- for (self.messages.items) |m| try s.write(m);
+ for (self.messages.items) |m| try @import("session_wake.zig").writeWire(s, m);
try s.endArray();
if (stream) {
try s.objectField("stream");
diff --git a/src/job_notify.zig b/src/job_notify.zig
index 903ea932..da54f7d5 100644
--- a/src/job_notify.zig
+++ b/src/job_notify.zig
@@ -212,12 +212,7 @@ pub fn deliver(root: *Agent) void {
if (root.sub) return;
var buf: [512]u8 = undefined;
const text = takeWake(root.io, &buf) orelse return;
- const owned = root.arena.dupe(u8, text) catch return;
- var obj: std.json.ObjectMap = .empty;
- obj.put(root.arena, "role", .{ .string = "user" }) catch return;
- obj.put(root.arena, "content", .{ .string = owned }) catch return;
- root.messages.append(.{ .object = obj }) catch {};
- engine_sink.forAgent(root).emit(root.io, .{ .session_notice = .{ .text = owned, .tone = .dim } });
+ @import("session_wake.zig").inject(root, text);
}
test "line names exit, kill, and abnormal end" {
diff --git a/src/peer_channel.zig b/src/peer_channel.zig
index b0f55826..d6b0ce0c 100644
--- a/src/peer_channel.zig
+++ b/src/peer_channel.zig
@@ -236,10 +236,7 @@ pub fn deliverInbound(root: *Agent) void {
}
if (peer_inbox.parkHeard(local_msgs, device_msgs) == 0) return;
// History gets the wake only (ADR 0004). Bodies wait in the ring.
- var obj: std.json.ObjectMap = .empty;
- obj.put(root.arena, "role", .{ .string = "user" }) catch return;
- obj.put(root.arena, "content", .{ .string = peer_context.capInject(peer_inbox.formatWake(root.arena)) }) catch return;
- root.messages.append(.{ .object = obj }) catch {};
+ root.messages.append(@import("session_wake.zig").message(root.arena, peer_context.capInject(peer_inbox.formatWake(root.arena))) catch return) catch {};
}
/// Emit the drain's visible half as one bracketed unit: a blank notice, the
diff --git a/src/providers.zig b/src/providers.zig
index e63a270e..31905ebc 100644
--- a/src/providers.zig
+++ b/src/providers.zig
@@ -68,7 +68,7 @@ fn translateHistory(arena: Allocator, msgs: *std.json.Array, to_kind: Provider.K
if (!std.mem.eql(u8, role, "user") and !std.mem.eql(u8, role, "assistant")) continue;
const text = std.mem.trim(u8, extractText(arena, m), " \t\r\n");
if (text.len == 0) continue;
- out.append(textMessage(arena, role, text) catch continue) catch {};
+ out.append(@import("session_wake.zig").copyOrigin(arena, m, textMessage(arena, role, text) catch continue) catch continue) catch {};
}
msgs.* = out;
}
diff --git a/src/repl_compact.zig b/src/repl_compact.zig
index 5f9ecc2e..4112e4b8 100644
--- a/src/repl_compact.zig
+++ b/src/repl_compact.zig
@@ -78,7 +78,7 @@ pub fn replCompactCb(ctx_ptr: ?*anyopaque, gpa: Allocator, history: []const repl
.user => "user",
.assistant => "assistant",
};
- agent.messages.append(textMessage(arena, role, t.text) catch {
+ agent.messages.append((if (t.notification) @import("session_wake.zig").message(arena, t.text) else textMessage(arena, role, t.text)) catch {
out.note = gpa.dupe(u8, "compaction failed: out of memory") catch "";
return false;
}) catch {
diff --git a/src/repl_convo.zig b/src/repl_convo.zig
index 184c6456..4673dc9c 100644
--- a/src/repl_convo.zig
+++ b/src/repl_convo.zig
@@ -110,7 +110,8 @@ pub const Conversation = struct {
// #714: a host that re-submits the same trailing user row must not
// inject another turn. The named-source gate then re-read the file
// and the session looped the same Q&A.
- if (messages_mod.trailingUserIs(msgs.items, last.text)) return;
+ if (messages_mod.trailingUserIs(msgs.items, last.text) and
+ @import("session_wake.zig").isNotice(msgs.items[msgs.items.len - 1]) == last.notification) return;
try msgs.append(try textOf(self.alloc(), last));
}
@@ -142,6 +143,7 @@ fn cloneArray(a: Allocator, source: std.json.Array) !std.json.Array {
}
fn textOf(a: Allocator, t: repl.Turn) !Value {
+ if (t.notification) return @import("session_wake.zig").message(a, t.text);
return messages_mod.textMessage(a, switch (t.role) {
.user => "user",
.assistant => "assistant",
@@ -149,7 +151,7 @@ fn textOf(a: Allocator, t: repl.Turn) !Value {
}
fn isUserPrompt(v: Value) bool {
- if (v != .object) return false;
+ if (v != .object or @import("session_wake.zig").isNotice(v)) return false;
const role = v.object.get("role") orelse return false;
if (role != .string or !std.mem.eql(u8, role.string, "user")) return false;
const content = v.object.get("content") orelse return false;
diff --git a/src/repl_turn.zig b/src/repl_turn.zig
index 89210aa3..ee7b0d36 100644
--- a/src/repl_turn.zig
+++ b/src/repl_turn.zig
@@ -165,13 +165,14 @@ fn borrowHistory(c: *ReplCtx, agent: *Agent, history: []const repl.Turn, arena:
/// A recalled TUI prompt carries `@[path]` markers. Stage the files so the
/// model gets pixels, not the literal marker (#577).
fn userOrText(agent: *Agent, arena: Allocator, t: repl.Turn) !std.json.Value {
+ if (t.notification) return @import("session_wake.zig").message(arena, t.text);
if (t.role != .user) return textMessage(arena, "assistant", t.text);
vision.stageGuiImageAttachment(agent, t.text);
return vision_queue.consumePromptImages(arena, agent, t.text);
}
fn promoteTailImages(agent: *Agent, cv: anytype, history: []const repl.Turn) !void {
- if (history.len == 0 or history[history.len - 1].role != .user) return;
+ if (history.len == 0 or history[history.len - 1].role != .user or history[history.len - 1].notification) return;
const text = history[history.len - 1].text;
vision.stageGuiImageAttachment(agent, text);
if (agent.pending_image_len == 0) return;
diff --git a/src/repl_types.zig b/src/repl_types.zig
index 41eae720..651b884e 100644
--- a/src/repl_types.zig
+++ b/src/repl_types.zig
@@ -17,6 +17,7 @@ pub const Effort = enum { low, medium, high, xhigh, max, ultra };
pub const Turn = struct {
role: Role,
text: []const u8,
+ notification: bool = false,
pub const Role = enum { user, assistant };
};
diff --git a/src/serde.zig b/src/serde.zig
index 2af99a8e..f3e38d17 100644
--- a/src/serde.zig
+++ b/src/serde.zig
@@ -114,7 +114,7 @@ pub fn writeAnthropicMessages(s: *std.json.Stringify, messages: std.json.Array,
try s.beginArray();
for (items, 0..) |m, i| {
if (m != .object or m.object.get("content") == null) {
- try s.write(m);
+ try @import("session_wake.zig").writeWire(s, m);
continue;
}
const content = m.object.get("content").?;
@@ -122,16 +122,17 @@ pub fn writeAnthropicMessages(s: *std.json.Stringify, messages: std.json.Array,
const string_content = content == .string;
const array_cache = cache_this and content == .array and content.array.items.len > 0 and anthropicCacheableBlock(content.array.items[content.array.items.len - 1]);
if (!normalize_blocks and !cache_this) {
- try s.write(m);
+ try @import("session_wake.zig").writeWire(s, m);
continue;
}
if (!string_content and !array_cache) {
- try s.write(m);
+ try @import("session_wake.zig").writeWire(s, m);
continue;
}
try s.beginObject();
var it = m.object.iterator();
while (it.next()) |kv| {
+ if (std.mem.eql(u8, kv.key_ptr.*, @import("session_wake.zig").origin_key)) continue;
if (std.mem.eql(u8, kv.key_ptr.*, "content")) continue;
try s.objectField(kv.key_ptr.*);
try s.write(kv.value_ptr.*);
@@ -368,16 +369,17 @@ pub fn writeOpenAITools(s: *std.json.Stringify, arena: Allocator, raw: []const u
/// request before the server will USE the replayed reasoning; see the audit
/// note in the ARC parity work.)
pub fn writeOpenAIMessageNormalized(s: *std.json.Stringify, m: Value) !void {
- if (m != .object) return s.write(m);
+ if (m != .object) return @import("session_wake.zig").writeWire(s, m);
const role = if (m.object.get("role")) |v| (if (v == .string) v.string else "") else "";
const is_assistant_tool_call = std.mem.eql(u8, role, "assistant") and m.object.get("tool_calls") != null;
const null_content = if (m.object.get("content")) |v| v == .null else false;
- if (!is_assistant_tool_call or !null_content) return s.write(m);
+ if (!is_assistant_tool_call or !null_content) return @import("session_wake.zig").writeWire(s, m);
try s.beginObject();
var it = m.object.iterator();
var wrote_content = false;
while (it.next()) |kv| {
+ if (std.mem.eql(u8, kv.key_ptr.*, @import("session_wake.zig").origin_key)) continue;
try s.objectField(kv.key_ptr.*);
if (std.mem.eql(u8, kv.key_ptr.*, "content")) {
try s.write("");
diff --git a/src/session_peer.zig b/src/session_peer.zig
index eaf92dab..707546d2 100644
--- a/src/session_peer.zig
+++ b/src/session_peer.zig
@@ -30,7 +30,7 @@ pub fn isHumanUserTurn(m: Value) bool {
if (m != .object) return false;
const role = m.object.get("role") orelse return false;
if (role != .string or !std.mem.eql(u8, role.string, "user")) return false;
- return !peer_context.isPeerInject(m);
+ return !@import("session_wake.zig").isNotice(m) and !peer_context.isPeerInject(m);
}
/// Messages written to `.session.json`: wakes stay out. The transcript still
diff --git a/src/session_wake.zig b/src/session_wake.zig
index 79bc3d83..804818ee 100644
--- a/src/session_wake.zig
+++ b/src/session_wake.zig
@@ -10,13 +10,45 @@ const Agent = agent_mod.Agent;
pub fn inject(root: *Agent, text: []const u8) void {
if (root.sub or text.len == 0) return;
const owned = root.arena.dupe(u8, text) catch return;
- var obj: std.json.ObjectMap = .empty;
- obj.put(root.arena, "role", .{ .string = "user" }) catch return;
- obj.put(root.arena, "content", .{ .string = owned }) catch return;
- root.messages.append(.{ .object = obj }) catch {};
+ root.messages.append(message(root.arena, owned) catch return) catch return;
engine_sink.forAgent(root).emit(root.io, .{ .session_notice = .{ .text = owned, .tone = .dim } });
}
+/// Persisted provenance, never a provider API field. Text is not an identity.
+pub const origin_key = "_graff_origin";
+pub fn isNotice(m: std.json.Value) bool {
+ if (m != .object) return false;
+ const v = m.object.get(origin_key) orelse return false;
+ return v == .string and std.mem.eql(u8, v.string, "notification");
+}
+pub fn message(a: std.mem.Allocator, text: []const u8) !std.json.Value {
+ var m = try @import("messages.zig").textMessage(a, "user", text);
+ try m.object.put(a, origin_key, .{ .string = "notification" });
+ return m;
+}
+pub fn copyOrigin(a: std.mem.Allocator, source: std.json.Value, dest: std.json.Value) !std.json.Value {
+ var m = dest;
+ if (isNotice(source) and m == .object) try m.object.put(a, origin_key, .{ .string = "notification" });
+ return m;
+}
+/// Preserve provider-native fields and ordering, excluding only our provenance.
+pub fn writeWire(s: *std.json.Stringify, m: std.json.Value) !void {
+ if (m != .object) return s.write(m);
+ try s.beginObject();
+ var it = m.object.iterator();
+ while (it.next()) |kv| {
+ if (std.mem.eql(u8, kv.key_ptr.*, origin_key)) continue;
+ try s.objectField(kv.key_ptr.*);
+ try s.write(kv.value_ptr.*);
+ }
+ try s.endObject();
+}
+pub fn writeWireArray(s: *std.json.Stringify, items: []const std.json.Value) !void {
+ try s.beginArray();
+ for (items) |m| try writeWire(s, m);
+ try s.endArray();
+}
+
test "inject is a no-op on subagents" {
var root: Agent = undefined;
root.sub = true;
@@ -39,6 +71,52 @@ test "inject appends a user-role line on the root" {
root.sink = .{ .ctx = undefined, .vt = &vt };
inject(&root, "wake up");
try std.testing.expectEqual(@as(usize, 1), root.messages.items.len);
+ try std.testing.expect(isNotice(root.messages.items[0]));
try std.testing.expectEqualStrings("user", root.messages.items[0].object.get("role").?.string);
try std.testing.expectEqualStrings("wake up", root.messages.items[0].object.get("content").?.string);
}
+
+test "notification provenance survives saved JSON and conversation adoption without claiming identical user text" {
+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);
+ defer arena_state.deinit();
+ const a = arena_state.allocator();
+ var cv = @import("repl_convo.zig").Conversation.init(std.testing.allocator);
+ defer cv.deinit();
+ try cv.adopt(&.{.{ .role = .user, .text = "wake up", .notification = true }});
+ try cv.adopt(&.{.{ .role = .user, .text = "wake up" }});
+ try std.testing.expectEqual(@as(usize, 2), cv.len());
+ const saved = try @import("session_peer.zig").messagesForSave(a, cv.list().items);
+ var aw: std.Io.Writer.Allocating = .init(a);
+ var s: std.json.Stringify = .{ .writer = &aw.writer };
+ try s.write(std.json.Value{ .array = saved });
+ const restored = try std.json.parseFromSliceLeaky(std.json.Value, a, aw.written(), .{});
+ try std.testing.expect(isNotice(restored.array.items[0]));
+ try std.testing.expect(!@import("session_peer.zig").isHumanUserTurn(restored.array.items[0]));
+ try std.testing.expect(!isNotice(restored.array.items[1]));
+ const turns = try @import("tui_session.zig").visibleTurns(a, restored.array);
+ try std.testing.expect(turns[0].notification);
+ try std.testing.expect(!turns[1].notification);
+}
+
+test "notification metadata stays off chat, responses and anthropic wires including cache branches" {
+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);
+ defer arena_state.deinit();
+ const a = arena_state.allocator();
+ const m = try message(a, "wake up");
+ var msgs = std.json.Array.init(a);
+ try msgs.append(m);
+ try msgs.append(m); // exercise both the prefix and final cache breakpoint
+ const serde = @import("serde.zig");
+ for (0..6) |mode| {
+ var aw: std.Io.Writer.Allocating = .init(a);
+ var s: std.json.Stringify = .{ .writer = &aw.writer };
+ if (mode == 0) try writeWireArray(&s, msgs.items) else if (mode == 1)
+ try serde.writeOpenAIMessageNormalized(&s, m)
+ else
+ try serde.writeAnthropicMessages(&s, msgs, mode & 1 == 1, mode & 2 == 2);
+ try std.testing.expect(std.mem.indexOf(u8, aw.written(), origin_key) == null);
+ try std.testing.expect(std.mem.indexOf(u8, aw.written(), "wake up") != null);
+ try std.testing.expect(std.mem.indexOf(u8, aw.written(), "\"role\":\"user\"") != null);
+ }
+ try std.testing.expect(isNotice(m)); // serialization must not mutate the saved object
+}
diff --git a/src/tui_acp.zig b/src/tui_acp.zig
index eab226fe..99aface1 100644
--- a/src/tui_acp.zig
+++ b/src/tui_acp.zig
@@ -245,7 +245,7 @@ pub fn turn(
turns.append(.{ .role = switch (t.role) {
.user => .user,
.assistant => .assistant,
- }, .text = text }) catch gpa.free(text);
+ }, .text = text, .notification = t.notification }) catch gpa.free(text);
}
var last_len: u32 = 0;
const user_text: []const u8 = if (history.len > 0 and history[history.len - 1].role == .user) blk: {
diff --git a/src/tui_launch.zig b/src/tui_launch.zig
index a4debf29..595a93e7 100644
--- a/src/tui_launch.zig
+++ b/src/tui_launch.zig
@@ -292,7 +292,7 @@ fn compactCb(ctx: ?*anyopaque, gpa: Allocator, history: []const tui.Turn, out: *
turns.append(.{ .role = switch (t.role) {
.user => .user,
.assistant => .assistant,
- }, .text = text }) catch gpa.free(text);
+ }, .text = text, .notification = t.notification }) catch gpa.free(text);
}
var raw: @import("repl_compact.zig").CompactOut = .{};
const ok = @import("repl_compact.zig").replCompactCb(ctx, gpa, turns.items, &raw);
@@ -310,7 +310,7 @@ fn compactCb(ctx: ?*anyopaque, gpa: Allocator, history: []const tui.Turn, out: *
converted[i] = .{ .role = switch (t.role) {
.user => .user,
.assistant => .assistant,
- }, .text = t.text };
+ }, .text = t.text, .notification = t.notification };
}
gpa.free(raw.turns);
out.turns = converted;
diff --git a/src/tui_session.zig b/src/tui_session.zig
index 6f34543f..4775db1f 100644
--- a/src/tui_session.zig
+++ b/src/tui_session.zig
@@ -26,7 +26,7 @@ pub fn visibleTurns(arena: Allocator, messages: std.json.Array) ![]tui.Turn {
const role = visibleRole(message) orelse continue;
const text = try visibleText(arena, message);
if (text.len == 0) continue;
- try turns.append(arena, .{ .role = role, .text = text });
+ try turns.append(arena, .{ .role = role, .text = text, .notification = @import("session_wake.zig").isNotice(message) });
}
return try turns.toOwnedSlice(arena);
}