Building Your AI Company: A Technical Deep Dive for Developers
A comprehensive technical guide to building with AgentAGI. Learn about the platform architecture, REST API, plugin development, MCP protocol integration, custom agent creation, Claude Code CLI, and Ollama setup.
1. Platform Architecture Overview
AgentAGI is built on a service-oriented architecture with the following core layers, all verified against our actual codebase:
- CEO Orchestrator (
server/adapters/ceo.ts— 1,223 lines) — The central coordination layer that receives missions, delegates to agents, and manages workflows. - Agent Adapters (
server/adapters/) — Abstraction layer connecting to different AI models and external agents (Claude Code, Ollama, Codex, OpenClaw). - Plugin System (
server/plugins/) — Extensible plugin framework with built-in plugin manager (340 lines) and plugin loader. - Memory Services (
server/services/memory/) — Per-agent persistent memory, semantic memory with embeddings (317 lines), shared memory, and actor-aware memory. - Trust & Reputation (
server/services/trust-reputation.ts— 358 lines) — Scoring engine that tracks agent reliability and influences delegation decisions. - Task DAG Resolver (
server/services/task-dag-resolver.ts) — Dependency graph engine for orchestrating complex multi-step workflows. - API Layer — RESTful API for programmatic access to all platform capabilities.
2. REST API Integration
AgentAGI exposes a comprehensive REST API that lets you integrate the platform into your own applications, build custom dashboards, or automate workflows. The API is organized around the core resources:
GET /api/companies # List your AI companies GET /api/companies/:id # Get company details POST /api/companies # Create a new AI company GET /api/agents # List all agents GET /api/agents/:id # Get agent details, trust score, budget POST /api/tasks # Create a new task GET /api/tasks # List tasks with filters POST /api/tasks/:id/approve # Approve a pending task GET /api/activity # Query activity log GET /api/budget # Get budget usage across agents
Authentication: All API requests require an API key. Generate one from the Settings page in your AgentAGI dashboard. Include it in the Authorization: Bearer <key> header.
3. Plugin Development
The plugin system allows you to extend AgentAGI with custom capabilities. Plugins can add new tools for agents, integrate with external services, or modify agent behavior. The plugin framework is managed by a dedicated plugin manager (340 lines) and plugin loader.
Plugin Structure
my-plugin/ ├── plugin.json # Plugin manifest (name, version, capabilities) ├── index.ts # Main plugin entry point ├── tools/ # Custom tool definitions │ ├── my-tool.ts │ └── my-other-tool.ts └── README.md # Documentation
Plugin Manifest Example
{
"name": "my-analytics-plugin",
"version": "1.0.0",
"description": "Connect your AI company to custom analytics",
"capabilities": ["tool:query_analytics", "hook:after_task_complete"],
"permissions": ["api:read", "budget:read"]
}Once your plugin is built, upload it through the Plugins page in your dashboard, or use the API to install it programmatically.
4. MCP Protocol Integration
AgentAGI supports the Model Context Protocol (MCP), the open standard for connecting AI agents to tools and data sources. MCP allows your agents to interact with any MCP-compatible tool, database, or API.
To connect an MCP tool, simply add it through the Integrations page. The MCP client service handles the protocol handshake, tool discovery, and secure execution.
5. Connecting External AI Models
AgentAGI is model-agnostic. You can connect different AI models for different agents:
- Claude Code CLI (
server/adapters/claude-code.ts— 507 lines) — Native integration with Claude Code for terminal-based coding tasks. Includes a global execution lock to serialize concurrent agent calls. - Ollama (
server/adapters/ollama.ts— 141 lines) — Run local LLMs via Ollama. Perfect for privacy-sensitive workloads or reducing API costs. - OpenAI / GPT — Standard integration for GPT-4 and GPT-4o models.
- Custom models — Any OpenAI-compatible API endpoint can be connected.
You can assign different models to different agents based on their role. Use a powerful (expensive) model for the CEO and simple (cheap) models for routine tasks.
6. Custom Agent Development
Want to create a custom agent with specific capabilities? The plugin framework supports agent definitions. Your custom agent can have its own tools, memory scope, and behavior rules:
// Example: Custom research agent plugin
export class ResearchAgentPlugin {
name = "market-researcher";
tools = ["web_search", "scrape_url", "analyze_competitor"];
memory = { type: "semantic", scope: "per-agent" };
async onTask(task) {
const search = await this.tools.web_search(task.query);
const analysis = await this.analyze(search);
return this.formatReport(analysis);
}
}7. Webhook Integration
AgentAGI supports webhooks for real-time event notifications. Configure webhooks to receive events when tasks are completed, budgets are exhausted, approvals are needed, or agent trust scores change:
// Example webhook payload (task completed)
{
"event": "task.completed",
"company_id": "cmp_abc123",
"agent": "CMO Agent",
"task": "Write SEO blog post",
"status": "completed",
"trust_score_after": 87,
"cost_incurred": 1.42,
"timestamp": "2026-06-11T14:30:00Z"
}8. Budget API
Programmatically manage budgets across your AI companies. Set limits, track spend, and receive alerts when agents approach their limits:
GET /api/budget/companies # Budget overview for all companies GET /api/budget/agents # Per-agent budget breakdown POST /api/budget/agents/:id # Update agent budget GET /api/budget/alerts # Active budget alerts
9. Observability & Debugging
Every action in AgentAGI is logged and traceable. The API provides full access to the activity log for debugging and analysis:
- Activity Log — Every tool call, API request, and decision point is recorded with timestamps, costs, and agent IDs.
- Task Traces — Drill into any task to see the full execution trace: which agents were involved, what tools were called, how long each step took, and what it cost.
- Agent Performance — Historical trust scores, task completion rates, budget efficiency metrics per agent.
Getting Started: The fastest way for developers to get started is to sign up at app.agentagi.dev, generate an API key from Settings, and start experimenting with the API. The platform is designed to be programmable from day one.