Skip to content

Slash menu, skill list and skill open: one host round trip each - #8123

Merged
ymichael merged 1 commit into
mainfrom
bb/slash-menu-skills-one-host-round-trip-thr_v7zgfxv8tf
Nov 24, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/slash-menu-skills-one-host-round-trip-thr_v7zgfxv8tf

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Opening the slash-command menu, listing skills, and opening one skill each cost several serial host round trips. Before every native-root scan the server made a separate plugin.host.call resolveNativeRoots, cached for 10 s, and only then sent host.list_commands / host.list_skills. The skills index also sent one host.list_skills per visible provider plus one for shared roots. Opening a skill rebuilt that whole index twice, once for content and once for files, just to map a skill id to a path. On a Connect-tunnelled host each serial wave costs ~200 ms (audit findings #2 and #3, thr_ejgucea7p3/report.md). Finding #4, frontmatter-only project skill reads, is handled in a separate thread.

What changed

  • Daemon wire change, HOST_DAEMON_PROTOCOL_VERSION 281 → 282.
    • host.list_commands now takes { cwd, provider: { providerId, declaredRoots, resolver }, resolution: { contributedEnv, timeoutMs } }.
    • host.list_skills takes { cwd, providers: [...], sharedRoots, resolution } and returns { workspaceSkills, sharedSkills, providers: [{ providerId, skills }] }.
    • resolver is { pluginId, generation, artifact } or null. The daemon calls the plugin's resolveNativeRoots in-process through its PluginHostManager, inside the same request as the scan. It cancels that call if the listing is cancelled. A failed, malformed, or unavailable answer falls back to the declared roots with a warning, as the server did before.
  • Server policy stays on the server (services/providers/native-roots.ts): which providers are scanned, which plugin resolves, the host env, and a 10 s resolver cap that leaves the scan time inside the first retry attempt. The server-side resolved-roots cache (ProviderNativeRootsCache) is deleted because resolving is no longer a separate round trip.
  • Skills index (services/skills/skill-listing.ts):
    • One batched host.list_skills replaces the per-provider calls and the separate shared-roots call.
    • .bb/skills is scanned once instead of once per provider. It is now also listed when no provider has native roots.
    • Server-owned skills load in parallel with the host call.
    • A per-(host, cwd) index memo (@bb/async-cache, 5 min) is refreshed by every listing. Content and file reads resolve the id from it and rebuild once only for an id the last listing didn't have. Writes and deletes always rebuild first. Plugin settings changes clear it.
  • Docs: docs/api_to_audit.md and the experimental_nativeRootsHostContract JSDoc now say the daemon resolves per listing, uncached. Plugin SDK bumped to 0.6.197 for the JSDoc change.

How you verified

Measured on two real servers, main at merge base af25b0b5a60 vs this branch, each with a fresh data dir (no ~/.bb). Each server had a second enrolled daemon behind a TCP latency proxy adding 100 ms each way (~200 ms RTT). The proxy strips permessage-deflate from the daemon's upgrade, reads server→daemon frames, and counts host-rpc.requests. Input was the same bb checkout (9 .bb/skills, real ~/.claude etc.) and provider=claude-code, with 8 samples per action after warm-up.

Remote host (~200 ms RTT): median wall time / host RPCs per action

action main branch
slash menu, cold (>10 s since last) 437 ms / 3 (resolver → list_commands, ‖ read_workspace_agent_context) 233 ms / 2
slash menu, warm 222 ms / 2 233 ms / 2
skills list, cold (>10 s since last) ~527 ms / 13 (6 resolvers → 7 list_skills) ~310 ms / 1
skills list, warm (resolver cache hit on main) 364 ms / 7 404 ms / 1 (steady-state resample: ~300–320 ms on both)
open one skill (content + files in parallel) 584 ms / 16–22 (two index rebuilds + read + list) 219 ms / 2 (read_file ‖ list_files)

Local host (primary daemon, no proxy), median:

action main branch
slash menu, cold / warm 22 / 19 ms 21 / 19 ms
skills list 119 ms 115 ms
open one skill 167 ms 17 ms

The warm slash menu still makes 2 RPCs in one parallel wave: host.list_commands and host.read_workspace_agent_context. Folding the second one in overlaps finding #4's change to that command, so it is left for that thread. Every action is now a single wave. The remaining ~100 ms over RTT on the skills list is server-side index work (listServerSkills hashing), not host traffic.

Tests:

  • apps/server/test/public/public-project-skills.test.ts adds "opens a listed skill with one host read…". It asserts that a listing is one host.list_skills, that content + files after it are exactly host.read_file + host.list_files, and that an unknown id re-lists once. It fails on main, where every open re-lists.
  • apps/host-daemon/src/command-handlers/list-skills.test.ts covers the batched handler with a fake plugin host: the .bb/skills root is listed once, shared roots and resolved roots are scanned, a throwing / malformed / missing runtime falls back to declared roots with a warning, and cancelling the listing cancels the resolver call.
  • native-roots.test.ts, the commands, workspace-routing and contract tests are updated to the new wire shape.
  • pnpm exec turbo run typecheck lint --filter=@bb/server --filter=@bb/host-daemon --filter=@bb/host-daemon-contract --filter=@get-bb/plugin-sdk --filter=@bb/integration-tests passes. So do the targeted vitest runs above, plus tests/integration native-roots-golden. CI runs the full suites.

AGENT GENERATED

🤖 Generated with Claude Code

@ymichael
ymichael merged commit c6816e9 into main Nov 24, 2026
96 of 97 checks passed
@ymichael
ymichael deleted the bb/slash-menu-skills-one-host-round-trip-thr_v7zgfxv8tf branch November 24, 2026 22:20
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.

1 participant