Instructions
Create and manage instructions that guide agent behavior. The agent uses these instructions alongside information from a conversation session to determine how to respond to user input, including which tools to use.
Instructions in Vectara are referred to system prompts in other LLM APIs (such as Gemini, Mistral, and OpenAI). If you are familiar with system prompts terminology, instructions serve a similar purpose. Instructions define the role, behavior, and guidelines of an agent before any user interaction begins.
Templating
Instructions use the Apache Velocity templating engine, which enables you to dynamically insert variables into your prompts, using the tools context and the metadata context. The available context variables include:
Tools
$tools is a list of tools available to the agent. You can iterate over tools
to display their names and descriptions in your instructions.
Example usage in templates:
You have access to the following tools:
#foreach($tool in $tools)
- ${tool.name}: ${tool.description}
#end
Metadata
Instructions can access metadata from both sessions and agents, enabling personalized and context-aware behavior:
${session.metadata.field}: Access session-specific metadata (user context, permissions, preferences).${agent.metadata.field}: Access agent-level metadata (version, configuration, environment).
Session metadata examples
Consider the following session metadata examples:
Access Control & Security
user_role(admin, manager, employee): Filter search results by permission level.tenant_id(company123): Isolate data in multi-tenant systems.department(legal, sales, engineering): Show only relevant documents.clearance_level(public, confidential): Enforce document access policies.data_classification(internal, external): Control what information can be shared.
Personalization
language(en, es, fr): Respond in user's preferred language.timezone(America/New_York): Schedule meetings, show local times.subscription_tier(free, pro, enterprise): Enable/disable features.user_preference(brief, detailed): Adjust response verbosity.region(EMEA, APAC, Americas): Show region-specific content, pricing, compliance.
Business Context
customer_id(cust_789): Pull customer-specific orders, support history.account_type(trial, paid, enterprise): Customize onboarding experience.industry(healthcare, finance): Use industry-specific terminology.product_owned(basic, premium): Provide relevant help documentation.contract_type(annual, monthly, perpetual): Tailor renewal reminders.
Workflow & Routing
support_tier(L1, L2, escalated): Route to appropriate knowledge base.conversation_type(sales, support, onboarding): Apply different tones and approaches.agent_purpose(billing, technical, general): Focus search on relevant corpora.escalation_needed(true/false): Track when to hand off to human.channel(web, mobile, API, voice): Adjust response format and length.
Metadata usage example
"template": "Hello! I see you're ${session.metadata.user_name} from ${session.metadata.region}. I'm here to help you with ${session.metadata.department} inquiries."
When a session is created with this metadata:
{
"metadata": {
"user_name": "John Doe",
"region": "NA",
"department": "billing"
}
}
The instruction renders as:
"Hello! I see you're John Doe from North America. I'm here to help you with billing inquiries."
📄️ Create instruction
Create a new instruction that can guide agent behavior.
📄️ List instructions
List all instructions available to the authenticated user, with optional filtering and pagination.
📄️ Get instruction
Retrieve the details of a specific instruction by its ID, including its template and configuration.
📄️ Update instruction
Update an existing instruction's template, metadata, and configuration.
📄️ Delete instruction
Permanently delete an instruction and all its associated configuration. This action cannot be undone.
📄️ Test instruction
Test an instruction by rendering its template with provided context data and tools.
📄️ Delete instruction version
Permanently delete the specified version of the instruction. This action cannot be undone.