Files
my-pi/pi-tool-search/docs/dynamic-tool-loading.md
T
云服务部-叶林立andDevin <158243242+devin-ai-integration[bot]@users.noreply.github.com> f9a7f743dd feat: 接入 Pi 内置 codemode,并修复全面审查发现的问题
- codemode:Tool Search 常驻(alwaysEnabled)、权限 allow(嵌套调用仍逐个过权限门)、
  tools.jsonc 登记使用规则;RTK 跳过 parentToolCallId 嵌套调用,避免丢失 bash
  structuredContent;Tool Search 目录过滤 hidden / codemode(script-only)exposure;
  扩展加载测试加载 builtin:codemode 并断言其常驻激活
- 搜索 key 不再经命令行参数传递:search-auth.mjs 改为 --set-stdin(先读校验再加锁),
  configure.sh 交互输入经管道、非交互用 --<provider> -
- CodeGraph 客户端监听子进程 stdin error,避免 EPIPE 未处理导致崩溃
- 移除 PI_TOOL_SEARCH/HERMES_MEMORY/RTK_CONFIG_PATH 环境变量入口,测试改用工厂 configPath 注入
- pi-subagents 固定 vitest / coverage-istanbul 4.1.10,修复 npm ls 版本冲突
- 补 pi-web-search / pi-worktree UPSTREAM.md 与 pi-minimal-footer AGENTS.md,
  files 白名单补齐并加测试;.codegraph/.gitignore 移出跟踪
- detect_kitty 优先识别官方安装目录

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-21 23:18:34 -07:00

5.0 KiB

Current dynamic tool-group loading

pi-tool-search keeps full low-frequency schemas hidden behind a compact, validated group catalog.

  1. session_start activates tool_search, the six cross-platform Pi core tools, and configured alwaysEnabled names. The my-pi defaults also pin CodeGraph exploration, LSP diagnostics, the six Hermes memory tools, and Pi's built-in codemode (exposure model-only). On Windows, powershell is pinned beside bash; on non-Windows hosts it is excluded. Tools with hidden or codemode (script-only) exposure are filtered out before catalog and pin processing. Pinned tools do not consume the dynamic-group or dynamic-tool budget.
  2. Hidden definitions are hashed with grouping constraints and matched against extensions/bundle-groups.ts. Available standard tools receive checked-in groups; unavailable optional tools are omitted.
  3. If every hidden tool is recognized, the bundle catalog is used directly. No model call or per-user cache is required.
  4. Additional tools receive immediate deterministic prefix/source groups. A matching model-enriched cache is reused only if it preserves all checked-in bundle assignments.
  5. Only a hybrid catalog with unrecognized tools can call ModelRegistry.complete(), and an exact existing group skips that enrichment so activation cannot wait on an unrelated unknown tool. Unknown-group and query lookups may still enrich the catalog. The prompt marks bundle assignments as fixed; validation rejects any response that moves them.
  6. Code validation still requires every exact tool name exactly once and rejects unknown names, duplicates, oversized generated groups, omissions, and tool-card/group mismatches. Generated text never changes executable schemas.
  7. Loading one exact group or an atomic groups batch calls setActiveTools() once with the original full tool definitions. A batch is rejected without changing active state if its requested groups alone exceed either capacity limit. Pi supplies newly added schemas on the next model request.
  8. Group load and member execution update an in-session LRU counter. Loading past the five-group or 28-tool defaults removes least-recently-used non-requested dynamic groups. /tool-search-status reports current capacity, LRU order, and the latest eviction reason.
  9. Natural-language lookup gives exact tool names and workflow aliases more weight than descriptive overlap. Weak or closely tied matches return candidates without activation.
  10. turn_start notices tool or grouping-configuration changes by hash, resets stale dynamic groups, and reconstructs the checked-in/hybrid catalog.

The standard bundle assigns the Hermes memory extension's six tools to recall and management groups: memory_search, session_search, and overflow_query join context_tree_query in memory-recall, while memory_add, memory_replace, memory_remove, and skill_manage form memory-management. All six are pinned by default, because the injected <memory-policy> tells the model to consult and write memory during normal work, and a schema the model cannot see would silently disable that loop. Third-party tff-memory_* names and the retired Hippo hippo_* names are not seeded. It also assigns Agent, get_subagent_result, and steer_subagent to the subagents orchestration group. The maintained pi-ssh tools are also split by workflow: sequential reviewed agent-controlled connection lives in ssh-connection, structured ssh_read/ssh_write/ssh_edit file operations live in ssh-remote-files, bounded ssh_find/ssh_grep discovery lives in ssh-remote-search, and sequential reviewed workspace changes plus reviewed command execution live in ssh-remote-shell. The workflows tell the model to call ssh_connect or ssh_cd separately and wait for success before issuing remote calls that depend on the new connection or cwd. The maintained ask_user_question tool has its own user-interaction group so the model can load the complete interactive schema only when a missing decision or preference must come from the user. The pinned pi-chrome bridge registers its 21 chrome_* tools only after explicit per-session authorization. Once registered, catalog refresh assigns them to chrome-navigation, chrome-interaction, and chrome-debugging; the 28-tool default allows all three groups to coexist. Revocation remains enforced inside every upstream tool execution even if a schema is later reactivated by Tool Search.

A purely additive first load receives Pi's native dynamic-tool result propagation. A replacement that evicts one group while adding another is intentionally non-additive; current Pi detects the removal and uses its safe next-request fallback instead of attaching an invalid additive-only hint.

A model cannot call a schema it had not received in an already-generated assistant response. tool_search therefore returns normally, and the next model request sees the activated group's complete schemas. No provider payload rewriting, proxy dispatch, hidden steer message, old package alias, or duplicate Pi runtime is used.