OpenHands uses specialized micro-agents to handle specific tasks and contexts efficiently. These micro-agents are small, focused components that provide specialized behavior and knowledge for particular scenarios.
Micro-agents are defined in markdown files under the openhands/agenthub/codeact_agent/micro/ directory. Each micro-agent is configured with:
File: github.md
Triggers: github, git
The GitHub agent specializes in GitHub API interactions and repository management. It:
GITHUB_TOKEN for API authenticationKey features:
File: npm.md
Triggers: npm
Specializes in handling npm package management with specific focus on:
You can create your own micro-agents by adding new markdown files to the micro-agents directory. Each file should follow this structure:
---
name: agent_name
agent: CodeActAgent
triggers:
- trigger_word1
- trigger_word2
---
Instructions and capabilities for the micro-agent...
When working with micro-agents:
Micro-agents are automatically integrated into OpenHands' workflow. They:
# GitHub agent example
git checkout -b feature-branch
git commit -m "Add new feature"
git push origin feature-branch
# NPM agent example
yes | npm install package-name
For more information about specific agents, refer to their individual documentation files in the micro-agents directory.
To contribute a new micro-agent to OpenHands, follow these guidelines:
Before creating a micro-agent, consider:
Create a new markdown file in openhands/agenthub/codeact_agent/micro/ with a descriptive name (e.g., docker.md for a Docker-focused agent).
Your micro-agent file must include:
Front Matter: YAML metadata at the start of the file:
---
name: your_agent_name
agent: CodeActAgent
triggers:
- trigger_word1
- trigger_word2
---
Instructions: Clear, specific guidelines for the agent's behavior:
You are responsible for [specific task/domain].
Key responsibilities:
1. [Responsibility 1]
2. [Responsibility 2]
Guidelines:
- [Guideline 1]
- [Guideline 2]
Examples of usage:
[Example 1]
[Example 2]
Before submitting:
Here's a template for a new micro-agent:
---
name: docker
agent: CodeActAgent
triggers:
- docker
- container
---
You are responsible for Docker container management and Dockerfile creation.
Key responsibilities:
1. Create and modify Dockerfiles
2. Manage container lifecycle
3. Handle Docker Compose configurations
Guidelines:
- Always use official base images when possible
- Include necessary security considerations
- Follow Docker best practices for layer optimization
Examples:
1. Creating a Dockerfile:
dockerfile FROM node:18-alpine WORKDIR /app COPY package*.json ./ RUN npm install COPY . . CMD ["npm", "start"]
2. Docker Compose usage:
yaml version: '3' services:
web:
build: .
ports:
- "3000:3000"
Remember to:
- Validate Dockerfile syntax
- Check for security vulnerabilities
- Optimize for build time and image size
Remember that micro-agents are a powerful way to extend OpenHands' capabilities in specific domains. Well-designed agents can significantly improve the system's ability to handle specialized tasks.