MCP HubMCP Hub
スキル一覧に戻る

Convex Agents Fundamentals

Sstobo
更新日 Today
124 閲覧
5
5
GitHubで表示
メタai

について

このスキルは、Convexエージェントを構築するための本質的な基盤を提供します。開発者はこれを用いてエージェントの初期化、会話スレッドの管理、テキスト及び構造化されたLLM応答の生成を可能にします。これはConvexプラットフォーム内でチャットベースのAIインタラクションを実装するための核心的な構成要素です。新しいエージェントプロジェクトを開始する際に、基本的な設定と会話管理を処理するためにご利用ください。

クイックインストール

Claude Code

推奨
プラグインコマンド推奨
/plugin add https://github.com/Sstobo/convex-skills
Git クローン代替
git clone https://github.com/Sstobo/convex-skills.git ~/.claude/skills/Convex Agents Fundamentals

このコマンドをClaude Codeにコピー&ペーストしてスキルをインストールします

ドキュメント

Purpose

Guides you through the core patterns for setting up Convex agents, managing conversation threads, and generating LLM responses. This is the foundation upon which all other agent capabilities build.

When to Use This Skill

  • Setting up your first Convex agent in a project
  • Creating or continuing conversation threads with users
  • Generating text responses or structured JSON objects from an LLM
  • Configuring agent defaults (system prompt, chat model, embedding model)
  • Building basic chat interfaces that need message history

How to Use It

1. Install and Configure

Add the agent component to your convex.config.ts:

// convex/convex.config.ts
import { defineApp } from "convex/server";
import agent from "@convex-dev/agent/convex.config";

const app = defineApp();
app.use(agent);

export default app;

Run npx convex dev to generate the required code.

2. Define Your Agent

Create an agent instance with a chat model:

// convex/agents/myAgent.ts
import { components } from "../_generated/api";
import { Agent } from "@convex-dev/agent";
import { openai } from "@ai-sdk/openai";

export const myAgent = new Agent(components.agent, {
  name: "My Assistant",
  languageModel: openai.chat("gpt-4o-mini"),
  instructions: "You are a helpful assistant.", // Optional: default system prompt
});

3. Create Threads

Create a thread for a user to manage their conversation history:

// convex/threads.ts
import { action } from "../_generated/server";
import { v } from "convex/values";
import { myAgent } from "./agents/myAgent";

export const createNewThread = action({
  args: { userId: v.string() },
  handler: async (ctx, { userId }) => {
    const { thread } = await myAgent.createThread(ctx, {
      userId,
      title: "New Conversation",
    });
    return { threadId: thread.getMetadata().threadId };
  },
});

4. Generate Responses

Generate text or structured responses in a thread:

// convex/generation.ts
export const generateReply = action({
  args: { threadId: v.string(), prompt: v.string() },
  handler: async (ctx, { threadId, prompt }) => {
    const { thread } = await myAgent.continueThread(ctx, { threadId });
    const result = await thread.generateText({ prompt });
    return result.text;
  },
});

Key Principles

  • Thread isolation: Each user/conversation gets its own thread for independent history
  • Automatic message storage: Generated responses are automatically saved to the thread
  • Context by default: Each generation includes recent message history automatically
  • Async-friendly: Use actions for LLM calls; mutations for transactional writes
  • Type safety: Always provide explicit return types to avoid circular reference errors

Common Patterns

  • Per-user organization: Always include userId when creating threads
  • Message history: Automatically included in LLM context
  • Thread reuse: Same thread can be used by multiple agents

Next Steps

  • Manage threads: See threads skill for conversation management
  • Work with messages: See messages skill for saving and retrieving
  • Add tools: See tools skill to let agents take actions

GitHub リポジトリ

Sstobo/convex-skills
パス: convex-agents-fundamentals

関連スキル

evaluating-llms-harness

テスト

This Claude Skill runs the lm-evaluation-harness to benchmark LLMs across 60+ standardized academic tasks like MMLU and GSM8K. It's designed for developers to compare model quality, track training progress, or report academic results. The tool supports various backends including HuggingFace and vLLM models.

スキルを見る

sglang

メタ

SGLang is a high-performance LLM serving framework that specializes in fast, structured generation for JSON, regex, and agentic workflows using its RadixAttention prefix caching. It delivers significantly faster inference, especially for tasks with repeated prefixes, making it ideal for complex, structured outputs and multi-turn conversations. Choose SGLang over alternatives like vLLM when you need constrained decoding or are building applications with extensive prefix sharing.

スキルを見る

cloudflare-turnstile

メタ

This skill provides comprehensive guidance for implementing Cloudflare Turnstile as a CAPTCHA-alternative bot protection system. It covers integration for forms, login pages, API endpoints, and frameworks like React/Next.js/Hono, while handling invisible challenges that maintain user experience. Use it when migrating from reCAPTCHA, debugging error codes, or implementing token validation and E2E tests.

スキルを見る

langchain

メタ

LangChain is a framework for building LLM applications using agents, chains, and RAG pipelines. It supports multiple LLM providers, offers 500+ integrations, and includes features like tool calling and memory management. Use it for rapid prototyping and deploying production systems like chatbots, autonomous agents, and question-answering services.

スキルを見る