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/cloud';const client = new Tenzro({ apiKey: 'your-api-key' });// Create an agentconst agent = await client.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',});// Activate the agentawait client.agents.activate(agent.agent_id);// Chat with the agentconst response = await client.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 client.agents.create({projectId: string,agentName: string,agentDescription?: string,aiProvider?: 'google' | 'openai' | 'anthropic', // Default: 'google'aiModel?: string, // 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 client.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 client.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 client.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 client.agents.activate(agentId);// Pause agent (disable execution)await client.agents.pause(agentId);// Update agent configurationawait client.agents.update(agentId, {systemPrompt: 'Updated system prompt',aiModel: 'gemini-2.5-pro',});// Delete agentawait client.agents.delete(agentId);
Get Agent Tools
const { tools, customToolCount, mcpToolCount, mcpServers } =await client.agents.getTools(agentId);// tools: Array of available tools with schemas
Execution History
// Get all executionsconst { executions } = await client.agents.getExecutions(agentId, {limit: 50,offset: 0,});// Get specific execution detailsconst execution = await client.agents.getExecution(agentId, executionId);
Custom Tools
Define custom tools that agents can call using the tool helper:
import { Tenzro, tool } from '@tenzro/cloud';const client = new Tenzro({ apiKey: 'your-api-key' });// Define tools using the helperconst checkInventory = tool({name: 'check_inventory',description: 'Check product inventory levels',parameters: {productId: { type: 'string', description: 'Product ID to check' },},});const createOrder = tool({name: 'create_order',description: 'Create a new order for a customer',parameters: {customerId: { type: 'string' },products: {type: 'array',items: {type: 'object',properties: {productId: { type: 'string' },quantity: { type: 'number' },},},},},});const agent = await client.agents.create({projectId: 'project-id',agentName: 'sales-agent',aiModel: 'gemini-2.5-flash',customTools: [checkInventory, createOrder],});
Multi-Agent Orchestration
Hierarchical Pattern
// Create specialist agentsconst researchAgent = await client.agents.create({projectId: 'project-id',agentName: 'researcher',systemPrompt: 'You are a research specialist. Find relevant information.',orchestrationPattern: 'SINGLE',});const writerAgent = await client.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 client.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],});await client.agents.activate(managerAgent.agent_id);// The manager will automatically delegate to sub-agentsconst result = await client.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 client.server.create({projectId: 'project-id',deploymentName: 'database-tools',aiModel: 'gemini-2.5-flash',dataSourceType: 'data',dataSourceId: 'your-database-id',});// Connect to the agentawait client.agents.update(agentId, {mcpServerIds: [server.deployment_id],});// Now the agent can use database toolsconst response = await client.agents.chat(agentId, {message: 'How many users signed up last week?',});// Agent will query the database via MCP server
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 |