Repository navigation
fix: put the confirmation token in the preview text - #249
Conversation
A write preview said "call again with `confirm` set to the token in `confirm_token`" but only carried the token in structuredContent. A client that forwards just the text block to the model — Claude's remote MCP path (bardesss#234), Hermes since 2026.9.7 which drops structuredContent whenever the text is non-empty — shows the model an instruction naming a field it cannot see. The model either stops (audit: unconfirmed) or invents a token (audit: confirmation malformed), and the write never lands. Both preview branches now state the token itself in the text, alongside the unchanged confirm_token field. Same shape as the bardesss#234 fix for the list tools. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Thanks, good catch and the diagnosis is right. Same split #235 fixed for the list tools, and the write previews had it too. Ran the three gates on the branch here, all clean, 2678 passing. Checked the rest of the tree while I was in there: every write tool goes through One thing I'd like folded in before this goes. The token is prose now, wrapped in backticks with a period right after it, but Only the exact string applies. And the malformed response hands the fresh token back in the identical shape, backticks and a trailing period, so a client that consistently clips one character past the token never converges. That's the nine previews all settling Smaller, same area: the rejection text interpolates Two nits, take or leave:
Happy to take the extraction tolerance as a follow-up if you'd rather keep this diff tight, but I'd want it in the same release. Update, a bit later the same day. Ignore the ask above about the trim, I did it myself in #250, now merged. Don't spend time on it. Splitting it out rather than leaving it with you: it lives in confirm.ts, which your diff never opens, and sending you off to fix a file outside your own change was a daft thing for me to ask. It strips whitespace, wrapping backticks or quotes, and trailing punctuation before the token is parsed. The HMAC still decides everything it decided before, and the stripped form is what the single-use set records, so punctuation is not a replay route. This branch is BEHIND now. No conflicts though, your three files and my three don't overlap at all, so an update from main is all it wants. I merged the two locally first to check they actually compose. Lint and typecheck clean, 2681 passing. Then I took the preview text your change produces and clipped the token out of it five ways: apply() fired once in each case, so that is the handshake completing from the text alone, which is what your PR set out to do. Good catch, and the writeup made it easy to follow. Still on your side, all optional:
None of it blocks. Update from main and I'll take another look. |
|
Edited my review above with an update: the trim landed in #250, so skip that part. Branch just needs an update from main. |
A write preview said "call again with `confirm` set to the token in `confirm_token`" but only carried the token in structuredContent. A client that forwards just the text block to the model — Claude's remote MCP path (#234), Hermes since 2026.9.7 which drops structuredContent whenever the text is non-empty — shows the model an instruction naming a field it cannot see. The model either stops (audit: unconfirmed) or invents a token (audit: confirmation malformed), and the write never lands. Both preview branches now state the token itself in the text, alongside the unchanged confirm_token field. Same shape as the #234 fix for the list tools. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Problem
A write preview's text says:
but the token itself is only in
structuredContent. A client that forwards just thecontentblock to the model never shows it the token, so the handshake cannot complete. Two such clients today:structuredContentto the model. That fix covered the list tools; write previews have the same split.cee12cc3, a port of kimi-code#3234) dropsstructuredContentwhenever the text block rendered anything usable. Releases up to v2026.8.31 combined both blocks, which is why the same setup works on an August Hermes and fails on a September one.Observed on 1.26.3 against a live Seerr 3.4.1 from Hermes 2026.9.11: nine
request_mediapreviews for the same film, all settledunconfirmed, oneconfirmation malformedwhere the model guessed a token, and no request ever reached Seerr. Calling the tool directly over HTTP confirmed the token is absent fromcontent[0].textand present instructuredContent.confirm_token.Fix
Both preview branches in
src/tools/write.tsnow state the token in the text, next to the unchangedconfirm_tokenfield:and on a rejected token:
No response field changes, so this is a
fix:.docs/writes.mdexample updated to match.Tests
test/writeTool.test.ts: two new cases asserting the text containsstructuredContent.confirm_token, for the plain preview and for the rejected-token preview.The three gates
What was exercised
confirm_token.🤖 Generated with Claude Code