Skip to content

[BUG] AgentConfig.tools typing is unnecessarily wide #15229

@abrahamcl

Description

@abrahamcl

Describe the Bug

AgentConfig.tools accepts an invalid value that should fail type checking. In a static tools map,
each entry should already be a tool object, but TypeScript currently allows a nested resolver
function like myTool: () => realTool.

That compiles without error, even though it is not a valid static tool definition. The bad value
then survives to runtime, where agent.listTools() crashes instead of the mistake being caught by
TypeScript.

Steps To Reproduce

  1. Clone the reproduction repo: https://github.com/abrahamcl/mastra-bug-agent-tools

Reproduction

npm install
npx tsc --noEmit

Expected: TypeScript reports an error for myTool: () => realTool.

Actual: tsc exits successfully with no type error.

To show that an actual runtime crash occurs when using the invalid config, run:

npm run test

Link to Minimal Reproducible Example

https://github.com/abrahamcl/mastra-bug-agent-tools

Expected Behavior

Typescript should flag an invalid tool value

Environment Information

System:
    OS: macOS 26.3
    CPU: (8) arm64 Apple M3
    Memory: 128.28 MB / 24.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 25.8.1 - /opt/homebrew/bin/node
    Yarn: 1.22.22 - /opt/homebrew/bin/yarn
    npm: 11.11.0 - /opt/homebrew/bin/npm
    pnpm: 10.32.1 - /opt/homebrew/bin/pnpm
    bun: 1.3.10 - /opt/homebrew/bin/bun
  Browsers:
    Chrome: 146.0.7680.165
    Safari: 26.3
  npmPackages:
    @mastra/core: ^1.24.1 => 1.24.1 
    @types/node: ^25.5.2 => 25.5.2 
    mastra: ^1.5.0 => 1.5.0 
    typescript: ^6.0.2 => 6.0.2 
    vitest: ^4.1.4 => 4.1.4 
    zod: ^4.3.6 => 4.3.6 
  npmGlobalPackages:
    @openai/codex: 0.75.0
    codex: 0.2.3
    httpyac: 6.16.7
    mint: 4.2.60
    npm: 11.11.0

Verification

  • I have searched the existing issues to make sure this is not a duplicate
  • I have included sufficient information for the team to reproduce and understand the issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions