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 agent
const 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 agent
const 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 response
console.log(response.toolCalls); // Any tools the agent used

Agent Configuration

Orchestration Patterns

PatternDescriptionUse Case
SINGLESingle agent, no sub-agentsSimple tasks, chatbots
SEQUENTIALSub-agents execute in orderPipelines, step-by-step workflows
PARALLELSub-agents execute concurrentlyIndependent tasks, aggregation
HIERARCHICALManager delegates to specialistsComplex 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 servers
subagentIds?: string[], // Sub-agents for orchestration
customTools?: Tool[], // Custom tool definitions
});

Chat

Simplified chat interface with conversation history:

const response = await tenzro.agents.chat(agentId, {
message: string, // User message
conversationId?: string, // For conversation continuity
context?: Record<string, any>, // Additional context
});
// Response type:
interface ChatResponse {
success: boolean;
response: string; // Agent's text response
conversationId: string; // Use for follow-up messages
executionId: 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 available
interface QueryResponse {
success: boolean;
result: string;
data?: any; // Structured output if agent returns JSON
executionId: 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 history
stream?: 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 configuration
await tenzro.agents.update(agentId, {
systemPrompt: 'Updated system prompt',
aiModel: 'gemini-2.5-pro',
});
// Delete agent
await 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 executions
const { executions } = await tenzro.agents.getExecutions(agentId, {
limit: 50,
offset: 0,
});
// Get specific execution details
const 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 agents
const 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-agents
const managerAgent = await tenzro.agents.create({
projectId: 'project-id',
agentName: 'content-manager',
systemPrompt: `You are a content manager. Delegate research to the researcher
and 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-agents
const 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 server
const 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 agent
await tenzro.agents.update(agentId, {
mcpServerIds: [server.deployment_id],
});
// Now the agent can use database tools
const 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

ResourceLimit
Max sub-agents10
Max custom tools50
Max MCP servers10
Conversation history100 messages
Execution timeout5 minutes