@sisu-ai/mw-register-tools
v9.0.0
Published
Register a set of tools at the start of the pipeline.
Maintainers
Readme
@sisu-ai/mw-register-tools
Register a set of tools at the start of the pipeline.
Setup
npm i @sisu-ai/mw-register-toolsExports
registerTools(tools: Tool[])— callsctx.tools.register(tool)for each item.
What It Does
- Registers one or more tools into
ctx.toolsfor the current run. - Emits a debug log per tool (name + description) to aid troubleshooting.
Tools become available to middlewares that surface them to providers (e.g., @sisu-ai/mw-tool-calling) or to custom loops (ReAct, planners).
How It Works
- On each request, iterates the provided array and calls
ctx.tools.register(tool). - The default registry is in‑memory per context (
SimpleTools), so registration is per run. - If a tool with the same name already exists, the last registration wins (overwrites).
Usage
import { registerTools } from '@sisu-ai/mw-register-tools';
const app = new Agent()
.use(registerTools([myTool]));Placement & Ordering
- Place early in the stack, before tool‑calling or planner middleware that needs access to tools.
- Safe to combine with logging/tracing; tool registration logs at debug level by default.
Notes & Gotchas
- Naming: keep tool names simple (lower‑case letters/numbers/._-) and consistent with prompts.
- Schemas: for providers like OpenAI, zod shapes are converted to JSON Schema under the hood; keep them precise for better tool selection.
- Overwrites: registering two tools with the same
nameoverwrites the first. - Scope: registration is per request/context. If you need global tools, construct them once and pass the same instances in each request.
Community & Support
Discover what you can do through examples or documentation. Check it out at https://github.com/finger-gun/sisu. Example projects live under examples/ in the repo.
