DEV Community

Necati Özmen for VoltAgent

Posted on • Originally published at voltagent.dev

Building Your First AI Agent: A GitHub Repo Analyzer⚡


Image description

Flow

Welcome to your first VoltAgent project!

In this tutorial, we'll guide you through building a practical AI agent system that analyzes GitHub repositories. We'll fetch star counts and contributor lists, then use another agent to analyze this information.

This example demonstrates the power of VoltAgent's multi-agent architecture.

What is VoltAgent?

VoltAgent is an open-source TypeScript framework that acts as this essential toolkit. It simplifies the development of AI agent applications by providing modular building blocks, standardized patterns, and abstractions. Whether you're creating chatbots, virtual assistants, automated workflows, or complex multi-agent systems, VoltAgent handles the underlying complexity, allowing you to focus on defining your agents' capabilities and logic.

Prerequisites

Before we start, make sure you have:

  • Node.js installed (LTS version recommended).
  • An OpenAI API key (or an API key for another supported LLM provider).

Create Your VoltAgent Project

First, let's set up a new VoltAgent project. We'll use the create-voltagent-app CLI for a quick start. Open your terminal and run:

npm create voltagent-app@latest github-repo-analyzer 
Enter fullscreen mode Exit fullscreen mode

Follow the prompts:

  1. Select your preferred package manager (npm, yarn, or pnpm).

Once the setup is complete, navigate into your new project directory:

cd github-repo-analyzer 
Enter fullscreen mode Exit fullscreen mode

And create a .env file in the root of the project to store your API key:

//.env OPENAI_API_KEY=sk-proj- 
Enter fullscreen mode Exit fullscreen mode

Replace sk-proj- with your actual OpenAI API key.

Understanding the Goal

