Appearance
Agent Script Recipes
A comprehensive collection of recipes for learning Agent Script - from basic concepts to production-ready patterns.
What are Agent Script Recipes?
Recipes are standalone, working examples that teach specific Agent Script concepts.
Think of these as cookbooks for building agents - each recipe focuses on one concept you can learn, adapt, and apply to your own agents.
How to Use These Recipes
For Beginners
Start with Language Essentials in order:
- HelloWorld - Understand the basic structure
- VariableManagement - Work with state
- TemplateExpressions - Create dynamic content
- LanguageSettings - Configure language support
- SystemInstructionOverrides - Customize per-topic behavior
For Intermediate Users
Jump to specific recipes based on what you need:
- Need to call external systems? → ActionDefinitions
- Building Q&A agents? → SimpleQA
- Working with multiple topics? → MultiTopicNavigation
- Processing action results? → ActionCallbacks
- Filtering actions conditionally? → ActionDescriptionOverrides
For Advanced Users
Explore production patterns and real-world use cases:
- BeforeAfterReasoning - Lifecycle event handling
- BidirectionalNavigation - Specialist consultation patterns
- ExternalAPIIntegration - API patterns
- ErrorHandling - Validation and safety
Recipe Catalog
Getting Started
| Recipe | Concept | What You'll Learn |
|---|---|---|
| HelloWorld | Basic agent structure | config, system, start_agent, topic blocks and minimal agent anatomy |
Language Essentials
Core building blocks every Agent Script developer should know.
| Recipe | Concept | What You'll Learn |
|---|---|---|
| HelloWorld | Basic agent structure | config, system, start_agent, topic blocks |
| VariableManagement | State management | All variable types, mutable vs linked, @variables syntax |
| TemplateExpressions | Dynamic content | {!} syntax, conditionals, personalization, calculations |
| LanguageSettings | Locale configuration | Multi-language support, default_locale, additional_locales |
| SystemInstructionOverrides | Topic customization | Per-topic system prompts, persona switching |
Action Configuration
Patterns for defining and using actions.
| Recipe | Concept | What You'll Learn |
|---|---|---|
| ActionDefinitions | External integrations | Action structure, inputs/outputs, flow:// and apex:// targets |
| ActionCallbacks | Post-action hooks | run keyword, chaining actions, processing results |
| AdvancedInputBindings | Action inputs | Fixed vs bound vs LLM-filled (...) parameters |
| ActionDescriptionOverrides | Contextual actions | Context-specific descriptions, expertise-based variations |
Architectural Patterns
Building sophisticated multi-topic agents.
| Recipe | Concept | What You'll Learn |
|---|---|---|
| SimpleQA | Q&A with actions | Single-topic pattern, focused agent design, action integration |
| MultiTopicNavigation | Topic transitions | Multiple topics, @utils.transition, workflow orchestration |
| BidirectionalNavigation | Specialist consultation | Route to specialist topics and return, state sharing |
| ErrorHandling | Validation & safety | Guard clauses, validation patterns, available when |
| ExternalAPIIntegration | API patterns | Flow and Apex targets, response handling, error tracking |
Reasoning Mechanics
Advanced reasoning and lifecycle patterns.
| Recipe | Concept | What You'll Learn |
|---|---|---|
| ReasoningInstructions | Procedural instructions | instructions:->, dynamic instruction building, run actions |
| BeforeAfterReasoning | Lifecycle events | before_reasoning, after_reasoning hooks |
Recipe Structure
Each recipe follows a consistent structure:
- Overview - What this recipe teaches
- Agent Flow - Visual diagram of the agent's behavior
- Key Concepts - Bullet point summary
- How It Works - Detailed explanations with code examples
- Key Code Snippets - Highlighted important patterns
- Try It Out - Example conversations showing the agent in action
- What's Next - Related recipes to explore
Learning Paths
Path 1: Building Your First Agent
- HelloWorld → VariableManagement → ActionDefinitions → SimpleQA
- Goal: Create a basic functional agent
- Time: 2-3 hours
- Outcome: Understand core Agent Script syntax
Path 2: Dynamic & Interactive Agents
- TemplateExpressions → ReasoningInstructions → SystemInstructionOverrides
- Goal: Build agents that adapt to context
- Time: 3-4 hours
- Outcome: Create personalized, context-aware experiences
Path 3: Multi-Topic Workflows
- MultiTopicNavigation → BidirectionalNavigation
- Goal: Design complex conversation flows
- Time: 3-4 hours
- Outcome: Handle sophisticated multi-step processes
Path 4: Production-Ready Agents
- ErrorHandling → ActionCallbacks → ExternalAPIIntegration
- Goal: Build reliable, enterprise-grade agents
- Time: 4-5 hours
- Outcome: Deploy agents with confidence
Quick Reference
Common Patterns
Accessing Variables
agentscript
{!@variables.variable_name} # In templates
@variables.variable_name # In expressions
set @variables.variable_name = value # Setting valuesCalling Actions
agentscript
run @actions.action_name # In procedures
with param=value
set @variables.result = @outputs.fieldTopic Transitions
agentscript
transition to @topic.topic_name # In procedures
@utils.transition with target=@topic.name # As actionConditionals
agentscript
if @variables.condition: # In procedures
| Instructions for true case
else:
| Instructions for false caseKey Syntax Elements
| Element | Usage | Example |
|---|---|---|
config: | Agent metadata | agent_name: "MyAgent" |
system: | Global settings | instructions: "You are..." |
variables: | State declaration | name: mutable string = "" |
topic name: | Define topic | topic greeting: |
actions: | Define external tools | get_data: ... |
reasoning: | Topic behavior | instructions: "Help user..." |
-> | Procedure | instructions:-> |
| | Multiline string | | Line 1 |
{!} | Template expression | {!@variables.name} |
@ | Resource access | @variables, @actions, @topic |
run | Call action | run @actions.name |
set | Set variable | set @variables.x = 1 |
with | Bind input | with param=value |
... | LLM slot-fill | with param=... |
if/else | Conditional | if @variables.x > 0: |
transition to | Change topic | transition to @topic.next |
Contributing
These recipes are designed to help developers learn Agent Script through practical examples. Each recipe:
- Is standalone - Can be understood without reading others
- Is functional - Includes working, deployable code
- Teaches one concept - Focused on a specific learning objective
- Follows patterns - Demonstrates idiomatic Agent Script
- Is well-documented - Explains the "why" not just the "what"
Quick Start
- Clone the repository
- Browse recipes by category (Language Essentials → Action Configuration → Architectural Patterns → Reasoning Mechanics)
- Read the documentation for each recipe to understand concepts
- Study the
.agentfile to see patterns in action - Adapt and experiment - modify recipes for your use cases
- Deploy and test using the included
.bundle-meta.xmlfiles
Ready to start? Begin with HelloWorld to understand the basics, then progress through the recipes at your own pace!