Command Palette

Search for a command to run...

Назад к скиллам
скилл № 92810

Ai Agents Ui Skills

Comprehensive guide for building AI agents using ToolLoopAgent, workflow patterns, and AI SDK UI components (useChat, generative UIs, tool calling)

БесплатноБез исполняемых скриптов
gocallumот gocallum★ 23 звезды на GitHub

Установить Ai Agents Ui Skills в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

AI Agents & UI Skills

Status: AI SDK 6 Beta Package Manager: pnpm Key Version: @ai-sdk/core, @ai-sdk/react (for UI) Official Docs:


Table of Contents

  1. Installation & Setup
  2. Understanding Agents
  3. Building ToolLoopAgent
  4. Agent Configuration Options
  5. System Instructions & Behavior
  6. Workflow Patterns
  7. AI SDK UI - useChat Hook
  8. Building Chatbot Applications
  9. Tool Calling in UI
  10. Generative User Interfaces
  11. Advanced Patterns
  12. Best Practices

Installation & Setup

Install Dependencies

# Core packages
pnpm add ai @ai-sdk/core @ai-sdk/anthropic

# For UI (React)
pnpm add @ai-sdk/react

# Optional: specific providers
pnpm add @ai-sdk/openai @ai-sdk/google

TypeScript Configuration

Ensure your tsconfig.json has proper settings:

{
  "compilerOptions": {
    "target": "ES2020",
    "lib": ["ES2020", "DOM"],
    "moduleResolution": "bundler",
    "strict": true
  }
}

Understanding Agents

What Are Agents?

Agents are LLMs that use tools in a loop to accomplish tasks. Three core components work together:

  1. LLMs - Process input, decide next action
  2. Tools - Extend capabilities (APIs, databases, files)
  3. Loop - Orchestrates execution through context management and stopping conditions

ToolLoopAgent Class

The ToolLoopAgent class is the recommended approach because it:

  • Reduces boilerplate - Manages loops and message arrays automatically
  • Improves reusability - Define once, use throughout application
  • Simplifies maintenance - Single place to update configuration
  • Provides type safety - Full TypeScript support for tools and outputs

vs. Core Functions

For most use cases, use ToolLoopAgent. Use core functions (generateText, streamText) when you need explicit control for complex structured workflows.


Building ToolLoopAgent

Basic Agent

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

const weatherAgent = new ToolLoopAgent({
  model: 'anthropic/claude-sonnet-4.5',
  tools: {
    weather: tool({
      description: 'Get weather in a location (Fahrenheit)',
      inputSchema: z.object({
        location: z.string().describe('The location'),
      }),
      execute: async ({ location }) => ({
        location,
        temperature: 72 + Math.floor(Math.random() * 21) - 10,
      }),
    }),
    convertFahrenheitToCelsius: tool({
      description: 'Convert Fahrenheit to Celsius',
      inputSchema: z.object({
        temperature: z.number(),
      }),
      execute: async ({ temperature }) => ({
        celsius: Math.round((temperature - 32) * (5 / 9)),
      }),
    }),
  },
});

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

console.log(result.text); // Agent's final answer
console.log(result.steps); // Steps taken by agent

Multi-Tool Execution

The agent automatically:

  1. Calls weather tool to get temperature in Fahrenheit
  2. Calls convertFahrenheitToCelsius to convert it
  3. Generates final text response with result

Agent Configuration Options

Model and System Instructions

const agent = new ToolLoopAgent({
  model: 'anthropic/claude-sonnet-4.5',
  instructions: 'You are an expert data analyst. Provide clear insights.',
});

Tools

const codeAgent = new ToolLoopAgent({
  model: 'anthropic/claude-sonnet-4.5',
  tools: {
    runCode: tool({
      description: 'Execute Python code',
      inputSchema: z.object({
        code: z.string(),
      }),
      execute: async ({ code }) => {
        // Execute code
        return { output: 'Result' };
      },
    }),
  },
});

Loop Control (stopWhen)

By default, agents run for 20 steps (stopWhen: stepCountIs(20)). Each step is one generation (text or tool call).

import { ToolLoopAgent, stepCountIs } from 'ai';

const agent = new ToolLoopAgent({
  model: 'anthropic/claude-sonnet-4.5',
  stopWhen: stepCountIs(20), // Allow up to 20 steps
});

// Combine multiple stop conditions
const agent2 = new ToolLoopA
Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл Ai Agents Ui Skills?

Comprehensive guide for building AI agents using ToolLoopAgent, workflow patterns, and AI SDK UI components (useChat, generative UIs, tool calling)

Как установить скилл Ai Agents Ui Skills?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл Ai Agents Ui Skills запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить Ai Agents Ui Skills с