Description
@ai-sdk/harness-pi 1.0.101. PiHarnessSettings.extensionFactories loads inline pi extensions, but any tool such an extension registers via pi.registerTool() is invisible to the model.
Cause, in createPiSession → rebuildPiSession:
const { session } = await createAgentSession({
...
customTools,
...hasMcpServers ? { noTools: "builtin" } : { tools: toolNames },
tools: toolNames (the 7 harness builtins + host tools) becomes pi's allowedToolNames; AgentSession._refreshToolRegistry filters extensionRunner.getAllRegisteredTools() through it, so extension tools are removed. Only when mcpServers is set does the harness use noTools: "builtin", which is the mode pi documents as "keeping extension and custom tools enabled".
Reproduction
createPi({
model, auth,
extensionFactories: [async (pi) => {
pi.registerTool({ name: 'ping', label: 'ping', description: 'ping', parameters: Type.Object({}), execute: async () => ({ content: [{ type: 'text', text: 'pong' }] }) });
}],
});
// prompt: "list your tools" → read, write, edit, bash, grep, find, ls (no `ping`)
Same with a real-world extension (context-mode's pi adapter, which registers ctx_* tools).
Fix that works for us
- ...hasMcpServers ? { noTools: "builtin" } : { tools: toolNames },
+ ...hasMcpServers || hasExtensionFactories ? { noTools: "builtin" } : { tools: toolNames },
Applied as a pnpm patch; with it the model sees builtins + extension tools and extension tool calls round-trip correctly. If extension-registered tools are intentionally unsupported, the extensionFactories docs should say so.
Description
@ai-sdk/harness-pi1.0.101.PiHarnessSettings.extensionFactoriesloads inline pi extensions, but any tool such an extension registers viapi.registerTool()is invisible to the model.Cause, in
createPiSession→rebuildPiSession:tools: toolNames(the 7 harness builtins + host tools) becomes pi'sallowedToolNames;AgentSession._refreshToolRegistryfiltersextensionRunner.getAllRegisteredTools()through it, so extension tools are removed. Only whenmcpServersis set does the harness usenoTools: "builtin", which is the mode pi documents as "keeping extension and custom tools enabled".Reproduction
Same with a real-world extension (context-mode's pi adapter, which registers
ctx_*tools).Fix that works for us
Applied as a pnpm patch; with it the model sees builtins + extension tools and extension tool calls round-trip correctly. If extension-registered tools are intentionally unsupported, the
extensionFactoriesdocs should say so.