MCP HubMCP Hub
スキル一覧に戻る

Convex Agents Context

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

について

このスキルは、開発者がLLMが各生成で受け取るコンテキストをカスタマイズできるようにし、メッセージ履歴やRAGコンテキスト注入を制御できます。クロススレッド検索、メモリ注入、会話要約、メッセージフィルタリングなどの高度なパターンをサポートしています。トークンオーバーフローを防止したり、ユーザープロファイルを追加したり、少数ショットの例でLLMの動作を誘導するために使用できます。

クイックインストール

Claude Code

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

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

ドキュメント

Purpose

By default, the Agent includes recent messages as context. This skill covers customizing that behavior for advanced patterns like cross-thread search, memory injection, summarization, and filtering.

When to Use This Skill

  • Limiting context window to prevent token overflow
  • Searching across multiple threads for relevant context
  • Injecting memories or user profiles into every prompt
  • Summarizing long conversations before continuing
  • Filtering out sensitive or irrelevant messages
  • Adding few-shot examples to guide LLM

Configure Default Context Options

const myAgent = new Agent(components.agent, {
  name: "My Agent",
  languageModel: openai.chat("gpt-4o-mini"),
  contextOptions: {
    recentMessages: 50,
    excludeToolMessages: true,
    searchOptions: {
      limit: 10,
      textSearch: true,
      vectorSearch: false,
    },
  },
});

Override Context Per Call

export const generateWithCustomContext = action({
  args: { threadId: v.string(), prompt: v.string() },
  handler: async (ctx, { threadId, prompt }) => {
    const result = await myAgent.generateText(
      ctx,
      { threadId },
      { prompt },
      {
        contextOptions: {
          recentMessages: 20,
          searchOptions: {
            limit: 5,
            textSearch: true,
            vectorSearch: true,
          },
        },
      }
    );

    return result.text;
  },
});

Search Across Threads

export const generateWithCrossThreadContext = action({
  args: { threadId: v.string(), userId: v.string(), prompt: v.string() },
  handler: async (ctx, { threadId, userId, prompt }) => {
    const result = await myAgent.generateText(
      ctx,
      { threadId, userId },
      { prompt },
      {
        contextOptions: {
          searchOtherThreads: true,
          searchOptions: {
            limit: 15,
            textSearch: true,
            vectorSearch: true,
          },
        },
      }
    );

    return result.text;
  },
});

Custom Context Handler

Completely customize context:

const myAgent = new Agent(components.agent, {
  name: "My Agent",
  languageModel: openai.chat("gpt-4o-mini"),
  contextHandler: async (ctx, args) => {
    const userMemories = await getUserMemories(ctx, args.userId);
    const examples = getExamples();

    return [
      ...userMemories,
      ...examples,
      ...args.search,
      ...args.recent,
      ...args.inputMessages,
    ];
  },
});

Fetch Context Manually

Get context without calling LLM:

import { fetchContextWithPrompt } from "@convex-dev/agent";

export const getContextForPrompt = action({
  args: { threadId: v.string(), prompt: v.string() },
  handler: async (ctx, { threadId, prompt }) => {
    const { messages } = await fetchContextWithPrompt(ctx, components.agent, {
      threadId,
      prompt,
      contextOptions: {
        recentMessages: 20,
        searchOptions: { limit: 10, textSearch: true },
      },
    });

    return messages;
  },
});

Key Principles

  • Default context is sufficient: Most use cases work with defaults
  • Search improves relevance: Enable for long conversations
  • userId required for cross-thread: Provide when searching multiple threads
  • Context handlers are powerful: Use for memories, examples, special formatting
  • Recent messages take precedence: Used after search in context order

Next Steps

  • See rag for knowledge base context injection
  • See fundamentals for agent setup
  • See rate-limiting for token management

GitHub リポジトリ

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

関連スキル

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.

スキルを見る