Skip to content

Self-improving AI Employees for everyone

test(chat): the shared run fixture says only what the server sends

trohitg2570001223ce
diff --git a/client/src/features/chat/__fixtures__/saturday-booking.events.json b/client/src/features/chat/__fixtures__/saturday-booking.events.json
index e5422a24..e17dcd83 100644
--- a/client/src/features/chat/__fixtures__/saturday-booking.events.json
+++ b/client/src/features/chat/__fixtures__/saturday-booking.events.json
@@ -770,70 +770,6 @@
"specversion": "1.0",
"id": "r_8f2a1c:25",
"source": "opencompany://services/chat",
- "type": "com.opencompany.chat.run.tool_call.started",
- "subject": "r_8f2a1c",
- "time": "2026-09-27T14:02:25.000Z",
- "datacontenttype": "application/json",
- "data": {
- "workflow_id": "wf_salon",
- "session_id": "wf_salon",
- "run_id": "r_8f2a1c",
- "seq": 25,
- "hub_epoch": "e_fixture",
- "tool_call_id": "call_8f2a1c",
- "tool_call_name": "whatsapp_send",
- "parent_message_id": "a_r_8f2a1c",
- "label": "WhatsApp"
- }
- }
- },
- {
- "type": "chat_run_event",
- "data": {
- "specversion": "1.0",
- "id": "r_8f2a1c:26",
- "source": "opencompany://services/chat",
- "type": "com.opencompany.chat.run.tool_call.args",
- "subject": "r_8f2a1c",
- "time": "2026-09-27T14:02:26.000Z",
- "datacontenttype": "application/json",
- "data": {
- "workflow_id": "wf_salon",
- "session_id": "wf_salon",
- "run_id": "r_8f2a1c",
- "seq": 26,
- "hub_epoch": "e_fixture",
- "tool_call_id": "call_8f2a1c",
- "delta": "{\"phone\": \"Priya Shah\", \"message\": \"Hi Priya! Saturday at 14:30 is free for a colour with Ana (about 2 hours). Shall I book you in? I’ll send you a reminder the day before.\"}"
- }
- }
- },
- {
- "type": "chat_run_event",
- "data": {
- "specversion": "1.0",
- "id": "r_8f2a1c:27",
- "source": "opencompany://services/chat",
- "type": "com.opencompany.chat.run.tool_call.ended",
- "subject": "r_8f2a1c",
- "time": "2026-09-27T14:02:27.000Z",
- "datacontenttype": "application/json",
- "data": {
- "workflow_id": "wf_salon",
- "session_id": "wf_salon",
- "run_id": "r_8f2a1c",
- "seq": 27,
- "hub_epoch": "e_fixture",
- "tool_call_id": "call_8f2a1c"
- }
- }
- },
- {
- "type": "chat_run_event",
- "data": {
- "specversion": "1.0",
- "id": "r_8f2a1c:28",
- "source": "opencompany://services/chat",
"type": "com.opencompany.chat.run.activity.snapshot",
"subject": "r_8f2a1c",
"time": "2026-09-27T14:02:28.000Z",
@@ -842,14 +778,13 @@
"workflow_id": "wf_salon",
"session_id": "wf_salon",
"run_id": "r_8f2a1c",
- "seq": 28,
+ "seq": 25,
"hub_epoch": "e_fixture",
- "message_id": "p_approval_1",
+ "message_id": "ap_1",
"activity_type": "approval",
"content": {
"approval_id": "ap_1",
- "tool_call_id": "call_8f2a1c",
- "status": "pending"
+ "tool_call_id": "call_8f2a1c"
},
"replace": true
}
@@ -859,7 +794,7 @@
"type": "chat_run_event",
"data": {
"specversion": "1.0",
- "id": "r_8f2a1c:29",
+ "id": "r_8f2a1c:26",
"source": "opencompany://services/chat",
"type": "com.opencompany.chat.run.finished",
"subject": "r_8f2a1c",
@@ -869,33 +804,10 @@
"workflow_id": "wf_salon",
"session_id": "wf_salon",
"run_id": "r_8f2a1c",
- "seq": 29,
+ "seq": 26,
"hub_epoch": "e_fixture",
"outcome": {
- "type": "interrupt",
- "interrupts": [
- {
- "id": "ap_1",
- "reason": "tool_call",
- "message": "Maya wants to send a message",
- "tool_call_id": "call_8f2a1c",
- "response_schema": {
- "type": "object",
- "properties": {
- "approved": {
- "type": "boolean"
- },
- "edited_args": {
- "type": "object"
- }
- },
- "required": [
- "approved"
- ]
- },
- "expires_at": "2026-10-04T14:02:00.000Z"
- }
- ]
+ "type": "success"
},
"result": {
"reply_message_id": "a_r_8f2a1c"
@@ -904,106 +816,5 @@
"step_count": 3
}
}
- },
- {
- "type": "chat_run_event",
- "data": {
- "specversion": "1.0",
- "id": "r_9b3d2e:1",
- "source": "opencompany://services/chat",
- "type": "com.opencompany.chat.run.started",
- "subject": "r_9b3d2e",
- "time": "2026-09-27T14:02:30.000Z",
- "datacontenttype": "application/json",
- "data": {
- "workflow_id": "wf_salon",
- "session_id": "wf_salon",
- "run_id": "r_9b3d2e",
- "seq": 1,
- "hub_epoch": "e_fixture",
- "kind": "resume",
- "parent_run_id": "r_8f2a1c",
- "reply_message_id": "a_r_8f2a1c",
- "started_at": "2026-09-27T14:03:10.000Z"
- }
- }
- },
- {
- "type": "chat_run_event",
- "data": {
- "specversion": "1.0",
- "id": "r_9b3d2e:2",
- "source": "opencompany://services/chat",
- "type": "com.opencompany.chat.run.tool_call.result",
- "subject": "r_9b3d2e",
- "time": "2026-09-27T14:02:31.000Z",
- "datacontenttype": "application/json",
- "data": {
- "workflow_id": "wf_salon",
- "session_id": "wf_salon",
- "run_id": "r_9b3d2e",
- "seq": 2,
- "hub_epoch": "e_fixture",
- "message_id": "t_call_8f2a1c",
- "tool_call_id": "call_8f2a1c",
- "content": "{\"status\": \"sent\", \"approved_by\": \"user\"}",
- "role": "tool"
- }
- }
- },
- {
- "type": "chat_run_event",
- "data": {
- "specversion": "1.0",
- "id": "r_9b3d2e:3",
- "source": "opencompany://services/chat",
- "type": "com.opencompany.chat.run.activity.delta",
- "subject": "r_9b3d2e",
- "time": "2026-09-27T14:02:32.000Z",
- "datacontenttype": "application/json",
- "data": {
- "workflow_id": "wf_salon",
- "session_id": "wf_salon",
- "run_id": "r_9b3d2e",
- "seq": 3,
- "hub_epoch": "e_fixture",
- "message_id": "p_approval_1",
- "activity_type": "approval",
- "patch": [
- {
- "op": "replace",
- "path": "/status",
- "value": "sent"
- }
- ]
- }
- }
- },
- {
- "type": "chat_run_event",
- "data": {
- "specversion": "1.0",
- "id": "r_9b3d2e:4",
- "source": "opencompany://services/chat",
- "type": "com.opencompany.chat.run.finished",
- "subject": "r_9b3d2e",
- "time": "2026-09-27T14:02:33.000Z",
- "datacontenttype": "application/json",
- "data": {
- "workflow_id": "wf_salon",
- "session_id": "wf_salon",
- "run_id": "r_9b3d2e",
- "seq": 4,
- "hub_epoch": "e_fixture",
- "outcome": {
- "type": "success"
- },
- "result": {
- "reply_message_id": "a_r_8f2a1c"
- },
- "duration_ms": 5200,
- "step_count": 0
- }
- }
}
]
diff --git a/client/src/lib/agui/__tests__/reduceRun.test.ts b/client/src/lib/agui/__tests__/reduceRun.test.ts
index 858916cc..ab4603c8 100644
--- a/client/src/lib/agui/__tests__/reduceRun.test.ts
+++ b/client/src/lib/agui/__tests__/reduceRun.test.ts
@@ -1,8 +1,8 @@
/**
* A chat run folded from its events: the handoff's Saturday booking run
- * (steps, streamed text, a generated interface patch by patch, a draft
- * waiting for the owner, then the resume run that sent it), duplicates, and
- * the snapshots the server sends.
+ * (steps, streamed text, a generated interface patch by patch, and the card
+ * of a draft waiting for the owner), duplicates, and the snapshots the
+ * server sends.
*/
import { describe, expect, it } from 'vitest';
@@ -46,16 +46,17 @@ describe('parseRunFrame', () => {
});
describe('applyRunEvent', () => {
- it('folds the handoff run: steps, the reply text, and the draft that waits', () => {
+ it('folds the handoff run: steps, the reply text, and the card of its draft', () => {
const run = replayRun('r_8f2a1c', 'wf_salon', eventsOf('r_8f2a1c'));
expect(run).toMatchObject({
state: 'finished',
kind: 'message',
userMessageId: 'm_owner_1',
replyMessageId: 'a_r_8f2a1c',
- seq: 29,
- outcome: { type: 'interrupt', interrupts: [{ id: 'ap_1', reason: 'tool_call', toolCallId: 'call_8f2a1c' }] },
+ seq: 26,
+ outcome: { type: 'success' },
});
+ expect(run.activities.map((activity) => activity.activityType)).toEqual(['json_render', 'approval']);
expect(run.steps.map((step) => [step.name, step.state, step.durationMs])).toEqual([
['Checked Google Calendar', 'done', 640],
['Read the WhatsApp thread with Priya', 'done', 640],
@@ -100,13 +101,6 @@ describe('applyRunEvent', () => {
expect(parseRunFrame(envelope('activity.snapshot', { activity_type: 'json_render', content: {} }))).toBeNull();
});
- it('folds the resume run that sent the draft', () => {
- const resume = eventsOf('r_8f2a1c').length;
- const others = frames.slice(resume).filter((frame): frame is RunEvent => frame !== null && frame.type !== 'resync');
- const run = replayRun(others[0].runId, 'wf_salon', others);
- expect(run).toMatchObject({ kind: 'resume', parentRunId: 'r_8f2a1c', state: 'finished', outcome: { type: 'success' } });
- });
-
it('changes nothing for an event it has already seen', () => {
const started = parseRunFrame(envelope('started', { kind: 'message' })) as RunEvent;
const once = applyRunEvent(emptyRun('r1', 'w1'), started);
diff --git a/docs-internal/chat_protocol.md b/docs-internal/chat_protocol.md
index 024cb467..940cbb3d 100644
--- a/docs-internal/chat_protocol.md
+++ b/docs-internal/chat_protocol.md
@@ -601,9 +601,9 @@ and server tests alike:
- `<name>.spec.json` and `<name>.patches.jsonl` (`saturday-booking`, `reply-insights`, `reminders`): json-render
specs and the depth-first patch stream for each. SlotPicker options use the catalog's generic keys (`time`,
`detail`, `recommended`, `unavailable`, `note`) instead of the handoff's salon ones.
-- `saturday-booking.events.json`: the handoff's AG-UI run as `chat_run_event` frames — steps, text, a generated UI
- streamed as `activity.delta` patches, a held WhatsApp send ending the run with an `interrupt` outcome, and the
- `resume` run that sends it once the owner presses Send.
+- `saturday-booking.events.json`: the handoff's AG-UI run as `chat_run_event` frames, as the server sends them:
+ steps, text, a generated UI streamed as `activity.delta` patches, the card of a held WhatsApp send
+ (`activity_type: "approval"`, as `parts.show_approval` publishes it), and `finished` with outcome `success`.
## Error codes
diff --git a/server/tests/services/chat/test_hub.py b/server/tests/services/chat/test_hub.py
index 38b42129..63457c47 100644
--- a/server/tests/services/chat/test_hub.py
+++ b/server/tests/services/chat/test_hub.py
@@ -160,9 +160,10 @@ def fixture_events():
def test_the_fixture_run_folds_to_its_final_state():
events = [event for event in fixture_events() if event["subject"] == "r_8f2a1c"]
snapshot = reducer.replay("r_8f2a1c", events)
- assert snapshot["state"] == "finished" and snapshot["seq"] == 29
- assert snapshot["outcome"]["type"] == "interrupt"
- assert [interrupt["id"] for interrupt in snapshot["interrupts"]] == ["ap_1"]
+ assert snapshot["state"] == "finished" and snapshot["seq"] == 26
+ assert snapshot["outcome"]["type"] == "success"
+ # The interface it streamed, and the card of the draft it made.
+ assert [activity["activity_type"] for activity in snapshot["activities"]] == ["json_render", "approval"]
assert [step["state"] for step in snapshot["steps"]] == ["done", "done", "done"]
assert snapshot["steps"][0]["name"] == "Checked Google Calendar"
[segment] = snapshot["segments"]
@@ -178,12 +179,6 @@ def test_every_prefix_folds_and_duplicates_change_nothing():
assert reducer.apply_event(snapshot, event) == snapshot
-def test_the_resume_run_folds_on_its_own():
- events = [event for event in fixture_events() if event["subject"] == "r_9b3d2e"]
- snapshot = reducer.replay("r_9b3d2e", events)
- assert (snapshot["kind"], snapshot["parent_run_id"], snapshot["state"]) == ("resume", "r_8f2a1c", "finished")
-
-
def test_a_discarded_segment_and_stopping_fold():
snapshot = reducer.empty_snapshot("r")
for seq, (suffix, data) in enumerate(