Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
bjornmelin avatar

Ai Sdk Agents

  • 5 installs
  • 5 repo stars
  • Updated August 5, 2026
  • bjornmelin/dev-skills

Ai-sdk-agents is a Claude Code skill providing expert guidance for building autonomous agents with the AI SDK v6+ ToolLoopAgent.

About

Ai-sdk-agents is a Claude Code skill giving expert guidance for building autonomous agents with the AI SDK v6+ ToolLoopAgent. It covers when to use ToolLoopAgent versus core generateText/streamText, loop control with stopWhen and hasToolCall, structured output, streaming, and type-safe client integration. It also documents runtime configuration via callOptionsSchema, prepareCall, and prepareStep, plus multi-agent workflow patterns. Developers use it when creating agents, tool loops, or agent workflows with the Vercel AI SDK.

  • Guidance for building autonomous agents with ToolLoopAgent in AI SDK v6+
  • Covers stopWhen, prepareStep, callOptionsSchema, prepareCall, and tool loops
  • Includes workflow patterns: sequential, routing, evaluator-optimizer, orchestrator-worker

Ai Sdk Agents by the numbers

  • 5 all-time installs (skills.sh)
  • Ranked #13,065 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
At a glance

ai-sdk-agents capabilities & compatibility

Free skill; requires a model provider API key (e.g. Anthropic or OpenAI) to run the agents it builds.

Capabilities
orchestration · api development
Works with
anthropic · openai · vercel
Use cases
orchestration · api development
Pricing
Bring your own API key
From the docs

What ai-sdk-agents says it does

Build autonomous agents with ToolLoopAgent: reusable model + tools + loop control.
SKILL.md
Set `stopWhen` (default: `stepCountIs(20)`) for safety.
SKILL.md
npx skills add https://github.com/bjornmelin/dev-skills --skill ai-sdk-agents

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs5
repo stars5
Last updatedAugust 5, 2026
Repositorybjornmelin/dev-skills

What it does

Build autonomous AI agents with the AI SDK ToolLoopAgent, controlling the tool loop, structured output, and multi-agent workflows.

Who is it for?

Building autonomous multi-step agents and workflows with ToolLoopAgent and loop control

Skip if: Deterministic single-shot generation flows better served by generateText or streamText

When should I use this skill?

Creating agents, configuring stopWhen/prepareStep, tool loops, or agent workflows with the AI SDK

What you get

A working ToolLoopAgent with correct stopWhen, structured output, streaming, and workflow patterns.

  • ToolLoopAgent agent implementations
  • agent API routes and workflow patterns

By the numbers

  • default stopWhen is stepCountIs(20)
  • 7 reference files bundled

Files

SKILL.mdMarkdownGitHub ↗

AI SDK Agents

Build autonomous agents with ToolLoopAgent: reusable model + tools + loop control.

Quick Start

Assume Zod v4.3.5 for schema typing.

import { ToolLoopAgent, tool } from 'ai';
import { anthropic } from '@ai-sdk/anthropic';
import { z } from 'zod';

const weatherAgent = new ToolLoopAgent({
  model: anthropic('claude-sonnet-4-20250514'),
  tools: {
    weather: tool({
      description: 'Get the weather in a location (F)',
      inputSchema: z.object({ location: z.string() }),
      execute: async ({ location }) => ({ location, temperature: 72 }),
    }),
  },
});

const result = await weatherAgent.generate({
  prompt: 'What is the weather in San Francisco?',
});

When to Use ToolLoopAgent vs Core Functions

  • Use ToolLoopAgent for dynamic, multi-step tasks where the model decides which tools to call.
  • Use generateText/streamText for deterministic flows or strict ordering.

Essential Patterns

Structured Output

import { ToolLoopAgent, Output } from 'ai';
import { z } from 'zod';

const analysisAgent = new ToolLoopAgent({
  model: 'openai/gpt-4o',
  output: Output.object({
    schema: z.object({
      sentiment: z.enum(['positive', 'neutral', 'negative']),
      summary: z.string(),
    }),
  }),
});

Streaming Agent

const stream = myAgent.stream({ prompt: 'Summarize this report' });
for await (const chunk of stream.textStream) {
  process.stdout.write(chunk);
}

API Route

import { createAgentUIStreamResponse } from 'ai';

export async function POST(request: Request) {
  const { messages } = await request.json();
  return createAgentUIStreamResponse({ agent: myAgent, messages });
}

Type-Safe Client Integration

import { ToolLoopAgent, InferAgentUIMessage } from 'ai';

const myAgent = new ToolLoopAgent({ model, tools });
export type MyAgentUIMessage = InferAgentUIMessage<typeof myAgent>;

Loop Control Checklist

  • Set stopWhen (default: stepCountIs(20)) for safety.
  • Use hasToolCall('finalAnswer') to stop on terminal actions.
  • Use prepareStep to swap models, compress messages, or limit tools per step.

Runtime Configuration

  • Use callOptionsSchema to define type-safe runtime options.
  • Use prepareCall to select model/tools or inject RAG context once per call.
  • Use prepareStep for per-step decisions (budget limits, dynamic tools).

Reference Files

ReferenceWhen to Use
references/fundamentals.mdToolLoopAgent basics, Output types, streaming
references/loop-control.mdstopWhen, hasToolCall, prepareStep patterns
references/configuration.mdcallOptionsSchema, prepareCall vs prepareStep
references/workflow-patterns.mdmulti-agent workflows and routing
references/real-world.mdRAG, multimodal, file processing
references/production.mdmonitoring, safety, cost control
references/migration.mdv6 migration notes

Related skills

FAQ

When should I use ToolLoopAgent vs core functions?

Use ToolLoopAgent for dynamic, multi-step tasks where the model decides which tools to call, and use generateText/streamText for deterministic flows or strict ordering.

How do I keep an agent loop safe?

Set stopWhen (default stepCountIs(20)) for safety, use hasToolCall('finalAnswer') to stop on terminal actions, and use prepareStep to swap models, compress messages, or limit tools per step.

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.