Skip to main content

What’s an Agent?

Think of agents as your smart AI assistants that can handle complex tasks, remember conversations, and even work with other agents. They’re not just chatbots - they’re intelligent systems that can analyze data, make decisions, and take actions.

Smart & Contextual

Remembers conversations, understands context, and learns from interactions

Tool-Powered

Uses custom tools to access databases, APIs, and perform real actions

Multi-Model Support

Works with OpenAI, Anthropic Claude, and Google Gemini models

Team Players

Agents can delegate tasks to other specialized agents

Vector Memory

Built-in semantic search and RAG capabilities with public API access

Testing Friendly

Public methods make testing and experimentation a breeze

Creating Your First Agent

Ready to build your first AI agent? It’s easier than you think! Let’s create a helpful customer support agent that can answer questions and solve problems.

Quick Start with Artisan

Fire up your terminal and run this magical command:
Terminal
Boom! You’ve just created your first agent! Let’s peek inside and see what makes it tick:

The Agent Blueprint

app/Agents/CustomerSupportAgent.php

Agent Configuration Options

Unleashing Your Agent’s Powers

Now comes the fun part - putting your agent to work! Vizra ADK gives you a powerful and simple way to interact with your agents.
One Method to Rule Them All - The run() method is your gateway to agent intelligence. Simple, powerful, and flexible - it handles everything from conversations to complex data processing.

Let’s Chat! Using the Fluent API

Working with agents feels natural with our fluent API. Check out these examples:

Real-time Magic with Streaming

Want to see your agent think in real-time? Enable streaming for that ChatGPT-like experience:

Managing Conversation History

Important: All messages are always saved to the database for session continuity. These settings only control what previous messages are sent to the LLM for context.
By default, agents don’t send conversation history to the LLM (for better performance and lower costs). But for chat agents, you’ll want context! Here’s how to control what history gets sent to the LLM:

Customizing Agent Behavior

Want to add your own special sauce? Agents come with powerful lifecycle hooks that let you customize exactly how they work. It’s like having backstage passes to your agent’s brain!

Available Hooks

  • beforeLlmCall - Tweak messages before they hit the AI
  • afterLlmResponse - Process AI responses your way
  • beforeToolCall - Modify tool inputs on the fly
  • afterToolResult - Transform tool outputs
  • onToolException - Handle tool execution errors
Here’s how to use these superpowers:

Dynamic Prompts

Want to test different personalities without changing code? Prompt versioning lets you A/B test, switch between tones, and evolve your agent’s voice on the fly!
Switch Prompts at Runtime - No more hardcoding prompts! Store different versions and switch between them instantly.
Store prompts as .md files in resources/prompts/{agent_name}/ for easy version control! Learn more about Dynamic Prompts

Dynamic Prompts with Blade Templates

Create dynamic, context-aware prompts using Laravel’s Blade templating engine. Your prompts can adapt based on user data, session state, and custom variables.

Quick Example

Save your prompt as .blade.php to enable dynamic content:
resources/prompts/agent_name/default.blade.php

Adding Custom Variables

Inject your own data by implementing getPromptData() in your agent:
Then use them in your template:
Learn more about Blade Templates & Advanced Features

SubAgents: Building Agent Teams

Why have one agent when you can have a whole team? SubAgents let you create specialized agents that work together, with a manager agent delegating tasks to the right specialist. Think of it as building your own AI company!

What Are SubAgents?

SubAgents are specialized agents that a parent agent can delegate tasks to. When you define subAgents on an agent, Vizra ADK automatically adds the DelegateToSubAgentTool - allowing your manager agent to intelligently route requests to the right specialist.

How SubAgent Delegation Works

When a user asks a question, the manager agent decides whether to handle it directly or delegate:

Creating Specialized SubAgents

Each subAgent should be focused on a specific domain:
Pro Tip: Write clear description properties on your subAgents - the manager agent uses these to decide which specialist to delegate to!

SubAgent Benefits

Separation of Concerns

Each agent focuses on what it does best

Specialized Tools

SubAgents can have their own unique tools

Different Models

Use GPT-4 for complex tasks, GPT-3.5 for simple ones

Easier Testing

Test each specialist agent independently

Advanced Agent Techniques

Ready to level up? Here are some pro tips and advanced features that’ll make your agents work harder and smarter!

Vector Memory & RAG

Give your agents superpowers with built-in semantic search and knowledge retrieval! Perfect for building documentation assistants, knowledge bases, and intelligent Q&A systems.
Agent with Vector Memory
Vector Memory Pro Tips
  • Use progressive API: simple strings for prototypes, arrays for production
  • Public methods make testing in Tinkerwell super easy
  • Organize with namespaces: ‘docs’, ‘faqs’, ‘policies’, etc.
  • Perfect for building chatbots that remember context

Background Processing with Async

Got heavy lifting to do? Send your agents to work in the background:

Vision & Multimodal Magic

Your agents aren’t just text wizards - they have eyes too! Send images, documents, and watch the magic happen:

Fine-Tune on the Fly

Need more creativity? Want faster responses? Override any parameter at runtime:

Memory That Actually Remembers

Unlike that friend who forgets your birthday every year, your agents have perfect memory! They remember everything important about your conversations and context.

Conversation History

Every message in the session

Tool Results

What tools did and returned

User Context

Who they’re talking to

Custom Data

Any context you provide

Understanding the Agent Lifecycle

When you ask an agent to do something, it goes through a carefully orchestrated lifecycle. Understanding this flow helps you build more powerful agents and debug issues faster!

The Request Journey

Lifecycle Hooks - Your Power Points

Agents provide strategic hooks where you can intercept and modify behavior. These are your control points for customization:

beforeLlmCall() - Pre-Processing

Called before sending messages to the AI. Perfect for adding context, filtering messages, or injecting system prompts.

afterLlmResponse() - Post-Processing

Called after receiving the AI’s response. Transform responses, extract insights, or trigger side effects. Now includes the original request for complete logging.

Tool Execution Hooks

Control tool execution with beforeToolCall() and afterToolResult() hooks.

Lifecycle Events

As your agent works, it broadcasts events you can listen to for monitoring, logging, or triggering other actions:

Pro Tips from the Trenches

Want to build agents that users actually love? Here’s the wisdom we’ve gathered from building hundreds of agents:

Crystal Clear Instructions

Write instructions like you’re explaining to a smart friend. Be specific about what you want!

Right Model for the Job

GPT-4 for complex reasoning, GPT-3.5 for quick tasks. Don’t use a Ferrari to go to the corner store!

Hook Into Everything

Use lifecycle hooks for debugging and monitoring. You’ll thank yourself later!

Delegate Like a Boss

Complex workflows? Use sub-agents! Let specialists handle what they do best.

Stream for the Win

Enable streaming for long responses. Users love seeing agents “think” in real-time!

Ready to Build Something Amazing?

You’ve got the knowledge, now let’s put it to work!

Power Up with Tools

Give your agents superpowers with custom tools

Deep Dive API Docs

Every method, property, and secret revealed