mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
fix(coding-agent): render MCP tool calls before their server connects
Add pi.registerToolRenderer((toolName, next) => renderers), which chooses the renderers for calls to any tool, including tools that are not registered. Resolvers run in extension load order; next() returns what the remaining resolvers, then the registered tool, would use. Interactive mode and HTML export both resolve through it. The MCP extension uses it to render every mcp__<server>__<tool> call with the MCP renderers, so calls in a resumed session no longer render fully expanded before their server connects, or for good if it never does. closes #10285
This commit is contained in:
parent
a276dabe57
commit
11449730c8
17 changed files with 189 additions and 47 deletions
|
|
@ -185,6 +185,10 @@ Register every tool first, keep optional tools inactive, and use `pi.setActiveTo
|
|||
|
||||
Pi records the initial prompt and tool set in the transcript's first system message, then appends tool and prompt changes before the next model request. Providers that cannot represent the transition receive a complete transcript checkpoint, which can invalidate the cached prefix.
|
||||
|
||||
### Tool rendering
|
||||
|
||||
A tool's `renderCall` and `renderResult` draw its calls in the interactive transcript and in HTML exports. `pi.registerToolRenderer((toolName, next) => renderers)` chooses renderers for calls to any tool, including tools that are not registered yet, such as MCP tools in a resumed session before their server connected. `next()` returns what the remaining resolvers (in extension load order), then the registered tool, would use, so `next() ?? mine` only fills in.
|
||||
|
||||
### MCP servers
|
||||
|
||||
`pi.registerMcpServer(name, config)` adds an MCP server for the current session. `config` has the shape of an `mcpServers` entry in [`mcp.json`](mcp.md): `command`, `args`, `env`, and `cwd` for stdio servers, `url`, `headers`, and `oauth` for HTTP servers, plus `exposure`, `toolExposure`, `description`, `enabled`, and `timeout`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue