Skip to content

harness-pi: tools registered by extensionFactories extensions never reach the model (dropped by tools allowlist) #20402

Description

@hteek

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 createPiSessionrebuildPiSession:

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions