Building Your App › Custom Agent Building
Main Agents in Emergent
Overview
Main agents are the primary decision makers in Emergent. They interpret instructions, plan tasks, call tools, and coordinate the full workflow. This page explains how main agents work and how to create your own.
What Main Agents Are
A main agent acts as the central controller for a task. It uses reasoning to decide what to do and uses tools to carry out actions. It can also call sub-agents to handle specialized tasks.
Main agents combine planning, action, and self correction into a single process.
What Main Agents Do
Main agents complete a variety of responsibilities.
- Interpret user instructions
- Break large tasks into steps
- Choose which tools to use
- Call sub-agents when needed
- Handle retries and error recovery
- Return final results
They manage both the high level thinking and the detailed execution.
Types of Main Agents
Emergent provides different main agent configurations. Some focus on long tasks, some focus on stability, and some focus on speed. You can choose the type that best matches your use case.
Creating a Main Agent
Choose a language model
Select the model that will perform the agent's reasoning. Different models have different strengths.
Define the system prompt
Write a clear and detailed prompt. Describe the agent's role, goals, and rules. Good prompts lead to reliable behavior.
Select Tools
Add the tools that the agent should be allowed to use. These may include MCP tools or built in tools provided by Emergent.
Add sub-agents
Attach specialized sub-agents for tasks such as testing, integration checks, or content generation.
Connect a repository (If Needed)
If your agent will work with code, link a GitHub repository so it has access to your project.
Save and Test
Test the agent with small tasks first. Review how it chooses tools and handles errors. Make adjustments as needed.
Writing Effective Instructions
The system prompt is one of the most important parts of a main agent. To write a good one:
- Be specific
- Describe the role clearly
- List rules and constraints
- Provide examples if helpful
- Explain when the agent should use tools or sub-agents
A strong prompt leads to consistent and predictable actions.
Best Practices for Main Agents
- Guide the agent with clear rules
- Keep the tool list focused
- Test behavior with simple tasks before moving to complex ones
- Use evaluation tasks to detect changes in behavior
- Update prompts as your project evolves
Well designed main agents provide structure, control, and flexibility for many types of tasks.
