See if stock covers an open order. The model writes one program that calls both lookups and subtracts.
Use this when a check needs two lookups combined in one step, such as stock against open orders, and you want a single result back.
Similar patterns, and when each one is the better fit.

Jev EvalsUse this when you need per-PR eval checks for an agent that diff a candidate run against a stored baseline to flag fractional drops.
Parallel Review Workflow PatternFreeUse this when you need several independent AI reviews of the same input to run at once in a durable workflow and be merged into one result.
Call Options: prepareCallUse this when you need to inject per-user context, such as retrieved documents, into an agent's instructions at call time using typed call options.
Agent Code ArtifactUse this when users and agent tools both edit a runnable Python file beside the chat and you only need in-memory version history.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
generateTextexperimental_codeModeToolexperimental_toolCallersExternal services
app/page.tsxapp/layout.tsxapp/api/compare/route.tscomponents/compare-demo.tsxcomponents/unit-row.tsxhooks/use-compare.tslib/compare.tslib/catalog.tslib/rate-limit.tslib/request-utils.tsREADME.mdnpm packages
6
Registry components
lib/compare.tscompareProduct binds getInventory and getDemand only to code_mode via experimental_toolCallers. readComparison accepts the result when each tool ran once and the program returned { sufficient, remaining }. Do not recompute the math in the route.
lib/catalog.tsThree stub products: sku_123 covered (42/31), sku_404 short (8/27), sku_200 even (20/20). The prompt asks for one Promise-style comparison.
compare/route.tsNode runtime generateText through AI Gateway model deepseek/deepseek-v4.1-flash with zeroDataRetention. Code mode timeout 15s, max 4 bridge requests, 2 in flight. Unknown product ids are 400. A bad program result is 502.
See if stock covers an open order. The model writes one program that calls both lookups and subtracts.
Use this when a check needs two lookups combined in one step, such as stock against open orders, and you want a single result back.
Similar patterns, and when each one is the better fit.

Jev EvalsUse this when you need per-PR eval checks for an agent that diff a candidate run against a stored baseline to flag fractional drops.
Parallel Review Workflow PatternFreeUse this when you need several independent AI reviews of the same input to run at once in a durable workflow and be merged into one result.
Call Options: prepareCallUse this when you need to inject per-user context, such as retrieved documents, into an agent's instructions at call time using typed call options.
Agent Code ArtifactUse this when users and agent tools both edit a runnable Python file beside the chat and you only need in-memory version history.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
generateTextexperimental_codeModeToolexperimental_toolCallersExternal services
app/page.tsxapp/layout.tsxapp/api/compare/route.tscomponents/compare-demo.tsxcomponents/unit-row.tsxhooks/use-compare.tslib/compare.tslib/catalog.tslib/rate-limit.tslib/request-utils.tsREADME.mdnpm packages
6
Registry components
lib/compare.tscompareProduct binds getInventory and getDemand only to code_mode via experimental_toolCallers. readComparison accepts the result when each tool ran once and the program returned { sufficient, remaining }. Do not recompute the math in the route.
lib/catalog.tsThree stub products: sku_123 covered (42/31), sku_404 short (8/27), sku_200 even (20/20). The prompt asks for one Promise-style comparison.
compare/route.tsNode runtime generateText through AI Gateway model deepseek/deepseek-v4.1-flash with zeroDataRetention. Code mode timeout 15s, max 4 bridge requests, 2 in flight. Unknown product ids are 400. A bad program result is 502.
Loading preview…
Early-bird pricing — limited time


Open on desktop for the interactive preview.
See if stock covers an open order. The model writes one program that calls both lookups and subtracts.
Loading preview…
Early-bird pricing — limited time


Open on desktop for the interactive preview.
See if stock covers an open order. The model writes one program that calls both lookups and subtracts.