# agent_ui: Fix inline assistant when reasoning precedes tool use \(\#61220\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/c3b365d276151ce8055ef78ecfd68c2745c0d31d)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: c3b365d276151ce8055ef78ecfd68c2745c0d31d

Requested commit: c3b365d276151ce8055ef78ecfd68c2745c0d31d

Commit: c3b365d276151ce8055ef78ecfd68c2745c0d31d

Tree: 941ac20898a83b255ae9bd4adf2d9958cef5875a

Author: Shuhei Kadowaki

Committer: GitHub

## Message

```
agent_ui: Fix inline assistant when reasoning precedes tool use (#61220)

The inline assistant's streaming-tool path waited for the first
`rewrite_section` output, but treated any other completion event as
terminal. Responses API providers can emit `ReasoningDetails`,
`Thinking`, and other metadata before the tool call. This stopped the
stream early and marked generation as done without applying a
replacement.

EOF was not handled explicitly. Parse errors, provider errors,
incomplete tool calls, and truncated responses could also be reported as
successful completions.

Continue consuming informational events until a supported tool call
arrives. Track the rewrite tool call's streaming state, reject a second
`rewrite_section` call instead of concatenating unrelated outputs,
accept `failure_message` only after its input is complete, and reject a
`rewrite_section` arriving after a failure message (and vice versa).

Stop, EOF, malformed tool input, and stream errors now surface as
`CodegenStatus::Error` instead of silently completing. A completed tool
call followed by `Stop(MaxTokens)` or `Stop(Refusal)` is also an error:
the OpenAI Responses mapper flushes truncated tool calls as complete
before emitting the stop reason, so the stop reason must be checked even
when the tool input parsed. Completed failure messages are stored before
`Finished` is emitted, and a failure message left over from a previous
generation is now cleared when a new one starts.

Add regression coverage for metadata around streamed rewrites, Stop and
EOF without a tool call, incomplete rewrites, interrupted responses,
multiple rewrite calls, failure messages, malformed input, mixed tool
calls, and stream errors before and after rewrite output begins.

---

Closes #52714

Release Notes:

- Fixed the inline assistant doing nothing when the model emits
reasoning before its tool call.

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
```

## Parents

- [09adbb01f6ed625a976339f014d6c11690aa6301](https://git.cafe/gitcafe/zed/commit/09adbb01f6ed625a976339f014d6c11690aa6301?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/c3b365d276151ce8055ef78ecfd68c2745c0d31d?format=markdown)
