LLM Agent Block
What it does: Create intelligent AI agents that can use custom tools, call APIs, and execute functions to accomplish complex tasks autonomously.
In simple terms: An LLM Agent is like giving AI hands and tools. Instead of just answering questions, it can actually DO things - call APIs, run custom code, fetch data, and make decisions about which tools to use.
When to Use This
Use LLM Agent when you need:
- ✅ AI that can take actions, not just respond
- ✅ Integration with external APIs and services
- ✅ Custom business logic executed by AI
- ✅ Multi-step problem solving with tools
- ✅ Dynamic function calling based on user intent
Example: Build an AI assistant that can check weather APIs, query your database, book appointments, send emails, and more - all by understanding natural language requests.
Key Features
- Tool Calling: AI decides which tools to use and when
- Custom Functions: Write JavaScript code the AI can execute
- API Integration: Connect to any REST API automatically
- Multi-Step Reasoning: Agent can use multiple tools to solve complex problems
- Autonomous Operation: AI chooses the best approach
- Groq-Powered: Ultra-fast inference with Groq's LPU technology
Setup Guide
Step 1: Basic Configuration
-
Agent: Select "Groq" as your LLM provider
- Currently supports Groq for fast inference
- Uses llama-3.3-70b-versatile model
-
Secret Key: Enter your Groq API key
- Get it from console.groq.com (opens in a new tab)
- Stored securely, never exposed
-
System Prompt: Define the agent's behavior `` ` You are a helpful AI assistant with access to tools. Use the available tools to help users accomplish their tasks. Always explain what you're doing.
-
User Query: The question or task from the user
- Use variables:
{{user_message}} - Can be complex requests requiring multiple steps
- Use variables:
Step 2: Enable Custom Tools (Optional)
Turn on "Enable Custom Tools" to let your agent execute custom JavaScript functions.
Custom Tool Configuration:
- Name: Function name (e.g., "calculateDiscount")
- Description: Explain what the tool does (helps AI know when to use it)
- Custom Variables: Define inputs
- Input Variable: Parameter name
- Input Type: boolean, number, or string
- Input Description: What this parameter is for
- Function Code: Write the JavaScript function
Example - Calculate Discount Tool:
// Name: calculateDiscount
// Description: Calculates the discounted price given original price and discount percentage
// Custom Variables:
// - originalPrice (number): The original price
// - discountPercent (number): The discount percentage (0-100)
// Function code:
async (input) => {
const discounted = input.originalPrice * (1 - input.discountPercent / 100);
return `The discounted price is $${discounted.toFixed(2)}`;
}Example - Format Date Tool:
// Name: formatDate
// Description: Formats a date string into a readable format
// Custom Variables:
// - dateString (string): The date to format
// - format (string): Desired format (e.g., "full", "short")
// Function code:
async (input) => {
const date = new Date(input.dateString);
if (input.format === "full") {
return date.toLocaleDateString('en-US', {
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric'
});
}
return date.toLocaleDateString();
}Step 3: Enable API Tools (Optional)
Turn on "Enable API Tools" to let your agent call external APIs.
API Configuration:
- API Name: Descriptive name for the endpoint
- Method: GET, POST, PUT, or DELETE
- Description: Explain what this API does (helps AI know when to use it)
- URL: The API endpoint
- Headers: JSON object with headers (e.g., authentication)
- Parameters: Define URL path parameters, query parameters, or body schema
Example - Weather API:
// API Name: getWeather
// Method: GET
// Description: Get current weather for a city
// URL: https://api.weather.com/v1/current
// Headers: { "X-API-Key": "your-api-key" }
// Query Parameters:
// - city (string): The city name
// - units (string): Temperature units (metric or imperial)Example - Create User API:
// API Name: createUser
// Method: POST
// Description: Create a new user account
// URL: https://api.yourservice.com/users
// Headers: { "Authorization": "Bearer YOUR_TOKEN", "Content-Type": "application/json" }
// Body Schema:
{
"name": { "type": "string", "description": "User's full name" },
"email": { "type": "string", "description": "User's email address" },
"role": { "type": "string", "description": "User role (admin, user, etc.)" }
}Step 4: Response Mapping
Save the agent's final response to a workflow variable for later use.
How It Works
The LLM Agent operates autonomously:
-
Receives User Query: "What's the weather in Paris and how much is $100 with 20% discount?"
-
Analyzes Available Tools:
- calculateDiscount (custom tool)
- getWeather (API tool)
-
Plans Approach:
- Need to call getWeather API for Paris
- Need to call calculateDiscount with 100 and 20
-
Executes Tools:
- Calls getWeather("Paris", "metric")
- Calls calculateDiscount(100, 20)
-
Synthesizes Response:
- "The weather in Paris is partly cloudy, 15°C. And 80.00."
Common Use Cases
Customer Service Agent
Agent with access to order tracking and knowledge base:
Configuration:
- Agent: Groq
- System Prompt:
You are a customer service agent. Help customers with their inquiries using available tools to look up information. Be friendly and professional. - Custom Tool - Check Order Status:
async (input) => { // Call your order system const order = await fetch(`https://api.yourstore.com/orders/${input.orderId}`); const data = await order.json(); return `Order ${input.orderId}: ${data.status}. Expected delivery: ${data.deliveryDate}`; } - User Query:
{{customer_message}}
Example Interaction:
- User: "Where's my order #12345?"
- Agent: Uses checkOrderStatus tool
- Agent: "Your order #12345 is currently in transit. Expected delivery is March 15, 2024."
Data Analysis Assistant
Agent that can query databases and calculate metrics:
Configuration:
- API Tool - Query Database:
- GET https://api.yourdb.com/query (opens in a new tab)
- Query parameters: table, filters, limit
- Custom Tool - Calculate Average:
async (input) => { const numbers = JSON.parse(input.numbers); const avg = numbers.reduce((a, b) => a + b, 0) / numbers.length; return `The average is ${avg.toFixed(2)}`; } - User Query: "Get average revenue from last month's sales"
Appointment Booking Agent
Automated scheduling with calendar integration:
Configuration:
- API Tool - Check availability:
GET /calendar/available-slots
- API Tool - Book Appointment:
POST /calendar/book- Body: date, time, customerName, service
- User Query: "I need a haircut appointment next Tuesday afternoon"
Agent Actions:
- Checks available slots for next Tuesday afternoon
- Presents options to user
- Books selected time slot
- Confirms booking
E-commerce Assistant
Help customers find products and place orders:
Configuration:
- API Tool - Search Products:
GET /products/search?q={{query}}&category={{category}}- Custom Tool - Format Product Info:
async (input) => { const product = JSON.parse(input.productData); return `${product.name} - $${product.price}\n${product.description}\n In stock: ${product.inStock ? 'Yes' : 'No'}`; } - API Tool - Add to Cart:
POST /cart/add
- User Query: "Show me wireless headphones under $100"
System Monitoring Agent
Monitor and report on system status:
Configuration:
- API Tool - Server Status:
GET /monitoring/servers
- API Tool - Alert Count:
GET /monitoring/alerts
- Custom Tool - Format Report:
async (input) => { const data = JSON.parse(input.monitoringData); let report = `System Status Report:\n`; report += `Active Servers: ${data.activeServers}\n`; report += `CPU Usage: ${data.avgCpu}%\n`; report += `Active Alerts: ${data.alertCount}\n`; return report; } - User Query: "Give me a system status report"
Advanced Configuration
Custom Tool Best Practices
1. Clear Descriptions:
// Good
"Calculates shipping cost based on weight, distance, and service level"
// Bad
"Calculates something"2. Type Safety:
// Define input types
{
inputVariable: "weight",
inputType: "number",
inputDescription: "Package weight in pounds"
}3. Error Handling:
async (input) => {
try {
const result = await someOperation(input);
return `Success: ${result}`;
} catch (error) {
return `Error: ${error.message}`;
}
}4. Return Strings:
// Always return strings
async (input) => {
const number = input.a + input.b;
return String(number); // Convert to string
}API Tool Best Practices
1. Descriptive Names:
- Use: "getUserProfile", "searchProducts", "bookAppointment"
- Avoid: "api1", "endpoint", "call"
2. Complete Descriptions:
// Good
"Searches the product catalog by keyword, category, and price range. Returns matching products with name, price, and availability."
// Bad
"Searches products"3. Secure Headers:
{
"Authorization": "Bearer {{api_token}}",
"Content-Type": "application/json"
}4. Define All Parameters:
- Path parameters: Replace in URL with
{paramName} - Query parameters: Add as query params array
- Body schema: Define complete schema for POST/PUT
System Prompt Guidelines
Be Specific:
You are a technical support agent specializing in software troubleshooting.
When users describe issues:
1. Ask clarifying questions if needed
2. Use diagnostic tools to check system status
3. Provide step-by-step solutions
4. Confirm the issue is resolvedSet Boundaries:
You can help with: product information, order tracking, returns, and account issues.
You cannot: process refunds directly (escalate to human), access payment details, or make policy exceptions.Define Tool Usage:
You have access to:
- orderLookup: To check order status
- inventoryCheck: To verify product availability
- customerHistory: To see past interactions
Use these tools proactively to provide accurate information.What You Get Back
After the agent completes:
- Agent Response: The final answer after using all necessary tools
- Tool Calls: Information about which tools were used
- Execution Log: Step-by-step process (for debugging)
Tips for Success
- Start Simple - Begin with one or two tools, add more as needed
- Test Tools Individually - Verify each tool works before combining
- Write Clear Descriptions - The AI relies on these to choose tools
- Use Descriptive Names - Both for tools and variables
- Handle Errors Gracefully - Tools should return helpful error messages
- Monitor API Costs - Each tool call uses tokens and may call external APIs
- Limit Tool Complexity - Simple, focused tools work better than complex ones
- Provide Examples in System Prompt - Show the agent how to use tools
Troubleshooting
| Problem | Likely Cause | Solution |
|---|---|---|
| Agent doesn't use tools | Poor tool descriptions | Make descriptions more specific and clear |
| Tool execution fails | Incorrect parameters | Check parameter types and requirements |
| API calls fail | Wrong headers or URL | Verify API configuration and authentication |
| Slow responses | Too many tools | Reduce number of tools or optimize code |
| Wrong tool selected | Ambiguous descriptions | Clarify when each tool should be used |
| Function errors | JavaScript syntax issues | Test function code separately first |
Best Practices
- Design Atomic Tools - Each tool should do one thing well
- Provide Context - Include relevant information in system prompt
- Test Edge Cases - What if API is down? Empty results?
- Use Meaningful Variable Names - "customerEmail" not "input1"
- Document Tool Behavior - Explain what tool returns
- Implement Retry Logic - Handle transient failures
- Log Tool Usage - Track which tools are used most
- Optimize for Speed - Tools add latency, keep them fast
Security Considerations
- Never expose API keys in tool code - Use secure credential storage
- Validate inputs - Check parameters before executing
- Limit tool permissions - Give tools only necessary access
- Sanitize outputs - Don't return sensitive data
- Rate limit tool usage - Prevent abuse
- Audit tool calls - Log all executions for security review
Performance Tips
- Cache API responses - Avoid redundant calls
- Minimize tool count - Only include necessary tools
- Optimize tool code - Keep functions fast and simple
- Use appropriate models - Groq's fast inference helps
- Batch operations - Combine related API calls when possible
This powerful block enables you to create sophisticated AI agents that can interact with your entire technology stack!