Skip to content

feat: add batch session metadata lookup - #1408

Merged
EugeneTheDev merged 8 commits into
mainfrom
issue-233-batch-get
Oct 26, 2026
Merged

EugeneTheDev merged 8 commits into
mainfrom
issue-233-batch-get

Conversation

@slapoguzov

@slapoguzov slapoguzov commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

A session browser may load only the 50 most recent conversations, while pinned sessions and saved folders refer to much older ones. After a restart, the client still has those IDs but needs their current titles, locations and archive state to rebuild the saved views. Finding a handful of retained sessions by paging through the entire history becomes increasingly expensive as that history grows.

Add _session/batch_get to retrieve metadata for known session IDs in one request; the client chooses how many IDs to send per request. Successful results use the same row format as session/list, including archived sessions and sessions in worktrees, so the client can merge them with its recent page and apply its usual display filters.

The response contains the sessions whose metadata is available, in request order. Other IDs are simply omitted. The client can refresh the rows it receives while keeping its saved references, so pinned and folder views stay independent of the recent-list window.

@slapoguzov slapoguzov self-assigned this Oct 23, 2026
@slapoguzov
slapoguzov marked this pull request as draft October 23, 2026 13:36
@slapoguzov slapoguzov changed the title feat: add AIR session batch metadata lookup feat: add batch session metadata lookup Oct 23, 2026
@slapoguzov
slapoguzov marked this pull request as ready for review October 23, 2026 17:56
@slapoguzov
slapoguzov requested a balanced review from Copilot October 23, 2026 17:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Targeted lookups can incorrectly populate the shared negative cwd cache, causing subsequent session lists to omit recoverable sessions.

1 open issue
What changed in this PR

Adds _session/batch_get so clients can refresh metadata for pinned and saved sessions without paging through the full session history.

Changes:

  • Adds capability negotiation, request validation, and routing for batches of up to 100 session IDs.
  • Reuses session-list metadata and row formatting, preserving request order and including archived sessions and worktrees.
  • Documents the API and adds lookup, validation, and failure-handling tests.
File Description
src/​tests/​session-index.test.ts Tests negotiation, routing, lookup behavior, and store failures.
src/​session-index/​session-index.ts Adds targeted transcript lookup and shared candidate collection.
src/​session-index/​service.ts Validates batch requests and formats response rows.
src/​session-index/​project-dirs.ts Exports the shared path-existence helper.
src/​session-index/​connection.ts Advertises and routes the batch extension.
src/​air-extension.ts Defines the sessionBatchGet capability.
src/​acp-agent.ts Exposes the batch lookup agent method.
docs/​air-extensions.md Documents batch semantics and subscription boundaries.

Review effort: Balanced

Comment thread src/session-index/session-index.ts Outdated
Drop the 100-ID limit on `_session/batch_get`: the client is the only
caller and chunking does not reduce total work. Look up IDs 100 at a time
so the project directories × IDs paths in memory stay bounded for any
request size. Copy selection and request order are unchanged.
benbrandt pushed a commit that referenced this pull request Oct 26, 2026
A foreground fork can stream a copied `tool_result` for the Agent call
that launched it. That placeholder completed the call and removed its
tracked state, so the real report arriving later was dropped. Ignore
only results whose tool ID equals the message's parent tool ID, keeping
the launching call open for its actual report.

Keep other results in the same message and discard the message-level
`tool_use_result` sidecar when its launch result was removed, so it
cannot be attributed to a remaining tool result. Regression coverage
exercises plain and Air clients, root and nested launch results, and a
mixed message containing a genuine nested Agent result.

Fixes #1389.

Validation:

- [Linux
CI](https://github.com/agentclientprotocol/claude-agent-acp/actions/runs/40217593917)
passes the full suite: 3,304 passed, 32 skipped (57 test files passed, 4
skipped). All PR checks are green.
- `npm run check` and `npm run build` pass.
- `vitest run src/tests/acp-agent.test.ts --maxWorkers=1`: 712 passed,
10 skipped. The four new regression cases fail on the original code and
pass with the fix.
- Eight actual-SDK runs against localhost fake gateways complete
successfully without model calls: plain and Air foreground forks, native
Air child sessions, nested forks with the background option omitted or
false, the SDK's fork-inside-fork rejection, a background launch
receipt, and history replay. Foreground reports arrive exactly once and
no launch-result tracking warning remains.

The local full-suite run encountered 19 failures in
`session-index.test.ts` and then stopped progressing, so it was
interrupted. A standalone recursive-file-watcher probe also emits
`EMFILE` on this machine. The successful Linux CI run above provides the
complete-suite verification.

Review dependencies (updated 26 October):

| Related proposal | Relationship to this PR |
| --- | --- |
|
[#1408](#1408)
— targeted session lookup | Independent. Both orders merge cleanly onto
the checked main and produce the same tree. |
|
[#1422](#1422)
— resumed subagents | Complementary, with no dependency on this PR. It
now conflicts with upstream main in `src/acp-agent.ts`; its author needs
to resolve that conflict, integrate the [separately shared AIR routing
patch](#1422 (comment))
and complete its validation. |

<details>
<summary>Additional local integration validation — 25 October</summary>

A local combination of the recorded main, #1408, #1431, #1422 and the
already-reviewed routing patch passed 199 focused
foreground/resume/native-subagent checks (647 other cases filtered or
skipped), TypeScript build, and two replays of previously captured SDK
frames for AIR and standard subagents. The two captured-frame replays
were independently repeated. No new model calls were made.

The combination is a private test tree, not a published change. It does
not replace full CI for #1422 or live Air acceptance. The routing patch
needed three-way application against that recorded main because its
surrounding source had moved; it applied cleanly that way. The
current-main conflict in #1422 means this historical result does not
establish today’s combined compatibility.

Checked main `739dde3`, #1408 `e3b3aa4`, #1431 `8f96f46`, #1422
`dd3bf2c`. The two orders of #1408 and #1431 produce tree `1716d7e`; the
full local test tree is `61c0447`. Refresh this evidence if these inputs
change.

</details>

Co-authored-by: Codex <codex@openai.com>

@EugeneTheDev EugeneTheDev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idea is solid, there are some implementation concerns, please check the comments

Comment thread src/session-index/session-index.ts
Comment thread docs/air-extensions.md Outdated
Comment thread src/tests/session-index.test.ts Outdated
Comment thread src/tests/session-index.test.ts Outdated
Aleksandr Slapoguzov and others added 2 commits October 26, 2026 14:59
Also explain the case check of batch lookups on case-insensitive file
systems and describe sessionIds as non-blank, as the parser checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@EugeneTheDev
EugeneTheDev merged commit 0ce42f2 into main Oct 26, 2026
6 checks passed
@EugeneTheDev
EugeneTheDev deleted the issue-233-batch-get branch October 26, 2026 23:44
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.

4 participants