Prune an agent's tool list before the model sees it. Allow and deny rules run first; Jev asks one relevance boolean per remaining tool in a single call.
Requirements, wiring steps, and what this pattern adds to your project.
Pick how you want to pull this pattern in. Then wire env vars and routes the same way.
Download → Next.js app
Use Download → Next.js app in the preview toolbar. You get a zip scaffold (Pro downloads rewrite preview `/view/.../api/*` paths to `/api/*` automatically).
Extract the zip and install dependencies
Unzip the archive, then run `pnpm install` (or npm / yarn) in the project folder.
Fill .env.local
The download includes .env.local placeholders when needed. Add real values for: AI_GATEWAY_API_KEY.
Customize the agent and tool files
Adapt prompts, tools, and stop conditions in the generated project for your product.
Run the app and open the pattern route
Run `pnpm dev`, open the setup/checklist page if present, then navigate to the generated pattern route and verify responses.
AI_GATEWAY_API_KEYGet keyAI SDK APIs
experimental_evaluateexperimental_filterActiveToolsprepareStepProviders
External services
app/page.tsxapp/layout.tsxapp/api/prune/route.tscomponents/tool-permissions-demo.tsxcomponents/tool-pile.tsxcomponents/typesafe-ai.tsxhooks/use-tool-pruner.tslib/tool-rules.tslib/prune-questions.tslib/prune-tools.tslib/prepare-step.tslib/tool-catalog.tslib/prune-catalog.tslib/rate-limit.tslib/request-utils.tsREADME.mdnpm packages
6
Registry components
lib/prune-tools.tspruneTools runs deny then allow rules, then asks one boolean per undecided tool in exactly one evaluate() call. decidePrune keeps tools at or above 0.20 and tools with no answer. On any error it fails open and keeps every non-denied tool. Use Experimental_EvaluationMockModelV4 in tests; never call Jev from unit tests.
lib/tool-rules.tsRules are glob strings, RegExp, or predicates. Deny beats allow. Only * and ? are special in globs; a dot is literal.
lib/prepare-step.tscreatePruningPrepareStep prunes once per generateText/streamText call on step 0 and returns the same activeTools on later steps, cached by initialMessages.
lib/prune-questions.tsKEEP_FLOOR and the relevance question live in application code. The floor is low on purpose: a wrongly dropped tool breaks the turn.
prune/route.tsRate-limited pruneCatalog over the 30-tool demo catalog with allow search.* and deny debug.*. Returns kept, dropped, relevance, rules, and token counts.
Prune an agent's tool list before the model sees it. Allow and deny rules run first; Jev asks one relevance boolean per remaining tool in a single call.
Requirements, wiring steps, and what this pattern adds to your project.
Pick how you want to pull this pattern in. Then wire env vars and routes the same way.
Download → Next.js app
Use Download → Next.js app in the preview toolbar. You get a zip scaffold (Pro downloads rewrite preview `/view/.../api/*` paths to `/api/*` automatically).
Extract the zip and install dependencies
Unzip the archive, then run `pnpm install` (or npm / yarn) in the project folder.
Fill .env.local
The download includes .env.local placeholders when needed. Add real values for: AI_GATEWAY_API_KEY.
Customize the agent and tool files
Adapt prompts, tools, and stop conditions in the generated project for your product.
Run the app and open the pattern route
Run `pnpm dev`, open the setup/checklist page if present, then navigate to the generated pattern route and verify responses.
AI_GATEWAY_API_KEYGet keyAI SDK APIs
experimental_evaluateexperimental_filterActiveToolsprepareStepProviders
External services
app/page.tsxapp/layout.tsxapp/api/prune/route.tscomponents/tool-permissions-demo.tsxcomponents/tool-pile.tsxcomponents/typesafe-ai.tsxhooks/use-tool-pruner.tslib/tool-rules.tslib/prune-questions.tslib/prune-tools.tslib/prepare-step.tslib/tool-catalog.tslib/prune-catalog.tslib/rate-limit.tslib/request-utils.tsREADME.mdnpm packages
6
Registry components
lib/prune-tools.tspruneTools runs deny then allow rules, then asks one boolean per undecided tool in exactly one evaluate() call. decidePrune keeps tools at or above 0.20 and tools with no answer. On any error it fails open and keeps every non-denied tool. Use Experimental_EvaluationMockModelV4 in tests; never call Jev from unit tests.
lib/tool-rules.tsRules are glob strings, RegExp, or predicates. Deny beats allow. Only * and ? are special in globs; a dot is literal.
lib/prepare-step.tscreatePruningPrepareStep prunes once per generateText/streamText call on step 0 and returns the same activeTools on later steps, cached by initialMessages.
lib/prune-questions.tsKEEP_FLOOR and the relevance question live in application code. The floor is low on purpose: a wrongly dropped tool breaks the turn.
prune/route.tsRate-limited pruneCatalog over the 30-tool demo catalog with allow search.* and deny debug.*. Returns kept, dropped, relevance, rules, and token counts.
Loading preview…
Early-bird pricing — limited time


Open on desktop for the interactive preview.
Prune an agent's tool list before the model sees it. Allow and deny rules run first; Jev asks one relevance boolean per remaining tool in a single call.
Loading preview…
Early-bird pricing — limited time


Open on desktop for the interactive preview.
Prune an agent's tool list before the model sees it. Allow and deny rules run first; Jev asks one relevance boolean per remaining tool in a single call.