Repository navigation
feat(codex): a sleep item is a sleep tool call - #84
Merged
Merged
Conversation
codex emits sleep items while the model waits ({durationMs}, ended early
by a steer); they produced no events, so a host showed nothing between
"I'll wait" and the next message. They now map to tool_call_started with
{durationMs} as input and tool_call_ended without a result (codex reports
no status for them). Closes #83.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Merged
xxchan
added a commit
that referenced
this pull request
Oct 3, 2026
Patch release: #84 maps codex `sleep` items (the model waiting) to a `sleep` tool call with `{durationMs}` as input. Version bump only. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: exe.dev user <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
xxchan
added a commit
that referenced
this pull request
Oct 3, 2026
…ge (#86) Closes #82. ## Why Two problems in the session view (`viewOf` / `reduceSessionView`), both visible in a real codex run (prompt `sleep 100`, then three steers while the agent waits): 1. **A steer appeared where it was sent, not where the runtime took it.** `upsertInput` appended the input and sealed the turn on the `steer` request. Codex holds a steer until its current step ends, so the reply to `test 1` rendered after `test 2` and `test 3`, which the agent hadn't read yet. 2. **Two assistant messages merged.** `text_delta` carried no message identity, so separate `agentMessage` items in one turn became one run-on text part. Before (today's `viewOf` on the recording): ``` input sleep 100 turn 好,我等 100 秒。 input test 1 input test 2 input test 3 turn 收到“test 1”。…剩余时间。收到“test 2”和“test 3”。… ``` After: ``` input sleep 100 turn 好,我等 100 秒。 · sleep input test 1 turn 收到“test 1”。… · sleep input test 2 input test 3 turn 收到“test 2”和“test 3”。… · sleep · sleep · 已等待约 100 秒,… ``` (The `sleep` tool parts come from #84, already on main.) ## Rules (as agreed with @cindy) **A steer enters the conversation where the agent read it.** - A `steer` or `queue` input enters `messages` only at the first `user_message` whose `inputId` matches it, and seals the open segment there. Until then it is not in `messages`. It waits in the new **`SessionView.pendingInputs`** (`ConversationInput[]`, request order), so a host can show it above the composer. - **Echo detection reads the stream itself.** There is no capability flag and no runtime-name check. Once the stream has carried a `user_message` with an `inputId` (codex and claude echo the first prompt), later steers and queues wait for their echo. A stream that never has (grok, kimi; pi's echo has no `inputId`, so it can't match) keeps today's placement at the request. This is derived from `view.conversation`: some input has an observation. - Prompts keep today's placement and open their turn. - A rejected input enters where it was refused, as today. If a `deliver` / `steerOrQueue` retry of the same input then has to wait for its echo (prompt refused `busy` → steer, steer refused → queue), the input leaves `messages` again. The segment it had sealed reopens, so the turn doesn't split at an input that is no longer there. - A steer still unread when the turn ends stays in `pendingInputs`. No position is invented for it. If its echo arrives later (a later turn, or a later stream after resume, since input identity crosses `streamId`s), it enters there. - A queued input's echo arrives when the runtime drains it, so it sits just before the adopted turn it starts. - `reduceSessionViewInput` (an app's own submission) still places the input immediately. **Text splits per message.** - `text_delta` gains optional **`messageId`**: codex = the agentMessage `itemId` (`item/agentMessage/delta`), claude = the assistant `message.id`. pi and ACP name none, so they are left as is. - In the view, a `text_delta` whose `messageId` differs from the last text part's starts a new part. Without a `messageId` (pi, ACP, older records) text concatenates as before. Text `ViewPart`s carry `messageId`. - `coalesceText` (`Session.events({ coalesceText })`) no longer merges across different `messageId`s. **Also fixed on the way:** `reduceSessionView` now skips a record its stream has already folded, for the whole view. Before, only the conversation fold skipped it, so folding a log twice opened an extra empty turn from the duplicated prompt request. ## Public API - `SessionView.pendingInputs: readonly ConversationInput[]` (new) - `text_delta.messageId?: string` on `RuntimeEventBody` / `Event` (new, optional) - `ViewPart` text: `messageId?: string` (new, optional) Behaviour change for hosts on codex/claude: a steer or queue is no longer in `messages` until the runtime echoes it. A host that wants it visible meanwhile should render `pendingInputs`. ## Tests - `tests/replay/codex-steer-order.test.ts` replays the real codex recording (`tests/replay/fixtures/codex-steer-order.records.jsonl`, oar RawEvent records, scrubbed). Every frame is re-read through today's codex projection, so `messageId` is exercised (frames whose native the scrub emptied keep their recorded events). It pins the order above, `pendingInputs` = `[test 2, test 3]` mid-run, re-read text = recorded text plus four distinct agentMessage ids, and double-folding idempotence. It also has a focused codex `messageId` adapter case. - `tests/session-view-inputs.test.ts` covers an echoing stream, the no-echo fallback (including pi's unlinked echo), an unread steer at turn end and its late echo in a later turn, the queue drain, a refused steer retried as a queue, a prompt refused `busy` retried as a steer, a pending steer echoed in a resumed stream, and records folded twice. - claude `messageId` adapter test, a view `messageId` split test, and a `coalesceText` `messageId` test. - `pnpm run check` (typecheck, lint, 530 tests, mock sea-trial) and `pnpm run build` pass. `OAR_TEST=codex-aimock` / `claude-aimock` `pnpm sea-trial` and their vendor tests pass. ## Docs `docs/design/chat-ui.md` (surface, mapping rows for prompt/steer/queue request and response, `user_message`, `text_delta`, assistant-ui mapping), `docs/spec/conversation.md` (new section: where an input enters the session view), `docs/spec/record-stream.md`, and the codex and claude runtime pages. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
xxchan
added a commit
that referenced
this pull request
Oct 3, 2026
A host can show what a tool call did, but not how long it ran. Codex `sleep` calls (#84) need this most. The model asks to wait 50 s and a steer cuts the wait short; only the observed times show how long it actually waited ("Waited 8 s of 50 s"). **What changes** - `ViewPart` tool gets optional `startedAt` and `endedAt`: the `receivedAt` of the call's `tool_call_started` and `tool_call_ended` records, in epoch ms. This is the same rule as `tasksOf`'s `TaskView`. - They record when OAR observed the record, not a time the runtime reported. Only what was seen is set: - A running call has no `endedAt`. - An end whose start was never seen has no `startedAt`. - Nothing is filled in from other times. - `docs/design/chat-ui.md`'s mapping row says so. **Tests** - A new view test: a sleep call with both times, a running call, and an end without a start. - Existing tool-part expectations now include the times. - `pnpm run check` passes. Scope agreed with @cindy. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: exe.dev user <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
xxchan
added a commit
that referenced
this pull request
Oct 3, 2026
Codex `sleep` items arrive as tool calls since #84. `classifyTool` left them as `other`, so hosts showed "Used a tool" while the model was waiting. **What changes** - **New `ToolActionKind` `"wait"`.** Codex `sleep` maps to it. - **New `ToolAction.durationMs`.** For a wait, this is the duration the agent asked for, taken from the input's `durationMs`. It's set only when the value is a finite positive number. - **Actual wait time.** The time actually waited is the tool part's `endedAt - startedAt` (#92), since a steer can end a wait early. With both, a host can show "Waited 8 s of 50 s". - **Labels and summaries.** Labels are "Waiting" / "Waited" / "Wait failed". `toolGroupSummary` says "waited" or "waited N times". **Compatibility.** Hosts that switch exhaustively on `ToolActionKind` get one more case. Otherwise the change is additive. **Tests.** Classification, the duration guard, labels and the summary wording. `pnpm run check` passes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
stamp-build Bot
added a commit
that referenced
this pull request
Oct 28, 2026
<!-- stamp:review:v1 --> <sup><img src="https://cdn.slock.ai/avatars/6aabf32c-20bc-4cba-b55a-2aa72b60999b/8ba4452ceb890f1930886ef4286fdb99.webp" width="16" height="16" align="absmiddle" alt=""> <b>Otter</b> from open-agent-runtime opened this pull request through Stamp</sup><br><sup><a href="https://stamp.build/review?receipt=prc_4b35d4e967946da3ac201c30d8c32200"><picture><source media="(prefers-color-scheme: dark)" srcset="https://stamp.build/assets/brand/stamp-glyph-dark.d907ffcadb44.svg"><img src="https://stamp.build/assets/brand/stamp-glyph-light.58a2c10ed108.svg" width="13" height="12" align="absmiddle" alt=""></picture> View in Stamp →</a></sup> --- <!-- /stamp:review:v1 --> Claude currently refuses host permission modes, while a DSH patch wants a noninteractive restriction. Investigate Claude 2.1.311 through real stream-json processes with an isolated HOME and local provider, and record the mode/prompt-target/resume matrix. No launch policy, public option or default behavior changes. The important distinction is the prompt target: default and acceptEdits emit a host request only with explicit stdio routing; `--permission-prompts none` locally denies the request and preserves already-allowed operations. Plan-mode Bash also consults a model classifier, so its outcome is recorded with controlled classifier answers and the original invalid-response fixture failure. Resume controls show that modes and `none` must be supplied again for these empty-config sessions. Correct the broad chat UI statement about automatic answers: Claude records permission requests without replying. Add a regression through the actual Claude session adapter, plus the rerunnable experiment and runtime documentation. The report offers options for Cindy's decision; it does not implement them. Validation: 36 native Claude 2.1.311 invocations on Linux against a local provider, no account or model quota. Full `CI=1 pnpm run check` (2,208 unit tests and 19 mock cases) and the new adapter-record regression passed. macOS/Windows native permission behavior and real-model classifier decisions were not tested. Task #84. The current base predates #503, whose Codex CI fix will be rebased in after it merges; failures on the old base are retained, not waived. --------- Co-authored-by: Otter <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #83. codex app-server emits
sleepitems when the model waits ({durationMs}, the wait it asked for; a steer can end it early). They now map totool_call_started(toolsleep, input{"durationMs":…}) andtool_call_ended. codex reports no status for a sleep, so the end carries noresult, per the tool-outcome rule; the elapsed time is the two records'receivedAt(nativestartedAtMs/completedAtMsstay in the frames). Test from the reported item; codex runtime page updated.pnpm run checkpasses.🤖 Generated with Claude Code