Two-phase marketing agent with brand context: Stage 0 extracts brand info from URL or manual input, planning phase gathers requirements and creates a plan with todos, implementation phase executes the plan using web scraping and research tools. Uses callOptionsSchema + prepareCall for dynamic agent configuration.
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: OPENAI_API_KEY, FIRECRAWL_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 SDK APIs
useChatgatewayToolLoopAgenttoolgenerateObjecthasToolCallstepCountIscreateAgentUIStreamResponseInferAgentUIMessagecallOptionsSchemaprepareCallexperimental_contextProviders
External services
app/page.tsxapp/layout.tsxapp/api/agent-usecase-marketing-plan/route.tsapp/api/agent-usecase-marketing-implement/route.tslib/marketing-plan-types.tslib/marketing-plan-actions.tslib/cheerio-scraper.tslib/utils/format-brand-context.tslib/ai/plan/plan-agent.tslib/ai/plan/tools/index.tslib/ai/plan/tools/ask-multiple-choice.tslib/ai/plan/tools/ask-text-input.tslib/ai/plan/tools/generate-plan.tslib/ai/plan/tools/refine-plan.tslib/ai/implement/implement-agent.tslib/ai/implement/tools/index.tslib/ai/implement/tools/read-plan.tslib/ai/implement/tools/update-plan.tslib/ai/implement/tools/read-todo.tslib/ai/implement/tools/update-todo.tslib/ai/implement/tools/finalize.tslib/ai/implement/tools/firecrawl.tslib/ai/implement/tools/url-scraper.tsREADME.mdnpm packages
10
Registry components
agent-usecase-marketing-plan/route.tsPlan phase API route using createAgentUIStreamResponse with callOptions to pass brandContext at runtime.
agent-usecase-marketing-implement/route.tsImplement phase API route passing both brandContext and plan via callOptions.
plan/plan-agent.tsPlan builder ToolLoopAgent with callOptionsSchema + prepareCall for runtime brand context injection into instructions and experimental_context.
tools/ask-multiple-choice.tsBrand-context-aware multiple choice tool. Reads brandContext from experimental_context to tailor AI-generated questions.
tools/generate-plan.tsPlan generation tool with brand context awareness using generateObject with planSchema.
tools/refine-plan.tsPlan refinement tool with brand-context-aware iteration.
tools/ask-text-input.tsBrand-context-aware text input tool for gathering open-ended requirements.
implement/implement-agent.tsAutonomous implementation agent with prepareStep for phased workflow (triage, process todos, research, synthesis, finalize). Most advanced agent pattern: callOptionsSchema, prepareCall, prepareStep, stopWhen.
tools/finalize.tsImplementation finalization tool that reads plan from experimental_context and signals completion.
tools/update-plan.tsTool for updating plan sections from experimental_context.
tools/update-todo.tsTool for updating todo status with validation against plan.
tools/read-plan.tsTool for reading current plan state from experimental_context.
tools/read-todo.tsTool for reading/filtering todos by ID or status from the plan context.
tools/firecrawl.tsFirecrawl web search tool for real-time web research during plan implementation.
lib/marketing-plan-types.tsComplete type system including Zod schemas (BrandContext, Plan, Todo) and all type definitions for both plan and implement phases.
utils/format-brand-context.tsUtility that formats BrandContext into markdown for injection into agent instructions.
Two-phase marketing agent with brand context: Stage 0 extracts brand info from URL or manual input, planning phase gathers requirements and creates a plan with todos, implementation phase executes the plan using web scraping and research tools. Uses callOptionsSchema + prepareCall for dynamic agent configuration.
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: OPENAI_API_KEY, FIRECRAWL_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 SDK APIs
useChatgatewayToolLoopAgenttoolgenerateObjecthasToolCallstepCountIscreateAgentUIStreamResponseInferAgentUIMessagecallOptionsSchemaprepareCallexperimental_contextProviders
External services
app/page.tsxapp/layout.tsxapp/api/agent-usecase-marketing-plan/route.tsapp/api/agent-usecase-marketing-implement/route.tslib/marketing-plan-types.tslib/marketing-plan-actions.tslib/cheerio-scraper.tslib/utils/format-brand-context.tslib/ai/plan/plan-agent.tslib/ai/plan/tools/index.tslib/ai/plan/tools/ask-multiple-choice.tslib/ai/plan/tools/ask-text-input.tslib/ai/plan/tools/generate-plan.tslib/ai/plan/tools/refine-plan.tslib/ai/implement/implement-agent.tslib/ai/implement/tools/index.tslib/ai/implement/tools/read-plan.tslib/ai/implement/tools/update-plan.tslib/ai/implement/tools/read-todo.tslib/ai/implement/tools/update-todo.tslib/ai/implement/tools/finalize.tslib/ai/implement/tools/firecrawl.tslib/ai/implement/tools/url-scraper.tsREADME.mdnpm packages
10
Registry components
agent-usecase-marketing-plan/route.tsPlan phase API route using createAgentUIStreamResponse with callOptions to pass brandContext at runtime.
agent-usecase-marketing-implement/route.tsImplement phase API route passing both brandContext and plan via callOptions.
plan/plan-agent.tsPlan builder ToolLoopAgent with callOptionsSchema + prepareCall for runtime brand context injection into instructions and experimental_context.
tools/ask-multiple-choice.tsBrand-context-aware multiple choice tool. Reads brandContext from experimental_context to tailor AI-generated questions.
tools/generate-plan.tsPlan generation tool with brand context awareness using generateObject with planSchema.
tools/refine-plan.tsPlan refinement tool with brand-context-aware iteration.
tools/ask-text-input.tsBrand-context-aware text input tool for gathering open-ended requirements.
implement/implement-agent.tsAutonomous implementation agent with prepareStep for phased workflow (triage, process todos, research, synthesis, finalize). Most advanced agent pattern: callOptionsSchema, prepareCall, prepareStep, stopWhen.
tools/finalize.tsImplementation finalization tool that reads plan from experimental_context and signals completion.
tools/update-plan.tsTool for updating plan sections from experimental_context.
tools/update-todo.tsTool for updating todo status with validation against plan.
tools/read-plan.tsTool for reading current plan state from experimental_context.
tools/read-todo.tsTool for reading/filtering todos by ID or status from the plan context.
tools/firecrawl.tsFirecrawl web search tool for real-time web research during plan implementation.
lib/marketing-plan-types.tsComplete type system including Zod schemas (BrandContext, Plan, Todo) and all type definitions for both plan and implement phases.
utils/format-brand-context.tsUtility that formats BrandContext into markdown for injection into agent instructions.
Loading preview…
Early-bird pricing — limited time

Open on desktop for the interactive preview.
Two-phase marketing agent with brand context: Stage 0 extracts brand info from URL or manual input, planning phase gathers requirements and creates a plan with todos, implementation phase executes the plan using web scraping and research tools. Uses callOptionsSchema + prepareCall for dynamic agent configuration.
Loading preview…
Early-bird pricing — limited time

Open on desktop for the interactive preview.
Two-phase marketing agent with brand context: Stage 0 extracts brand info from URL or manual input, planning phase gathers requirements and creates a plan with todos, implementation phase executes the plan using web scraping and research tools. Uses callOptionsSchema + prepareCall for dynamic agent configuration.