PatternsSDK API

Queue

Loading pattern preview

Loading preview…

Problems solved

Technical challenges this implementation handles out of the box.
  • Generate structured queues with messages, todos, and attachments
  • Drive queue creation through Experimental_Agent tool calls
  • Manage conversational workflow state in a chat UI

Use cases

Products and workflows this pattern is designed to support.
  • Support ticket intake queues
  • Content review queues with attachments
  • Ops todo lists built through chat
  • Agent demos for structured queue outputs

Setup

Requirements, wiring steps, and what this pattern adds to your project.

Getting started

Pick how you want to pull this pattern in — then wire env vars and routes the same way.

  1. 1

    Install from the preview toolbar

    Shadcn Icon

    Copy the install command above and run it in your project — Pro patterns include a short-lived token.

  2. 2

    Add environment variables to .env.local

    GOOGLE_API_KEY

  3. 3

    Point client fetches at your API routes

    Replace preview `/view/.../api/...` paths with `/api/...` in the installed files.

  4. 4

    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.

  5. 5

    Run your dev server and open the pattern route

    Install dependencies if needed, then start the app and verify responses.

Environment variables

Capabilities

AI SDK APIs

generateObjecttoolAgentvalidateUIMessages

Providers

Gemini

Files added

10 files
  • app/page.tsx
  • app/layout.tsx
  • app/api/agent/route.ts
  • components/queue-demo.tsx
  • lib/queue-agent.ts
  • lib/queue-tool.ts
  • lib/types.ts
  • lib/schema.ts
  • lib/request-utils.ts
  • README.md

Dependencies

8 total

npm packages

5
AISDKlucide-reactNext.jsReactZod

Shadcn IconRegistry components

3
buttonemptytooltip

Critical files

  • agent/route.ts

    API route using createAgentUIStreamResponse with the Experimental_Agent pattern. Shows the new Agent API pattern from AI SDK.

  • lib/queue-agent.ts

    Defines the queue management Agent using the Experimental_Agent API from AI SDK. Uses google/gemini-3-flash with createQueue tool and stepCountIs(5) stop condition.

  • lib/queue-tool.ts

    Implements the createQueue tool that uses generateObject with a structured Zod schema to generate queue data (sections with messages, todos, attachments).

Requirements

Complexity
Beginner
Setup time
~10 minutes
Node
24+
Memory
512MB
Upstash Redis