#convex agent
3 messages · Page 1 of 1 (latest)
If you’re using Convex’s Agent component, you can give the LLM “instructions” (a system prompt) when you define the agent. This controls its tone and behavior.
- Basic setup with instructions:
import { Agent } from "@convex-dev/agent";
import { openai } from "@ai-sdk/openai";
import { components } from "./_generated/api";
const supportAgent = new Agent(components.agent, {
name: "Support Agent",
languageModel: openai.chat("gpt-4o-mini"),
instructions: "You are a helpful assistant. Answer concisely and cite sources when possible.",
});
(“instructions” is the system prompt; you can customize it to match the style you want) (Agents > Getting Started).
-
You can also supply per-call options, including custom context behavior, when generating messages. The Agent will automatically include prior message history and supports hybrid search; you can tweak what context is pulled in via contextOptions if needed (LLM Context).
-
For richer setups (tools, retries, usage tracking), you can define defaults once and override at call time. Example shows configurable instructions and tools, plus provider options (Agents > Getting Started).
If you’re looking for a reusable “instruction set” for coding with Convex (not chat style), Convex provides editor-specific rules/guidelines you can add to your project (e.g., Cursor rules, Copilot instructions) so agents write Convex code correctly. Install:
- Cursor rules: add the Convex rules file to .cursor/rules (Using Cursor with Convex).
- GitHub Copilot instructions: add convex.instructions.md to .github/instructions (Using GitHub Copilot).