A user message that carried ordinary text beside a live tool_result, before
or after the result block, was refused with 400 "text beside a live
tool_result; send it after the tool response completes" (maxleebeta's
DeepSeek-harness agent, #909; Claude Science does the same). inspectToolTurn
now marks such a turn userSteered, so the bridge takes the existing replay
path: the old session is stopped, its pending calls are not resolved, and a
new session/prompt carries the round, the real tool result included. The
user's text is never spliced into an MCP function response. The same goes
for plain text after a Skill result, and for a hook line that carries "The
user sent a new message while you were working".
Still refused: an unclosed protocol notice (<system-update>... with no end
tag) on either side of the result, a companion (ARGUMENTS:, [Image: ...],
Tool loaded.) with no matching preceding tool, and an image before the first
tool_result. A turn whose tools also grew (#942) takes the same single
replay.
Changed behaviour beyond #909: a protocol notice, token line or hook-success
line placed before the tool_result (previously 400) now replays in a new
session, where the same line after the result is forwarded in-session.
Tests: compat.mjs checks both placements are userSteered, the MCP result
is unchanged, and the replay carries the instruction and the result. smoke.mjs
drives both placements and the Skill case through the fake agy and checks a
new convId whose prompt carries both. Five smoke checks that asserted 400
for text the bridge now replays were removed; the unclosed-notice 400 check
stays.
Run at head 04692ce0a74d (merged onto origin/main d5f4214e) on mote, bun 1.4.2:
- bun test packages/agy-cli: 8 pass, 0 fail, at the head and merged
- bun scripts/check.mjs agy-cli: ok, at the head and merged
- Broken by hand (index.mjs reverted, tests kept): compat 1 fail (the new
test); smoke 3 FAILURES of 321 (before, after, Skill: status 400)
- Probe of inspectToolTurn merged: the user text appears once in the replay
and the result once; MCP content stays "file contents"
Not run: the root bun test suite (mote's suite queue was long); the
reporter's own request bytes (never obtained, #909 stays open for them).
Co-authored-by: Guuuu233 <308638291+Guuuu233@users.noreply.github.com>