Our goal is to create an agent system that takes a GitHub repository URL (like https://github.com/voltagent/voltagent or simply voltagent/voltagent) and provides an analysis based on its star count and contributors.

To achieve this, we'll use a supervisor-worker pattern:

  1. Supervisor Agent: Takes the user's input (the repo URL) and coordinates the work.
  2. Stars Fetcher Agent: Fetches the star count for the repo.
  3. Contributors Fetcher Agent: Fetches the list of contributors for the repo.
  4. Analyzer Agent: Takes the star count and contributor list and generates insights.

Setting Up the Tools (Conceptual)

Agents often need tools to interact with the outside world (like APIs). In a real application, you would define tools to fetch data from the GitHub API. For this tutorial, imagine we have two pre-built tools:

  • fetchRepoStarsTool: A tool that takes a repository name (e.g., voltagent/core) and returns the number of stars.
  • fetchRepoContributorsTool: A tool that takes a repository name and returns a list of contributors.

(To learn how to create your own tools, check out the Tool Creation documentation.)

Let's assume these tools are defined in a separate file, perhaps src/tools.ts. We'll import them into our main agent file.

Defining the Agents

Now, let's define our agents in src/index.ts. Open this file and replace its contents with the following code:

// src/index.ts import { VoltAgent, Agent } from "@voltagent/core"; import { VercelAIProvider } from "@voltagent/vercel-ai"; import { openai } from "@ai-sdk/openai"; // Assume these tools are defined elsewhere (e.g., src/tools.ts) // import { fetchRepoContributorsTool, fetchRepoStarsTool } from "./tools"; // --- Mock Tools for Demonstration --- // In a real scenario, you'd use actual tool implementations. // We use simple functions here to illustrate agent structure. const mockFetchRepoStarsTool = { name: "fetchRepoStars", description: "Fetches the star count for a given GitHub repository (owner/repo).", parameters: { type: "object", properties: { repo: { type: "string", description: 'Repository name (e.g., "voltagent/core")' }, }, required: ["repo"], }, execute: async ({ repo }: { repo: string }) => ({ stars: Math.floor(Math.random() * 5000) }), // Mock data }; const mockFetchRepoContributorsTool = { name: "fetchRepoContributors", description: "Fetches the contributors for a given GitHub repository (owner/repo).", parameters: { type: "object", properties: { repo: { type: "string", description: 'Repository name (e.g., "voltagent/core")' }, }, required: ["repo"], }, execute: async ({ repo }: { repo: string }) => ({ contributors: ["UserA", "UserB", "UserC"] }), // Mock data }; // --- End Mock Tools --- // 1. Create the stars fetcher agent const starsFetcherAgent = new Agent({ name: "StarsFetcher", description: "Fetches the number of stars for a GitHub repository using a tool.", llm: new VercelAIProvider(), model: openai("gpt-4o-mini"), tools: [mockFetchRepoStarsTool], // Use the mock tool }); // 2. Create the contributors fetcher agent const contributorsFetcherAgent = new Agent({ name: "ContributorsFetcher", description: "Fetches the list of contributors for a GitHub repository using a tool.", llm: new VercelAIProvider(), model: openai("gpt-4o-mini"), tools: [mockFetchRepoContributorsTool], // Use the mock tool }); // 3. Create the analyzer agent (no tools needed) const analyzerAgent = new Agent({ name: "RepoAnalyzer", description: "Analyzes repository statistics (stars, contributors) and provides insights.", llm: new VercelAIProvider(), model: openai("gpt-4o-mini"), // This agent doesn't need tools; it processes data provided by the supervisor. }); // 4. Create the supervisor agent that coordinates all the sub-agents const supervisorAgent = new Agent({ name: "Supervisor", description: `You are a GitHub repository analyzer. When given a GitHub repository URL or owner/repo format, you will: 1. Extract the owner/repo name. 2. Use the StarsFetcher agent to get the repository's star count. 3. Use the ContributorsFetcher agent to get the repository's contributors. 4. Pass the collected data (stars, contributors) to the RepoAnalyzer agent. 5. Return the analysis provided by the RepoAnalyzer. Example input: https://github.com/vercel/ai-sdk or vercel/ai-sdk `, llm: new VercelAIProvider(), model: openai("gpt-4o-mini"), subAgents: [starsFetcherAgent, contributorsFetcherAgent, analyzerAgent], // Assign sub-agents }); // 5. Initialize the VoltAgent with the agent hierarchy new VoltAgent({ agents: { // We only expose the supervisor externally. // The supervisor will internally call the other agents. supervisor: supervisorAgent, }, }); console.log("GitHub Repo Analyzer Agent system started."); 
Enter fullscreen mode Exit fullscreen mode

Explanation:

  1. Imports: We import necessary components from VoltAgent and AI SDK libraries.
  2. Mock Tools: For simplicity, we've added mock versions of the tools directly in this file. In a real app, you'd import actual tool implementations.
  3. starsFetcherAgent: Defined with a name, description, LLM configuration, and the mockFetchRepoStarsTool. Its job is solely to use this tool when asked.
  4. contributorsFetcherAgent: Similar to the stars fetcher, but configured with the mockFetchRepoContributorsTool.
  5. analyzerAgent: This agent doesn't need tools. Its purpose is to receive data (stars and contributors) and use its LLM capabilities to generate an analysis based on its description.
  6. supervisorAgent: This is the main coordinator.
    • Its description clearly outlines the steps it needs to take.
    • Crucially, it includes the other three agents in its subAgents array. This tells the supervisor it can delegate tasks to these specific agents.
  7. new VoltAgent(...): This initializes the VoltAgent system. We register the supervisorAgent under the key supervisor. This means when we interact with our application, we'll be talking directly to the supervisor.

Run Your Agent System

Now, let's run the agent. Go back to your terminal (make sure you're in the github-repo-analyzer directory) and run the development command:

npm run dev 
Enter fullscreen mode Exit fullscreen mode

You should see the VoltAgent server startup message:

══════════════════════════════════════════════════ VOLTAGENT SERVER STARTED SUCCESSFULLY ══════════════════════════════════════════════════ ✓ HTTP Server: http://localhost:3141 Developer Console: https://console.voltagent.dev ══════════════════════════════════════════════════ 
Enter fullscreen mode Exit fullscreen mode

Interact with Your Agent

  1. Open the Console: Go to https://console.voltagent.dev.
  2. Find Your Agent: Look for the agent named supervisor (or whatever name you gave it in the new VoltAgent call).
  3. Open Agent Details: Click on the supervisor agent.
  4. Start Chatting: Click the chat icon.
  5. Send a Message: Try sending a message like: Analyze the repo voltagent/voltagent or Tell me about https://github.com/voltagent/voltagent

flow-2

The supervisor agent will now follow its instructions:

  • It will likely first call the StarsFetcher to get the (mock) star count.
  • Then, it will call the ContributorsFetcher for the (mock) contributor list.
  • Finally, it will pass this information to the RepoAnalyzer and return the analysis to you in the chat.

