Skip to content

feat(ai): add tool namespaces - #46548

Open
rekram1-node wants to merge 4 commits into
v2from
ai-tool-namespaces
Open

feat(ai): add tool namespaces#46548
rekram1-node wants to merge 4 commits into
v2from
ai-tool-namespaces

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add recursive provider-neutral ToolEntry definitions with ToolDefinition leaves and ToolNamespace groups
  • normalize, sanitize, deduplicate, and budget recursive tool trees without collapsing sibling namespace identities
  • lower outer namespaces natively for OpenAI Responses and recursively flatten them for protocols without native namespace support
  • preserve OpenAI namespace identity through streaming events, local dispatch, history normalization, and replay
  • keep Core tool registration flat for now while updating its AI definitions and legacy AI SDK adapter for the widened AI surface

Shape

LLM.request({
  model,
  tools: [
    ToolNamespace.make({
      name: "acme",
      description: "Acme tools",
      tools: [
        ToolDefinition.make({
          name: "billing",
          description: "Look up billing details",
          inputSchema: { type: "object" },
        }),
        ToolDefinition.make({
          name: "users",
          description: "Look up users",
          inputSchema: { type: "object" },
        }),
      ],
    }),
  ],
})

OpenAI Responses lowers this to its native { type: "namespace", ... } wire shape. Generic Open Responses and protocols without native namespace support lower the leaves as acme_billing and acme_users, including matching historical calls. OpenAI only accepts one native namespace level, so deeper semantic levels are flattened within the outer native namespace.

Validation

  • bun typecheck, full suite (939 passed, 25 skipped), and bun run build in packages/ai
  • forced Core typecheck
  • 53 focused Core tool/schema/session tests
  • changed files pass Prettier and git diff --check

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant