Loading preview…
Loading preview…
Dynamically configure one ToolLoopAgent per request with callOptionsSchema and prepareCall. A customer-support agent rewrites instructions, gates tools, tunes reasoning effort, and injects RAG context based on account tier and urgency.
Loading preview…
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.
Install from the preview toolbar
Copy the install command above and run it in your project — Pro patterns include a short-lived token.
Add environment variables to .env.local
OPENAI_API_KEY
Point client fetches at your API routes
Replace preview `/view/.../api/...` paths with `/api/...` in the installed files.
Customize the agent and tool files
Adapt prompts, tools, and stop conditions for your product — Copy for AI in the toolbar helps seed that work.
Run your dev server and open the pattern route
Install dependencies if needed, then start the app and verify responses.
OPENAI_API_KEYGet keyAI SDK APIs
ToolLoopAgentcallOptionsSchemaprepareCallactiveToolsproviderOptionstoolgatewayProviders
app/page.tsxapp/layout.tsxapp/api/support/route.tscomponents/call-options-demo.tsxcomponents/prepared-config-display.tsxlib/support-agent.tslib/customer-data.tstools/get-plan-limits.tstools/create-ticket.tsREADME.mdnpm packages
5
Registry components
lib/support-agent.tsCore pattern: ToolLoopAgent with callOptionsSchema (zod) and prepareCall that returns modified instructions, activeTools, and providerOptions from runtime options. prepareCall can be async for RAG.
support/route.tsCalls agent.generate({ prompt, options }) with the required, type-checked call options and returns the resolved config plus the answer.
lib/customer-data.tsClient-safe tier config + fake knowledge base and keyword retrieval used by prepareCall to inject RAG context.
Loading preview…
Early-bird pricing — limited time

Open on desktop for the interactive preview.
Dynamically configure one ToolLoopAgent per request with callOptionsSchema and prepareCall. A customer-support agent rewrites instructions, gates tools, tunes reasoning effort, and injects RAG context based on account tier and urgency.