You can observe this multi-step process happening in the VoltAgent Developer Console!

AI chat

Conclusion

Congratulations! You've successfully built a multi-agent system using VoltAgent. You learned how to:

  • Set up a VoltAgent project.
  • Define multiple agents with specific roles and tools (even mock ones).
  • Create a supervisor agent to orchestrate tasks among sub-agents.
  • Run and interact with your agent system via the Developer Console.

This example showcases how you can break down complex tasks into smaller, manageable units, each handled by a specialized agent.

Next Steps

  • Replace the mock tools with real implementations using the GitHub API.
  • Try the full example: Check out the complete GitHub Repo Analyzer example with real tool implementations. You can also create a project directly from this example:
 npm create voltagent-app@latest -- --example github-repo-analyzer 
Enter fullscreen mode Exit fullscreen mode
  • Explore different LLM providers and models.
  • Learn more about Agent Memory to give your agents context.
  • Dive deeper into Tool Creation.

Top comments (17)

Collapse
 
nadeem_zia_257af7e986ffc6 profile image
nadeem zia

Interesting work

Collapse
 
necatiozmen profile image
Necati Özmen

We hope like it.

Collapse
 
omeraplak profile image
Omer Aplak

Thanks a lot! Appreciate it 🙌

Collapse
 
nevodavid profile image
Nevo David

Pretty cool seeing how you can chain these agents together, honestly helps me make sense of how to start with AI stuff myself.

Collapse
 
omeraplak profile image
Omer Aplak

That’s awesome to hear. That’s exactly what we hoped for! 🙌
Agents can feel abstract at first, but chaining them makes it all click.

If you build something or have questions, feel free to drop by Discord → s.voltagent.dev/discord

Collapse
 
akshaybond30160 profile image
Akshay bondre

Great work

Collapse
 
omeraplak profile image
Omer Aplak

Thank you! Means a lot ⚡

Collapse
 
arindam_1729 profile image
Arindam Majumder

This looks interesting.

I'm already creating a playlist where I'm building Agents with different frameworks. I'll try this as well.

Collapse
 
ricorizz profile image
Rico Rizz

Excellent work man!

Collapse
 
necatiozmen profile image
Necati Özmen

Thanks!

Collapse
 
astrodevil profile image
Astrodevil • Edited

Coming across VoltAgent for the 1st time, Is it something close to LyzrAI

Collapse
 
omeraplak profile image
Omer Aplak

Great question! VoltAgent and LyzrAI both work with agents, but the approach is a bit different.

VoltAgent is a TypeScript-first open-source framework focused on:
• Full-code flexibility (no visual drag-and-drop)
• Multi-agent orchestration with a Supervisor Agent
• Built-in observability and debugging tools
• Strong developer experience for real-world apps

You can think of it like building production-ready AI workflows but with full control and visibility 👀⚡

If you’re curious, here’s the repo → github.com/voltagent/voltagent
And the docs → voltagent.dev/docs

Would love to hear your thoughts if you explore it!

Collapse
 
astrodevil profile image
Astrodevil

Very interesting, been trying out diff agent frameworks recently. Published demos and videos on ADK yesterday.

I'll give this a try soon. Can I use OpenAI compatible inference providers with Volt?

Thread Thread
 
omeraplak profile image
Omer Aplak

Great to hear you’ve been exploring different frameworks!

Yes! with VoltAgent’s VercelAIProvider, you can use any model or provider supported by the Vercel AI SDK, including OpenAI-compatible ones.

Here’s more info:
📘 VoltAgent docs: voltagent.dev/docs/agents/provider...
🛠️ Vercel AI SDK providers: sdk.vercel.ai/docs/foundations/pro...

Excited to see what you build! ⚡

Collapse
 
androaddict profile image
androaddict

are we using this to our own data ? how much our data is safer side ?

Collapse
 
omeraplak profile image
Omer Aplak

Great question!

By default, VoltAgent runs entirely in your own environment. You have full control over how your data is stored, processed, and shared.
Nothing is sent anywhere unless you explicitly configure it to do so (e.g., using a third-party provider).

So yes. You’re using your own data, on your own terms.
And we take developer trust seriously ⚡

Let us know if you want to dive deeper into how storage or observability is handled!

Collapse
 
yewot29861 profile image
Yalwa

It is of great assistance.