Skip to content

search: add experimental ahp-search channel - #629

Merged
Connor Peet (connor4312) merged 5 commits into
mainfrom
agents/search-streaming-cancelable-results
Nov 25, 2026
Merged

Connor Peet (connor4312) merged 5 commits into
mainfrom
agents/search-streaming-cancelable-results

Conversation

@connor4312

Copy link
Copy Markdown
Member

Adds an experimental ahp-search:/<id> channel (stability 1.0). A client can search file names, file text, session titles, and chat messages in one query. Results stream into channel state, the client can change the query without opening a new channel, and unsubscribing cancels the search.

How it works

  1. The host advertises InitializeResult.search: { targets }. The client calls createSearch with a URI it chooses and a SearchQuery, then subscribes. The query has text, matchCase, wholeWord, isRegex, maxResults, and a list of targets:
    • fileNames and fileText take roots, includes, excludes, and includeIgnored. The host decides how to match file names.
    • sessions searches session titles, the same sessions listSessions returns.
    • chatMessages searches the chats it lists.
  2. SearchState is { query, results, lifecycle }. Each result is one match: a resource, a match (text plus highlights as [rangeStart, rangeEnd) UTF-16 ranges, like CompletionItem), and an optional score where higher is better. Each result kind adds its own fields:
    • fileText: range, the match location as a TextRange.
    • session: title.
    • chatMessage: title and turnId; resource is the chat URI.
  3. Actions:
    • search/queryChanged (client only) keeps the current results and sets the lifecycle to pending, so the list doesn't flash empty.
    • search/resultsChanged appends results. With replace: true it replaces them and moves pending to running. This follows the replace flag on */configChanged.
    • search/lifecycleChanged sets one of pending, running, completed (with a reason) or failed (with an error). The types follow the terminal channel: SearchLifecycleState and SearchLifecycleStatus.
  4. After a query change, the host must send a replacing resultsChanged before any other search action. If the query is invalid, the host replaces the results with an empty list and sets the lifecycle to failed. A host that watches the searched data may keep changing the results of a completed search.

Start with the spec.

Reviewers should know

  • Every generator and every hand-written client reducer is updated for Go, Rust, Kotlin, Swift and .NET, along with the TypeScript and native state mirrors.
  • Snapshot decoding: Go, Kotlin and .NET detect a snapshot's state type by the fields it contains, and session state is detected by lifecycle. Search state is now checked first, by query plus results, so search snapshots are no longer read as session snapshots. No other state has a query field.
  • @preserveUnknownMembers is only on SearchQuery and its target variants, which clients send back in search/queryChanged. Results, matches and lifecycle states only go from host to client.
  • Lists are plain arrays, not inline { items } wrappers. Inline wrappers become raw JSON in the generated clients.
  • Out of scope: chat results don't yet say which part of a turn matched.
  • The same PR also marks CompletionItem.rangeStart and rangeEnd as integers (minimums 0 and 1) in the JSON Schema. Generated client types don't change.

Validation: npm run generate and npm test pass (676 tests). These client suites also pass, including the shared reducer fixtures 330–336 and round-trip fixtures 110–117:

  • Go: go test
  • Rust: cargo test, fmt and clippy
  • swift test
  • TypeScript client: 81 tests
  • Kotlin (JDK 17 in podman)
  • .NET: 716 tests and dotnet format

No live host or VS Code run was performed.

Adds a channel that searches file names, file text, session titles, and
chat messages and streams scored, highlighted results into SearchState.
Clients start a search with createSearch, change the query with the
client-dispatched search/queryChanged (old results stay visible while
the lifecycle is pending), and cancel by unsubscribing. Hosts append or
replace results with search/resultsChanged and report progress with
search/lifecycleChanged.

Registers the channel in every generator and client reducer, adds shared
reducer and round-trip fixtures, and documents the channel. Also types
CompletionItem.rangeStart/rangeEnd as integers in the JSON Schema.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A host may keep a search after the connection closes so a client can resume it, and any subscriber to the channel URI is treated as continuing the same search.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sessions targets may match any session content, not just titles; drop the note that only clients dispatch search/queryChanged (the host echoes every action) and the unsubscribe-before-subscribe aside.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Resolve generator conflicts with deferred turns (#620), renumber search reducer fixtures to 340-346, bump the stability marker count, and use deferred-turn wording in the chat-message target.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Lets clients signal a quick-find context where precise matching isn't expected; hosts may then match loosely and ignore isRegex and wholeWord.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@connor4312
Connor Peet (connor4312) merged commit c33bd23 into main Nov 25, 2026
8 checks passed
@connor4312
Connor Peet (connor4312) deleted the agents/search-streaming-cancelable-results branch November 25, 2026 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants