Repository navigation
fix: 让扩展/package 工具在 pi-web 新建 session 中可用(修复 #79) - #83
Merged
agegr merged 1 commit intoJun 24, 2026
Merged
Conversation
startRpcSession passed a builtin-only allow-list (allCodingToolNames) to createAgentSession for non-empty tool presets. In the SDK that sets allowedToolNames, and isAllowedTool() filters the tool registry by it, so every extension/package-provided tool (pi-subagents' `subagent`, pi-web-access' web tools, ...) was dropped from the registry — web sessions exposed only read/bash/edit/write while the `pi` CLI kept the extension tools. Don't restrict the allow-list for non-empty presets (leave allowedToolNames undefined so all tools register and extension tools activate); set the active set to the requested builtin tools plus all extension tools. "Off" (empty array) and resume (no toolNames) paths are unchanged. Addresses the symptom reported in #79. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
cnbattle
added a commit
to cnbattle/pi-web
that referenced
this pull request
Jun 23, 2026
…upstream PR agegr#83: fix extension/package tools available in pi-web new sessions PR agegr#80: load extension models in web model selector PR agegr#78: add ToolsConfig panel with individual tool toggles PR agegr#65: add scroll-to-bottom control for chat sessions PR agegr#75: add rehype-raw plugin to render HTML tables in markdown PR agegr#76: fix stack overflow on large session files (+TTL cache)
Merged
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.
问题
通过 pi-web 新建 / 配置带工具预设的 session 时,只有 4 个内置工具
read/bash/edit/write可用,所有扩展 / package 提供的工具全部消失(如pi-subagents的subagent、pi-web-access的web_search/code_search/fetch_content)。完全相同的~/.pi配置在独立piCLI 里一切正常。对应 #79。根因
lib/rpc-manager.ts的startRpcSession在toolNames非空时,把写死的内置列表allCodingToolNames(["read","bash","edit","write","grep","find","ls"])作为tools传给createAgentSession。在 SDK 里tools→allowedToolNames,而isAllowedTool(name)用它过滤工具注册表 —— 扩展工具不在白名单里 → 被挡在注册表外 → 既不出现也无法激活(includeAllExtensionTools只对已通过isAllowedTool的工具生效)。预设(
components/ToolPanel.tsx的PRESET_NONE/PRESET_DEFAULT/PRESET_FULL)也只含内置工具,所以扩展工具在 Low/High 档结构上被排除。只有恢复已有会话(不传toolNames)时allowedToolNames === undefined,扩展工具才可用 —— 这也是「打开旧会话有工具、新建会话没工具、重启服务后又有」现象的来源。修改(
lib/rpc-manager.ts)tools留空 →allowedToolNames为undefined→ 所有工具进注册表、扩展工具被激活);测试
tsc --noEmit通过;createAgentSession→allowedToolNames/isAllowedTool/includeAllExtensionTools);pi install npm:pi-subagents)新建一个 session 验证subagent出现。备注
更彻底的做法可让
ToolPanel同时列出扩展工具供逐个开关;本 PR 先做最小后端修复,恢复「扩展工具默认可用」的预期行为。Related: #79