Convex Agent

作者 get-convex2cfe645c87f9無授權條款63 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫6 天前更新

Add an AI agent / RAG backend (@convex-dev/agent) to the Convex app.

僅含說明AI & Agents
AI 產生的概覽

使用 @convex-dev/agent 為 Convex 應用程式加入 AI 代理與 RAG 後端,支援持久化執行緒和向量檢索。

功能
此技能指導在 Convex 應用程式中加入 AI 代理與 RAG 後端:安裝 @convex-dev/agent 和 @convex-dev/ai-sdk-provider,並在 convex.config.ts 中註冊代理元件。內容涵蓋定義含工具與指示的代理、建立執行緒並串流訊息且將歷史記錄持久化至 Convex,以及將文件嵌入向量索引以供檢索。模型呼叫預設走 Convex AI Gateway,閘道無法使用時改用儲存在 Convex 環境中的供應商金鑰。
適用情境
當 Convex 應用程式需要內建 AI 代理、持久化對話執行緒、工具呼叫或檢索增強生成時使用。適合希望在無須自行管理 LLM 金鑰的情況下呼叫模型的 Convex Cloud 專案。
執行需求
AI Gateway 需要 Convex Cloud 付費方案上的 Convex 1.45+;需要 @convex-dev/agent 與 @convex-dev/ai-sdk-provider 套件;RAG 需要將嵌入供應商金鑰存入 Convex 環境;閘道無法使用時需要將供應商金鑰存入 Convex 環境。僅含指示,無指令碼。
<!-- GENERATED from convex-agents content/capabilities/agent.json — do not edit by hand. -->

Add an AI agent / RAG backend

Install @convex-dev/agent for durable threads, message history, tool-calls, and vector search/RAG — the backend for an in-app AI agent. Call models through the Convex AI Gateway by default: Convex holds the provider credentials, so there is no LLM key to obtain, store, or rotate.

Workflow

  1. Install @convex-dev/agent + @convex-dev/ai-sdk-provider; add the agent component to convex.config.ts.
  2. Define the agent (tools, instructions) with languageModel: convexGateway("provider/model") — no API key needed (needs convex 1.45+ on a Convex Cloud deployment, paid plan).
  3. Create threads + stream messages; persist history in Convex.
  4. For RAG: embed docs into a vector index and retrieve in the tool. The gateway does not serve embeddings yet, so store the embedding provider's key via the env micro power.
  5. Only if the gateway is unavailable (free plan, self-hosted, local backend): call the provider SDK with a key stored via the env micro power.

Rules

  • Default to the Convex AI Gateway (convexGateway from @convex-dev/ai-sdk-provider) for model calls; fall back to a provider key in Convex env only where the gateway is unavailable (free plan, self-hosted, local backend).
  • Never expose a provider API key client-side; when one is needed (embeddings, gateway fallback), keep it in Convex env via the env micro power.
  • Run model calls in actions ('use node' if the SDK needs it).
  • Persist threads/messages in Convex for durability + reactivity.

來源與署名

來源:get-convex/agent-skills位於skills/convex-agent提交2cfe645

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架