You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit dc635b8
Browse filesBrowse the repository at this point in the historyBrowse files
`aictrl run --format json` never emitted user messages, so the stream
could not reconstruct what the model was asked. Emit each primary-session
user message once, with its messageID, agent, model, full parts as stored
(synthetic flags and -f file parts included) and a sequenceNum on the
per-session counter shared with text/reasoning/tool_use.
The bus has no "user message complete" event: updateMessage publishes the
info, then updatePart publishes each part. A small collector in
run.user-message.ts treats the message as complete at the first
primary-session event that is not about it (the loop's busy status, the
assistant message, an error or idle), so user_message always precedes the
assistant events it triggers. Child-session user messages are not emitted,
matching text.
This covers the prompt, the --command expansion, and the user messages the
loop stores itself (compaction request, compaction continue, subtask
summary). The StructuredOutput corrective reminder is never stored, so it
has no user_message; structured_output_rejected already reports it.
Additive: schemaVersion stays "1". Part of #223.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015nwvfUHdM3bgMgD9Zpz7Mj
Copy file name to clipboardExpand all lines: CHANGELOG.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,10 @@
2
2
3
3
## Unreleased
4
4
5
+
### Features
6
+
7
+
-**`user_message` NDJSON event** — `aictrl run --format json` now emits each primary-session user message once, with its `messageID`, `agent`, `model`, full `parts` as stored (including `synthetic` flags and `-f` file parts) and a `sequenceNum` on the per-session counter shared with `text`, `reasoning` and `tool_use`. It covers the prompt, the `--command` expansion and the user messages the loop creates (the compaction request, the compaction "continue" message and the subtask summary request), and always comes before the assistant events it triggers. Parts are not truncated, so consumers must accept large lines. The StructuredOutput corrective reminder is not stored, so it has no `user_message`. Subagent user messages are not emitted. The event is additive; `schemaVersion` stays `"1"`. (part of #223)
8
+
5
9
### Fixes
6
10
7
11
-**Messages written in the same millisecond keep their order** — Reading a session's messages now breaks `time_created` ties by message ID. Before, messages written in the same millisecond came back oldest first. A compaction writes its request, its summary and the continue message in quick succession, so the prompt loop could miss the finished summary and compact again, sending an extra model request. (#200)
Copy file name to clipboardExpand all lines: EVENTS.md
+34-3Lines changed: 34 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -220,6 +220,37 @@ Emitted when a primary-session model attempt fails with a retryable error and th
220
220
221
221
**Retry delays.** No single wait between attempts exceeds 5 minutes, whatever the status code or headers. Each retry waits for the provider's `Retry-After` / `retry-after-ms` when it asks for a positive wait, or else for exponential backoff of 2 s, 4 s, 8 s and 16 s, then 30 s for each later attempt. A retryable error whose provider asks for a wait longer than 5 minutes is not retried: a 429 fails as a provider usage limit (see `session_error`), and any other status (for example a 503 or 529 "overloaded" with `retry-after: 18000`) fails with that provider error, so `session_error.reason` is classified from its status as usual (`provider` for a 5xx). Neither emits a `retry` event. With at most 10 retries, the waits total at most 50 minutes when every response asks for 5 minutes, and 3.5 minutes (210 s) when no response gives a retry hint.
222
222
223
+
### `user_message`
224
+
225
+
Emitted once for each primary-session user message, after all of its parts are stored. This covers the prompt (with its `-f` file parts and any agent or subtask parts), the `--command` expansion, and the user messages the session loop creates itself: the compaction request, the compaction "continue" message and the message that asks the model to summarize a subtask's output.
-`messageID` (string, **required**) — stable user-message identity. Assistant messages it triggers carry it as their `parentID`.
247
+
-`agent` (string, **required**) — the agent the message was sent to.
248
+
-`model` (object, **required**) — `{ providerID, modelID }` the message was sent with.
249
+
-`parts` (array, **required**) — the message's parts exactly as stored, in the order they were written. Parts the CLI derived from the input have `synthetic: true`; for example, the text a `-f` file or MCP resource expands to, or the compaction "continue" text. A compaction request has a single `compaction` part. Parts are not truncated: a `file` part can carry a `data:` URL, so consumers must accept arbitrarily large lines, as for `reasoning`.
250
+
-`sequenceNum` (number, **required**) — the same per-session counter as `text`, `reasoning` and `tool_use`. A `user_message` is emitted before any event of the assistant turn it triggers, so its `sequenceNum` is lower than theirs.
251
+
252
+
The StructuredOutput corrective reminder is not a stored user message. It is added to the next model request only, so it emits no `user_message`; `structured_output_rejected` reports each corrective turn instead. Child-session (subagent) user messages are not emitted, matching `text`.
253
+
223
254
### `message_complete`
224
255
225
256
Emitted when a primary-session assistant message finishes (one per LLM turn). Child-session assistant messages are
@@ -314,7 +345,7 @@ Emitted when a text block from the assistant is complete.
314
345
}
315
346
```
316
347
317
-
-`sequenceNum` (number, **required**) — monotonic per-session counter shared across `text`, `reasoning`, and `tool_use` events. Use it to render a correctly-ordered trace without relying on timestamp ties. Subagent sessions have their own independent counters keyed on `part.sessionID`. Note: in JSON mode only `tool_use` events are emitted for subagent sessions, so subagent counters increment only on tool_use.
348
+
-`sequenceNum` (number, **required**) — monotonic per-session counter shared across `user_message`, `text`, `reasoning`, and `tool_use` events. Use it to render a correctly-ordered trace without relying on timestamp ties. Subagent sessions have their own independent counters keyed on `part.sessionID`. Note: in JSON mode only `tool_use` events are emitted for subagent sessions, so subagent counters increment only on tool_use.
318
349
319
350
### `reasoning`
320
351
@@ -331,7 +362,7 @@ Emitted when extended thinking content is complete (requires `--thinking` flag).
331
362
}
332
363
```
333
364
334
-
-`sequenceNum` (number, **required**) — monotonic per-session counter shared across `text`, `reasoning`, and `tool_use` events. Use it to render a correctly-ordered trace without relying on timestamp ties. Subagent sessions have their own independent counters keyed on `part.sessionID`. Note: in JSON mode only `tool_use` events are emitted for subagent sessions, so subagent counters increment only on tool_use.
365
+
-`sequenceNum` (number, **required**) — monotonic per-session counter shared across `user_message`, `text`, `reasoning`, and `tool_use` events. Use it to render a correctly-ordered trace without relying on timestamp ties. Subagent sessions have their own independent counters keyed on `part.sessionID`. Note: in JSON mode only `tool_use` events are emitted for subagent sessions, so subagent counters increment only on tool_use.
335
366
- One event is emitted per complete reasoning block. `part.text` has no size cap; consumers must accept arbitrarily large strings.
336
367
337
368
## Tool Events
@@ -356,7 +387,7 @@ Emitted when a tool call completes (success or error). This includes tools execu
356
387
}
357
388
```
358
389
359
-
-`sequenceNum` (number, **required**) — monotonic per-session counter shared across `text`, `reasoning`, and `tool_use` events. Use it to render a correctly-ordered trace without relying on timestamp ties. Subagent sessions have their own independent counters keyed on `part.sessionID`. Note: in JSON mode only `tool_use` events are emitted for subagent sessions, so subagent counters increment only on tool_use.
390
+
-`sequenceNum` (number, **required**) — monotonic per-session counter shared across `user_message`, `text`, `reasoning`, and `tool_use` events. Use it to render a correctly-ordered trace without relying on timestamp ties. Subagent sessions have their own independent counters keyed on `part.sessionID`. Note: in JSON mode only `tool_use` events are emitted for subagent sessions, so subagent counters increment only on tool_use.
360
391
361
392
`state.status` is `"completed"` or `"error"`. On error, `state.error` contains the error message.
0 commit comments