Repository navigation
The to-human message tool: mid-turn messages arrive word for word (to-human 0.5.0, sminos 1.4.0, 7.201.0) - #312
Conversation
Sminos-Session: doperpowers-88#df0b714b (doperpowers on macbook)
Sminos-Session: doperpowers-88#df0b714b (doperpowers on macbook)
Sminos-Session: doperpowers-88#df0b714b (doperpowers on macbook)
Sminos-Session: doperpowers-88#df0b714b (doperpowers on macbook)
A message written as text before a tool call comes back from claude-opus-5-5 and claude-fable-5-1 as a progress note's paraphrase without its tags, so it reaches no one. The to-human plugin now registers mcp__to-human__message in every interactive session but a MAWS launch, always loaded: a call returns `sent` and raises the person's notification with the message's preview line (shared with a span's), a subagent's call is refused, and one with no text too. The view draws an accepted call as a message row, as a span draws, its result as nothing, the text so far while the input streams; a refused, errored or interrupted call stays working record. A conversation holding only tool messages turns the view on at module start. Live, the call runs without a permission prompt in default and auto modes (Claude Code 2.1.305), so no tool.check allow is added. M1 of docs/doperpowers/specs/2026-10-20-to-human-message-tool-design.md. Sminos-Session: doperpowers-88#df0b714b (doperpowers on macbook)
Sminos-Session: doperpowers-88#df0b714b (doperpowers on macbook)
A message a session sends through the to-human plugin's message tool, or MAWS's own in a MAWS launch, reaches the project's log as the event a span gives: kind message, to host, the call's text word for word, src the tool-use id, at the call's place among the spans. sminos knows both names (MESSAGE_TOOLS, in sminos.py and bridge-rows.tsx), since it depends on neither plugin. Only an accepted call counts: host_events pairs the call with its result and drops a refused, failed or interrupted one, and export_host holds the export position before a call whose result is not on disk yet, as it does for an ask. The bridge forwards the call and its result rows as one export, in either order, as it does an async ask's; a message past TEXT_CAP is left to the Stop hook. A turn can end on the tool's result with no answer after it, so the Stop's flush wait also waits, under its existing bound, for the result of a message call at the transcript's tail. M2 of docs/doperpowers/specs/2026-10-20-to-human-message-tool-design.md. Sminos-Session: doperpowers-88#df0b714b (doperpowers on macbook)
…ithheld (#310) Sminos-Session: doperpowers-88#df0b714b (doperpowers on macbook)
The bridge exported a marked text row as soon as it was kept, but a message call only once its result came, so a call followed by a span in the same response reached the log as the span, then the call; the Stop hook reads the call first, and dedup cannot reorder what is appended. Now an ordinary message call kept before its result holds its place in the exports (state.exportHold): what the main loop keeps after it waits, and is released in order once the call's pair is whole, a refused one included (the child logs nothing for it). A row holding a message call goes whole with the call's pair, its texts with it, so a span and a call in one record keep their order and their src. The over-cap message keeps its exception and holds nothing; a call whose result the bridge never sees holds at most PAIRS_KEPT exports. The flush wait's test no longer leans on a sleep: a helper-level test drives await_flush step by step, seeing it hold on the open call before the result is written, under both names. Review fix for M2 of docs/doperpowers/specs/2026-10-20-to-human-message-tool-design.md. Sminos-Session: message-tool#df0b714b (doperpowers on macbook)
…the style Sminos-Session: message-tool#df0b714b (doperpowers on macbook)
…tyle only The rule for when to use the tool now lives in the style alone, so the description reads `Send the human a message.` and the field `The message, in Markdown.` (the human's ruling). With no rule in the description, the tool is registered only when /config's outputStyle row reads doperpowers:to-human at session start ($.config.list(), confirmed live on 2.1.305 and 2.1.306: registered under the style, not under default); an unreadable style registers nothing and says why in the debug log. The subagent refusal points at #310. The headless and MAWS registration tests are split, so each pins its own condition. Sminos-Session: message-tool#df0b714b (doperpowers on macbook)
…ults Each call in a row holding several message calls carried the whole row with its own result alone, so settling the first exported the row's spans ahead of a call that had no answer yet, and the second call landed after them: [A, B, span C] reached the log as A, C, B. The hold now keeps the row itself (HeldRow: the row, the calls still without a result, the results so far), and exports it once, with every result, when its last call settles; in either result order, the row's blocks reach the child together and the reader emits them in order. A row given up at the bound goes with the results it has. Review fix for M2 of docs/doperpowers/specs/2026-10-20-to-human-message-tool-design.md. Sminos-Session: message-tool#df0b714b (doperpowers on macbook)
… hold Sminos-Session: message-tool#df0b714b (doperpowers on macbook)
Sminos-Session: message-tool#df0b714b (doperpowers on macbook)
…ssage tool The to-human style names both forms: a <message> span at a turn's end, and mcp__to-human__message for a message sent before the turn ends, in the same response as the next tool call, since written as text there it comes back as a paraphrase that never reaches the human. Where the tool is not among the session's tools a span is the only form. Contract 6 (the message-tool shape). The agents that withhold compact and the ask tool withhold the message tool too: a subagent's call is refused, so its definition is cost alone (#310). Sminos-Session: message-tool#df0b714b (doperpowers on macbook)
… tool Both evals offer mcp__to-human__message from the first request, read from to-human/hooks/mods/message.tsx so they offer what ships (result `sent`), set display "updates" in every arm, and keep each response's blocks in order. A mid-turn message is a span or a tool call (delivered) or a progress note the judge (doperpowers-f7's criterion, word for word) rules addressed to the human (lost); a final message is a span or a tool call ending the turn. The shared definitions are mid_turn.py. The agent-step eval gains keep_working (a dialog the owner must approve at a set time, then the session keeps working), each scenario runs on its own history by default, and Bash answers as a working shell (git log and status, gh pr, file reads), since "(no output)" for every call read as a broken shell and drew a Critical block about it. test-eval-logic.py drives both run()s through a fake client. Sminos-Session: message-tool#df0b714b (doperpowers on macbook)
The sminos skill and the spawn preamble, README's to-human style, the mods README, and CLAUDE.md's to-human, output-styles and sminos rows: a message at a turn's end is a <message> span, one before a tool call goes through mcp__to-human__message, which registers only under the doperpowers:to-human style; sminos exports its accepted calls as message events keyed by the tool-use id. Sminos-Session: message-tool#df0b714b (doperpowers on macbook)
A live session under the doperpowers:to-human style, with the worktree's to-human and sminos plugins and its style in an isolated config and sminos project: the call beside the command's in one response, `sent`, no prompt; the report's message row between working-record runs; the plugin_notification; the log's one message event keyed by the tool-use id, during the live export and after each Stop; a subagent's call refused and sent nowhere. Run by hand: it spends model calls. Sminos-Session: message-tool#df0b714b (doperpowers on macbook)
…s the view does The review of phase A: - the fan-out eval runs up to two responses past its end while the last calls only the message tool (SETTLE), so a tool message that ends the turn counts as final; a run still cut off on one counts it as cut_off_tool, neither kind - keep_working names its window in UTC and the shell's clock reads 14:05 UTC for it, its commits before that, the same in both arms - spans are read with sminos_marks.parse, the view's grammar, so a mark in inline code or a fence is literal; a span after a response's last call stays mid-turn and delivered, and is also counted apart (mid_span_trailing) - README documents the qualified style key, doperpowers:to-human Sminos-Session: message-tool#df0b714b (doperpowers on macbook)
Sminos-Session: message-tool#df0b714b (doperpowers on macbook)
claude-opus-5-5 high, judge low, 4 reps, 7.200.0 against 7.201.0, both arms with the message tool. Agent-step: mid-turn messages lost 1 of 5 (control) and 0 of 8 (variant), final messages spans 28 of 28 and 27 of 27, tool calls per run 0.10 and 0.20. Fan-out: every announcement 8 of 8 through the tool in both arms, none lost, 0.67 tool calls per run. No cut-off calls, no judge errors, no trailing spans. Sminos-Session: message-tool#df0b714b (doperpowers on macbook)
The bound on a message call whose result the bridge never sees ran only when another kind of export queued behind it, and a completed call leaves state.pairs, so that map's limit never fired either: a missed result followed by message calls alone held every later row (100 accepted calls: no export, 101 rows held). The bound is now boundHold, run after either kind of push: past PAIRS_KEPT held entries, the waiting row at the head is given up with the results it has, and the queue flows in order; the Stop hook's export still writes the missed call. Review fix for M2 of docs/doperpowers/specs/2026-10-20-to-human-message-tool-design.md. Sminos-Session: message-tool#df0b714b (doperpowers on macbook)
…tten Sminos-Session: message-tool#df0b714b (doperpowers on macbook)
Sminos-Session: message-tool#df0b714b (doperpowers on macbook)
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Sminos-Session: message-tool#df0b714b (doperpowers on macbook)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e02e354772
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| * tool's messages stay in the report; other messaging (an agent's | ||
| * `SendMessage`) is working record. | ||
| */ | ||
| export const isRead = (tool: string) => tool === 'AskUserQuestion' || ASK_TOOLS.includes(tool) || isSpawn(tool) || tool === MESSAGE_TOOL |
There was a problem hiding this comment.
Handle MAWS messages in the terminal report
In a MAWS terminal session, registerMessage deliberately leaves only mcp__maws__message available, while native() leaves terminal rendering to this view; however, this predicate and the message-specific rendering paths recognize only mcp__to-human__message. Once report folding is active, a MAWS message call is therefore classified as working record and hidden behind the fold, and a resumed conversation containing only such calls is not recognized by sentMark either. Treat both message-tool names as report messages so the human does not miss a potentially action-required message.
Useful? React with 👍 / 👎.
| elif (text := _sent_text(b, results)) is not None: | ||
| out.append((i, {"kind": "message", "from": alias, "to": "host", "text": text, "src": str(b["id"])})) |
There was a problem hiding this comment.
Preserve block order between questions and messages
When one assistant record contains an accepted async-ask call before an accepted message-tool call, this loop appends the message event first, while _ask_events appends the question only afterward; the final stable sort uses only the record index, so it cannot recover their within-record order. The exported project log and desk consequently show the later message before the earlier question. Build both event types with their block positions, or otherwise include a within-record ordering key.
Useful? React with 👍 / 👎.
| inp, res = block.get("input"), results.get(str(block["id"])) | ||
| text = inp.get("text") if isinstance(inp, dict) else None | ||
| if not isinstance(text, str) or not text.strip() or res is None or res.get("is_error") is True: | ||
| return None |
There was a problem hiding this comment.
Exclude interrupted calls from exported messages
When a message-tool call is interrupted before its handler runs, interruption can be represented by the call/record metadata rather than is_error: true on the tool_result block—the new view code explicitly handles isInterrupted because the result row cannot report the cut. This acceptance check ignores that metadata and treats any present non-error result as proof that the message was sent, so the bridge or Stop exporter can append an aborted message to the project log and desk. Carry the interruption state into the result lookup and reject such calls.
Useful? React with 👍 / 👎.
…ing) Sminos-Session: message-tool#df0b714b (doperpowers on macbook)
On
claude-opus-5-5andclaude-fable-5-1, text that a model writes before a tool call in the same response comes back as a paraphrased progress-updatethinkingblock, not as text. A<message>sent mid-turn therefore reached none of its consumers: the report view, the notification, the sminos export, the desk, or MAWS. This PR adds a plugin tool,mcp__to-human__message. Tool input is never summarized, so a mid-turn message arrives word for word. Messages at the end of a turn stay<message>spans. Spec:docs/doperpowers/specs/2026-10-20-to-human-message-tool-design.md. The full account is indocs/doperpowers/specs/2026-10-20-to-human-message-tool-report.md.to-human/hooks/mods/message.tsxregistersmessage, which the engine exposes asmcp__to-human__message.doperpowers:to-humanoutput style, read from$.config.list(), and not under MAWS. It is always loaded.sentMarkcounts the tool's calls.host_eventsemits{"kind": "message", "to": "host", "text", "src": <tool-use id>}for an accepted call ofmcp__to-human__messageormcp__maws__message(MESSAGE_TOOLS), through both the Stop export and the bridge's live export.PAIRS_KEPT.await_flushwaits for a message call at the transcript's tail to get its result.<message>for the turn's end. It declaresmaws-to-human-contract: 6.agents/*.mdthat withholds the sminos ask now withholds the tool too.tests/output-styles/mid_turn.py, offline dry runtest-eval-logic.py).to-human/tests/mods/live-message-check.py.The cross-repo contract table did not move. MAWS's side (82a0967ff) and the desk's (MAWS #94) have already landed against it.
Validation Evidence
Acceptance 1–5, live (
to-human/tests/mods/live-message-check.py, Claude Code 2.1.306, haiku, isolated config, 17 model calls):No permission prompt in
defaultorautomode: an M1 live check (4 haiku calls). The debug log showstool.call … resolved by a hooks module, with no permission line.Acceptance 6, evals. claude-opus-5-5 at high effort, judge at low effort,
--reps 4, both arms withdisplay: "updates"and the shipped tool definition. Control is origin/main's 7.200.0 style. 209 turn calls and about 17 judge calls.Acceptance 7, suites at c7d4407:
to-human/tests/mods/run.sh: 96 pass, 0 fail.sminos/tests/mods/run.sh: 406 pass, 0 fail.sminos/tests/test-bridge-export.sh: all 44 assertions passed.tests/mods/typecheck.sh: exit 0.tests/output-styles/test-eval-logic.py: all passed.sminos/tests/run-sminos-tests.sh: 2147/2147 at the last change tosminos.py(M2's fix).ci-gate c7d44078: GREEN, 11 of 11 gates (https://github.com/SSFSKIM/doperpowers/actions/runs/39547259577). The head adds only the execution report.Unresolved Review Findings
None. Every task review and the whole-branch review (reviewer-high) ended clean. Two Minors were dismissed: npm notices in the reported typecheck output, which are validation hygiene and come from the repository's own script.
Residue
sminos/hooks/mods/bridge-rows.tsx, beside the message-call hold.await_flushcovers a message call whose row has been written. A call and its result both still in the engine's ~100 ms write queue when the Stop hook reads go out at the next Stop, or through the bridge. An unconditional wait would cost up to 2 s on every Stop after an Esc.claude -p, subagents).Sminos-Session: message-tool#df0b714b (doperpowers on macbook)