Skip to content

Load project skills in one host round trip for / and thread start - #5172

Closed
brsbl wants to merge 7 commits into
bb/command-catalog-focus-prefetchfrom
bb/project-skills-single-rpc
Closed

brsbl wants to merge 7 commits into
bb/command-catalog-focus-prefetchfrom
bb/project-skills-single-rpc

Conversation

@brsbl

@brsbl brsbl commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Loading project skills took two serial host round trips: list .bb/skills, then read each SKILL.md. That made it the slowest branch of the /commands route, and thread start paid the same cost.

What changed

  • Project skills now load in one host round trip, through the new daemon command host.read_skill_files.
  • This applies to thread start too, which reads project skills the same way.
  • The win is one round trip (about 100–200ms on a remote server), only for projects with .bb/skills.
  • Wire change: HOST_DAEMON_PROTOCOL_VERSION goes from 230 to 231.
  • The command only reads top-level <dir>/SKILL.md files inside the workspace.
  • It rejects a .bb or .bb/skills folder that symlinks outside the workspace.
  • It skips hidden folders, symlinked folders, and symlinked files.
  • Responses are capped at 32 MiB of encoded JSON in total, and 10 MiB per file.
  • Skills past either cap are skipped, with a server log warning only.
  • Server-side frontmatter validation is unchanged.
  • It skips the server's excluded folder names, such as venv, and requires an exact-case SKILL.md, as before.

How you verified

  • New daemon tests cover:

    • symlinks, hidden folders, and nested files
    • excluded folder names and a lowercase skill.md
    • the per-file and total size caps
    • the skill-count limit
    • a missing root, a symlinked root, and a root that escapes the workspace
  • Branch dev app at 59489178dc (10-skill fixture), one /commands call:

    Base 86ac764436 This PR
    Host RPCs 13 2
    Serial round trips for skills 2 1
  • Same run: all 10 skills appeared in the / menu.

  • Same run: a claude-code thread listed all 10 skills.

  • Same run: a mismatched name, venv/, and a lowercase skill.md were all skipped.

  • New daemon test: the budget counts encoded size, so control-character content can't exceed it.

  • Remote CI passed on head 9d68b83622.

Part of #5192 (row 5: daemon round trips)

BB-Thread: Investigate slow command lookup

🤖 Generated with Claude Code

AGENT GENERATED

The / command list and thread start listed .bb/skills and then read each
SKILL.md with a separate host RPC. Add host.read_skill_files, which returns
every top-level SKILL.md in one call, and keep validation on the server.
Bump the host daemon protocol to 231.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@brsbl
brsbl added this pull request to stack #5173 October 8, 2026 02:36
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-08T02:40:04.548664Z 1074291 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

host.read_file enforced rootPath containment for each SKILL.md. Require
rootPath on host.read_skill_files and reject a skills root whose real path
escapes it, such as a .bb directory symlinked outside the workspace.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1074291f78

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

return {
directoryName: args.directoryName,
sizeBytes: stat.size,
content: await fs.readFile(filePath, "utf8"),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Cap the aggregate skill-file payload

When a workspace contains many large but individually permitted skill files, this retains every file body for one RPC response; the server requests up to 1,000 files at 10 MiB each, so the daemon can accumulate and JSON-serialize nearly 10 GiB in a single WebSocket message. A much smaller collection can already exhaust daemon memory or exceed transport message limits, causing thread startup and /commands resolution to fail, whereas the previous batched per-file RPCs did not aggregate all bodies into one payload. Add an aggregate byte cap or paginate the results while preserving the reduced round-trip behavior.

Useful? React with 👍 / 👎.

brsbl and others added 2 commits October 7, 2026 19:57
One response carried every SKILL.md with only a per-file cap, so a
.bb/skills tree over the 100 MiB daemon socket frame limit would drop the
host session on every retry. Add maxTotalBytes (32 MiB from the server);
skills past the budget return without content and are skipped with a warning.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Local disk reads do not need the batched two-phase stat-then-read loop.
One pass keeps the same budget, limit, and missing-file behavior.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@brsbl brsbl changed the title Read project skills in one host round trip Load project skills in one host round trip Oct 8, 2026
brsbl and others added 2 commits October 7, 2026 22:08
Skip the server's excluded directory names and require an exact-case
SKILL.md, as the host.list_files path did on case-insensitive filesystems.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@brsbl brsbl changed the title Load project skills in one host round trip Load project skills in one host round trip for / and thread start Oct 8, 2026
The response is JSON, where control characters expand up to 6x, so a raw
32 MiB budget could still exceed the 100 MiB daemon socket frame limit.
Count each file's JSON-encoded length against maxTotalBytes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@brsbl

brsbl commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator Author

Closing as superseded. #5257 (merged) added host.read_workspace_agent_context, and /commands on main (apps/server/src/routes/projects.ts, readWorkspaceAgentContext) now reads project skill files in one daemon round trip, which was this PR's goal. Branch kept for reference: bb/project-skills-single-rpc.

AGENT GENERATED

@brsbl brsbl closed this Oct 19, 2026
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