Skip to content

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

Merged
SSFSKIM merged 26 commits into
mainfrom
to-human-message-tool
Oct 21, 2026
Merged

SSFSKIM merged 26 commits into
mainfrom
to-human-message-tool

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Oct 21, 2026

Copy link
Copy Markdown
Owner

On claude-opus-5-5 and claude-fable-5-1, text that a model writes before a tool call in the same response comes back as a paraphrased progress-update thinking block, 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 in docs/doperpowers/specs/2026-10-20-to-human-message-tool-report.md.

  • to-human 0.5.0 (M1). to-human/hooks/mods/message.tsx registers message, which the engine exposes as mcp__to-human__message.
    • It is registered in an interactive session under the doperpowers:to-human output style, read from $.config.list(), and not under MAWS. It is always loaded.
    • It refuses a subagent's call (lifting that is to-human: let subagents message the human directly with the message tool #310) and a blank one.
    • The notification fires from the accepted call.
    • The view draws the call as a message row and draws nothing for its result. A refused, errored or interrupted call stays in the working record. sentMark counts the tool's calls.
  • sminos 1.4.0 (M2). host_events emits {"kind": "message", "to": "host", "text", "src": <tool-use id>} for an accepted call of mcp__to-human__message or mcp__maws__message (MESSAGE_TOOLS), through both the Stop export and the bridge's live export.
    • An unanswered call holds the export position.
    • The live export holds what follows a pending call, a whole row at a time, so events keep transcript order. The hold is bounded by PAIRS_KEPT.
    • await_flush waits for a message call at the transcript's tail to get its result.
  • doperpowers 7.201.0 (M3).
    • The style sends a message before the turn ends through the tool, in the same response as the next tool call, and keeps <message> for the turn's end. It declares maws-to-human-contract: 6.
    • Every agents/*.md that withholds the sminos ask now withholds the tool too.
    • Both to-human evals count message by message (shared tests/output-styles/mid_turn.py, offline dry run test-eval-logic.py).
    • A live check: to-human/tests/mods/live-message-check.py.
    • The docs that teach the mark now name the tool.

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):

    PASS  1 the call beside the command, sent, no prompt: response's calls ['mcp__to-human__message', 'Bash']; result 'sent'; prompts none
    PASS  2 drawn as a message row between the tool calls: label at 41, text at 53, working record before 21 and after 94, engine row None
    PASS  3 a plugin_notification with its first line: 1 of 3 notifications carry it
    PASS  4 the log holds it once (live export, then each Stop): during the sleep 1, after turn one 1, after turn two 1; event {'kind': 'message', 'src': 'toolu_01ETeDgLkhPM5CVHhjvMJPms', 'text': 'Checkpoint alpha: the first step ran.'}
    PASS  5 a subagent's call is refused, and goes nowhere: 1 subagent call(s), results ['<tool_use_error>message is for the main conversation; ...']; drawn False, notified False, exported False
    
  • No permission prompt in default or auto mode: an M1 live check (4 haiku calls). The debug log shows tool.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 with display: "updates" and the shipped tool definition. Control is origin/main's 7.200.0 style. 209 turn calls and about 17 judge calls.

    agent-step control agent-step variant fan-out control fan-out variant
    mid-turn messages 5 (4 tool, 1 lost) 8 (8 tool, 0 lost) 8 (8 tool, 0 lost) 8 (8 tool, 0 lost)
    lost share 20% 0% 0% 0%
    final messages that stay spans 28 of 28 27 of 27 none (runs end on a launch) none
    message-tool calls per run 0.10 0.20 0.67 0.67
    cut_off_tool / judge_errors / mid_span_trailing 0/0/0 0/0/0 0/0/0 0/0/0
    • Lost share under 25%: met.
    • Under half the old style's share: met in agent-step, and pooled (0 of 16 against 1 of 13).
    • Final messages that stay spans, at least 90%: met.
    • Read the numbers with care. Both arms list the tool, and the old style uses it unprompted, so most of the effect comes from the tool being present. The loss without a tool is the 2026-10-20 fan-out round's: 12 of 12 announcements came back as progress notes. The samples are small.
  • Acceptance 7, suites at c7d4407:

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

  • Async ask ordering in the live export. An async ask's pair still does not hold the exports that follow it, so a question can land in the project log behind a span written after it in the same turn. This predates the PR. Making asks hold too would be about one line in sminos/hooks/mods/bridge-rows.tsx, beside the message-call hold.
  • Stop flush wait before the row is on disk. await_flush covers 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.
  • Friction tracker row 1 (Friction tracker (moved to ~/.claude/friction-tracker/doperpowers/) #304). The mid-turn loss row's workaround and status should name this tool once it merges: conditional, live where the tool is not loaded (other styles, claude -p, subagents).

Sminos-Session: message-tool#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)
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)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T05:23:21.259116Z e02e354 PR opened
ℹ️ 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" or "@codex security review".

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)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +4028 to +4029
elif (text := _sent_text(b, results)) is not None:
out.append((i, {"kind": "message", "from": alias, "to": "host", "text": text, "src": str(b["id"])}))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment on lines +4003 to +4006
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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)
@SSFSKIM
SSFSKIM merged commit 3e59139 into main Oct 21, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant