AI Agents
Build and deploy autonomous AI agents with tool calling, multi-agent orchestration, and MCP server integration.
Overview
Tenzro Agents provide a complete framework for building AI agents that can:
- Use tools to interact with external systems
- Connect to MCP servers for extended capabilities
- Orchestrate multiple sub-agents for complex tasks
- Maintain conversation history and context
- Execute workflows and trigger actions
Quick Start
import { Tenzro } from 'tenzro';const tenzro = new Tenzro({ apiKey: 'your-api-key' });// Create an agentconst agent = await tenzro.agents.create({projectId: 'project-id',agentName: 'customer-support',agentDescription: 'AI customer support agent',aiModel: 'gemini-2.5-flash',systemPrompt: `You are a helpful customer support agent.Be polite, concise, and helpful in resolving customer issues.`,orchestrationPattern: 'SINGLE',});// Chat with the agentconst response = await tenzro.agents.chat(agent.agent_id, {message: 'I need help with my order',conversationId: 'conv-123', // Optional: for conversation continuity});console.log(response.response); // Agent's responseconsole.log(response.toolCalls); // Any tools the agent used
Agent Configuration
Orchestration Patterns
| Pattern | Description | Use Case |
|---|---|---|
SINGLE | Single agent, no sub-agents | Simple tasks, chatbots |
SEQUENTIAL | Sub-agents execute in order | Pipelines, step-by-step workflows |
PARALLEL | Sub-agents execute concurrently | Independent tasks, aggregation |
HIERARCHICAL | Manager delegates to specialists | Complex multi-domain tasks |
SDK Reference
Create Agent
const agent = await tenzro.agents.create({projectId: string,agentName: string,agentDescription?: string,aiProvider?: 'google', // Default: 'google'aiModel?: AIModel, // Default: 'gemini-2.5-flash'systemPrompt?: string,orchestrationPattern?: 'SINGLE' | 'SEQUENTIAL' | 'PARALLEL' | 'HIERARCHICAL',mcpServerIds?: string[], // Connected MCP serverssubagentIds?: string[], // Sub-agents for orchestrationcustomTools?: Tool[], // Custom tool definitions});
Chat
Simplified chat interface with conversation history:
const response = await tenzro.agents.chat(agentId, {message: string, // User messageconversationId?: string, // For conversation continuitycontext?: Record<string, any>, // Additional context});// Response type:interface ChatResponse {success: boolean;response: string; // Agent's text responseconversationId: string; // Use for follow-up messagesexecutionId: string;usage: {inputTokens: number;outputTokens: number;thinkingTokens: number;totalTokens: number;};toolCalls?: ToolCall[];latencyMs: number;}
Query
Single-turn query without conversation state:
const response = await tenzro.agents.query(agentId, {query: string,context?: Record<string, any>,});// Response includes structured data if availableinterface QueryResponse {success: boolean;result: string;data?: any; // Structured output if agent returns JSONexecutionId: string;toolCalls?: ToolCall[];usage: TokenUsage;latencyMs: number;}
Execute
Full execution with complete control:
const execution = await tenzro.agents.execute(agentId, {message: string,context?: Record<string, any>,conversationId?: string,messageHistory?: Message[], // Provide custom historystream?: boolean, // Enable streaming});
Lifecycle Management
// Activate agent (make it executable)await tenzro.agents.activate(agentId);// Pause agent (disable execution)await tenzro.agents.pause(agentId);// Update agent configurationawait tenzro.agents.update(agentId, {systemPrompt: 'Updated system prompt',aiModel: 'gemini-2.5-pro',});// Delete agentawait tenzro.agents.delete(agentId);
Get Agent Tools
const { tools, customToolCount, mcpToolCount, mcpServers } =await tenzro.agents.getTools(agentId);// tools: Array of available tools with schemas
Execution History
// Get all executionsconst { executions } = await tenzro.agents.getExecutions(agentId, {limit: 50,offset: 0,});// Get specific execution detailsconst execution = await tenzro.agents.getExecution(agentId, executionId);
Custom Tools
Define custom tools that agents can call:
const agent = await tenzro.agents.create({projectId: 'project-id',agentName: 'sales-agent',aiModel: 'gemini-2.5-flash',customTools: [{name: 'check_inventory',description: 'Check product inventory levels',inputSchema: {type: 'object',properties: {productId: { type: 'string', description: 'Product ID to check' },},required: ['productId'],},},{name: 'create_order',description: 'Create a new order for a customer',inputSchema: {type: 'object',properties: {customerId: { type: 'string' },products: {type: 'array',items: {type: 'object',properties: {productId: { type: 'string' },quantity: { type: 'number' },},},},},required: ['customerId', 'products'],},},],});
Multi-Agent Orchestration
Hierarchical Pattern
// Create specialist agentsconst researchAgent = await tenzro.agents.create({projectId: 'project-id',agentName: 'researcher',systemPrompt: 'You are a research specialist. Find relevant information.',orchestrationPattern: 'SINGLE',});const writerAgent = await tenzro.agents.create({projectId: 'project-id',agentName: 'writer',systemPrompt: 'You are a content writer. Create engaging content.',orchestrationPattern: 'SINGLE',});// Create manager agent with sub-agentsconst managerAgent = await tenzro.agents.create({projectId: 'project-id',agentName: 'content-manager',systemPrompt: `You are a content manager. Delegate research to the researcherand writing to the writer. Coordinate their work to produce final content.`,orchestrationPattern: 'HIERARCHICAL',subagentIds: [researchAgent.agent_id, writerAgent.agent_id],});// The manager will automatically delegate to sub-agentsconst result = await tenzro.agents.chat(managerAgent.agent_id, {message: 'Write a blog post about AI trends in 2025',});
Connecting MCP Servers
// First, deploy an MCP serverconst server = await tenzro.servers.create({projectId: 'project-id',deploymentName: 'database-tools',aiModel: 'gemini-2.5-flash',dataSourceType: 'data',dataSourceId: 'your-database-id',});// Connect to the agentawait tenzro.agents.update(agentId, {mcpServerIds: [server.deployment_id],});// Now the agent can use database toolsconst response = await tenzro.agents.chat(agentId, {message: 'How many users signed up last week?',});// Agent will query the database via MCP server
React Integration
import { useAgent } from '@tenzro/react';function ChatComponent() {const {messages,send,loading,reset,conversationId,} = useAgent({agentId: 'agent-id',onToolCall: (tool, args) => {console.log('Agent called tool:', tool, args);},});return (<div>{messages.map((msg) => (<div key={msg.id} className={msg.role}>{msg.content}</div>))}<input onKeyPress={(e) => e.key === 'Enter' && send(e.target.value)} /></div>);}
Best Practices
- Clear system prompts: Define agent role, capabilities, and constraints clearly
- Use conversation IDs: Maintain context across multiple messages
- Tool schemas: Provide detailed descriptions for tools to guide the model
- Error handling: Handle tool failures gracefully in your application
- Monitor usage: Track token usage and costs with getStats()
Limits
| Resource | Limit |
|---|---|
| Max sub-agents | 10 |
| Max custom tools | 50 |
| Max MCP servers | 10 |
| Conversation history | 100 messages |
| Execution timeout | 5 minutes |