feat(serve): stream tool input and output in tool events - #488
Merged
Conversation
The tool events on the SSE and WebSocket streams carried only a tool name (and an error flag), dropping both the arguments and the output. A client could show that "FileEdit ran" but not which file, nor the diff — so any GUI or API consumer had to render a bare name with no detail. - tool_start now carries `input` (the tool's arguments), so clients can show a detail line: the bash command, the edited path, the search pattern. - tool_result now carries `content` (the tool's output), so clients can render it — notably the unified diff that the edit tools already return. - Output is capped at 64 KiB with a truncation marker. Events are broadcast and cloned per subscriber, so an unbounded result (a large FileRead, a chatty command) would otherwise be copied wholesale into the channel. Both fields are additive, so existing consumers are unaffected. Tests cover the serialized shape and the truncation, including multi-byte boundaries.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The tool events on the
serveSSE and WebSocket streams carried only a tool name (plus an error flag), dropping both the arguments and the output. A client could show that "FileEdit ran" — but not which file, and not the diff. Any GUI or API consumer was stuck rendering a bare tool name with no detail.What changed
tool_startnow carriesinput(the tool's arguments), so clients can render a detail line: the bash command, the edited file path, the search pattern, the fetched URL.tool_resultnow carriescontent(the tool's output), so clients can render it — notably the unified diff the edit tools already return, which enables inline diff review in a GUI (the counterpart of what the terminal client renders today).FileRead, a chatty shell command — would otherwise be copied wholesale into the channel.Both fields are additive, so existing consumers are unaffected (they simply ignore the new keys).
Verification
tool_start.input,tool_result.content, diff content surviving serialization) and truncation — including the multi-byte-char boundary case, which would otherwise panic on a naive slice.cargo test(12 pass in this module),cargo clippy --all-targets -- -D warnings,cargo fmt --all -- --checkall clean.Why now
This unblocks rich tool cards + inline diffs in the Flutter client — without it the client has nothing to render. Shipping it separately keeps the protocol change reviewable on its own.