fix: Claude Stop-hook continuations no longer hide the answer #27747
main fromrefs/pull/27747/head·merged by maria-rcks View on GitHubProblem#
With the Claude provider, a user's Stop hook can block the end of a turn. Claude then replies to the hook in the same run, so the run ends with two assistant messages: the real answer, then a short reply to the hook. After the run settles, the timeline keeps only the last message visible and folds the real answer under "Worked for". To the user, the answer looks like it disappeared.
Repro: add any Stop hook that blocks once (for example a script that returns {"decision":"block","reason":"..."}), ask Claude a question, and wait for the run to finish.
Fixes pingdotgg/t3code#5297
Change#
Server only, in ClaudeAdapterV2. When a root Stop hook feedback: frame arrives that is not the active /goal check, the adapter does two things:
- It republishes the reply Claude had just finished with the existing
final_answerphase. Web and mobile already keep afinal_answerreply out of the "Worked for" fold and visible in Zen mode. This is the same thing the adapter does for a reply that a steer continues past. - It emits a completed
notificationitem, "Stop hook asked Claude to continue", with the hook's reason as its detail. Notifications already stay visible on both clients.
/goal checks are unchanged. Turns without a Stop hook are unchanged.



Smaller than the original#
Maintainer takeover, now at d70ddb4. The PR went from 13 files, +664 −8 to 2 files, +146 −11. Removed:
- The web and mobile fold and Zen changes, and the shared constant in
packages/contracts. Thefinal_answerphase already does that job on both clients. - The
additionalContext-only path. It neededincludeHookEventson every Claude query, which streams a frame for every hook of every kind. That in turn needed the native log filter for hook output and a fix to the unanswered-request watch, and it left a known misplaced notice on background wakes. - The recorded replay fixture, which recorded hook event frames the adapter no longer asks for.
A Stop hook that returns only additionalContext still hides the answer. That case is a follow-up.
Verification#
- Real web app (run locally): isolated dev server with empty state, real Claude Haiku 5.5, a project whose Stop command hook blocks once with
{"decision":"block","reason":"Run the formatter before finishing."}. The same prompt ran withmain's adapter and with this branch's. The shots above are from those runs, after each run settled. - Stored items for the run on this branch (read from the dev database): the answer has phase
final_answer, then one notification with the hook's reason, then the reply. - Adapter test (remote runner): the new case in
ClaudeAdapterV2.test.tsfails withmain's adapter and passes with this one, with and without an active/goal. It runs three Stop hooks in one run, two of them with no frameuuid, and expects three answers kept and three separate notices. The/goaltest now also asserts that a goal check adds no notice and marks no reply final. The whole file passes, 521 tests. - Mobile (remote runner, not committed): the mobile feed's fold and Zen derivations keep a
final_answerreply and the notification visible for one run with two Stop hooks. This ran againstmain's unchanged mobile code. vp run check:changed(remote runner): format, lint, knip, typecheck and tests pass.
Not verified: native iOS and Android, Electron, several Stop hooks in one live run (covered by the adapter test only), and a Stop hook firing while a steer is pending.
Council review#
Rounds: 3
| Delegate | Round 1 | Round 2 | Round 3 |
|---|---|---|---|
| GPT Sol | 8/10 | 9/10 | 9/10 |
| GPT Sol (second seat) | 9/10 | 9/10 | 9/10 |
| Gemini Neon | no score | no score | no score |
Gemini Neon is out of quota, so a second independent GPT Sol reviewer has its seat. Both found the same issue: two Stop hook frames with no uuid shared one notice id. Fixed in 144b944. Round 2 reviewed ccaaa3f and found nothing. Round 3 reviewed the current head d70ddb4, which only adds a merge of main, and found nothing. The rounds on the larger version of this PR no longer apply.
Original implementation by @AppLoidx with gpt-6.1-sol (Codex CLI) and Claude Opus 5.5 (Claude Code), with the hook-event work from @ElliotDrel. Maintainer takeover by claude-fable-5-2 (Claude Code) on behalf of Maria.