feat(selection): stream select_path requests and resolve picks mid-turn#77
Open
hazemahmedx0 wants to merge 3 commits into
Open
feat(selection): stream select_path requests and resolve picks mid-turn#77hazemahmedx0 wants to merge 3 commits into
hazemahmedx0 wants to merge 3 commits into
Conversation
This was referenced Jun 21, 2026
e3c0d5d to
833bd9f
Compare
Bridges anton's select_path tool to the GUI without a turn boundary: - SelectionGateway: process-global rendezvous of (conversation_id, request_id) -> asyncio.Future, resolved out-of-band by the new endpoint. - StreamingSelectionElicitor (anton's SelectionElicitor protocol): emits a SelectionRequestEvent into the turn stream, then awaits the gateway future. - harness.stream_response now drives turn_stream in a pump task feeding a merge queue, so the request event reaches the client before the tool blocks; cancels cleanly and unblocks pending selections on turn end. - stream_formatter emits response.selection.requested SSE for the event. - POST /responses/selection delivers the chosen path (or null cancel) into the paused turn; 404 when nothing is awaiting.
GET /fs/list lists a directory's children (folders first; files when kind!=folder; hidden hidden by default; capped; loopback desktop scope). SelectionRequestEvent and the SSE frame now carry mode + root so the UI can render a browser.
…active Drops the in-app /fs directory-listing endpoint now that the client uses the native OS picker, so the server no longer lists the user's filesystem. The streaming path turns the selection elicitor on only for interactive turns, backpressures the merge queue with a bounded async put instead of put_nowait, and re-raises cancellation so a Stop actually tears the turn down rather than being swallowed as an empty pick.
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.
This is the server half of the inline path picker. anton can now ask for a file or folder mid-turn through a
select_pathtool, but it needs a host to carry that request out to the client and feed the answer back into the same paused turn. That's what this does.Before
After
https://www.loom.com/share/5495d1aff1a7488db532fbdbd0f55926
What's in here:
StreamingSelectionElicitorthat implements anton's elicitor protocol. When the agent asks for a path, it emits a selection event onto the live SSE stream and then waits on a future for the answer.SelectionGatewaythat holds the open requests as asyncio futures, keyed by conversation and request id, so the pick that arrives on a separate HTTP call can resolve the exact turn that's waiting./responses/selectionendpoint the client posts the chosen path to. It resolves the future, the tool returns, and the turn continues. A 404 means nothing was waiting.put_nowait, so a slow client applies backpressure instead of dropping events.Two correctness fixes worth calling out:
One removal: the in-app
/fsdirectory-listing endpoint is gone. The client now uses the native OS picker, so the server no longer needs to list the user's filesystem over HTTP. Less surface area, and the agent already has its own file access.Depends on the anton
select_pathchange. The client PR for cowork sits on top of this one.Part of the inline path picker stack. Merge bottom up:
Related but independent: mindshub_inference #302 (https://github.com/mindsdb/mindshub_inference/pull/302) is the image side of the same multimodal and file effort. It translates image_url blocks for every provider and transcodes unsupported image types to PNG. It does not depend on this stack and this stack does not depend on it.