|
| 1 | +# OpenHands Microagents |
| 2 | + |
| 3 | +Microagents are specialized prompts that enhance OpenHands with domain-specific knowledge and task-specific workflows. They help developers by providing expert guidance, automating common tasks, and ensuring consistent practices across projects. Each microagent is designed to excel in a specific area, from Git operations to code review processes. |
| 4 | + |
| 5 | +## Sources of Microagents |
| 6 | + |
| 7 | +OpenHands loads microagents from two sources: |
| 8 | + |
| 9 | +### 1. Shareable Microagents (Public) |
| 10 | +This directory (`OpenHands/microagents/`) contains shareable microagents that are: |
| 11 | +- Available to all OpenHands users |
| 12 | +- Maintained in the OpenHands repository |
| 13 | +- Perfect for reusable knowledge and common workflows |
| 14 | + |
| 15 | +Directory structure: |
| 16 | +``` |
| 17 | +OpenHands/microagents/ |
| 18 | +├── # Keyword-triggered expertise |
| 19 | +│ ├── git.md # Git operations |
| 20 | +│ ├── testing.md # Testing practices |
| 21 | +│ └── docker.md # Docker guidelines |
| 22 | +└── # These microagents are always loaded |
| 23 | + ├── pr_review.md # PR review process |
| 24 | + ├── bug_fix.md # Bug fixing workflow |
| 25 | + └── feature.md # Feature implementation |
| 26 | +``` |
| 27 | + |
| 28 | +### 2. Repository Instructions (Private) |
| 29 | +Each repository can have its own instructions in `.openhands/microagents/repo.md`. These instructions are: |
| 30 | +- Private to that repository |
| 31 | +- Automatically loaded when working with that repository |
| 32 | +- Perfect for repository-specific guidelines and team practices |
| 33 | + |
| 34 | +Example repository structure: |
| 35 | +``` |
| 36 | +your-repository/ |
| 37 | +└── .openhands/ |
| 38 | + └── microagents/ |
| 39 | + └── repo.md # Repository-specific instructions |
| 40 | + └── ... # Private micro-agents that are only available inside this repo |
| 41 | +``` |
| 42 | + |
| 43 | + |
| 44 | +## Loading Order |
| 45 | + |
| 46 | +When OpenHands works with a repository, it: |
| 47 | +1. Loads repository-specific instructions from `.openhands/microagents/repo.md` if present |
| 48 | +2. Loads relevant knowledge agents based on keywords in conversations |
| 49 | + |
| 50 | +## Types of Microagents |
| 51 | + |
| 52 | +Most microagents use markdown files with YAML frontmatter. For repository agents (repo.md), the frontmatter is optional - if not provided, the file will be loaded with default settings as a repository agent. |
| 53 | + |
| 54 | + |
| 55 | +### 1. Knowledge Agents |
| 56 | + |
| 57 | +Knowledge agents provide specialized expertise that's triggered by keywords in conversations. They help with: |
| 58 | +- Language best practices |
| 59 | +- Framework guidelines |
| 60 | +- Common patterns |
| 61 | +- Tool usage |
| 62 | + |
| 63 | +Key characteristics: |
| 64 | +- **Trigger-based**: Activated by specific keywords in conversations |
| 65 | +- **Context-aware**: Provide relevant advice based on file types and content |
| 66 | +- **Reusable**: Knowledge can be applied across multiple projects |
| 67 | +- **Versioned**: Support multiple versions of tools/frameworks |
| 68 | + |
| 69 | +You can see an example of a knowledge-based agent in [OpenHands's github microagent](https://github.com/All-Hands-AI/OpenHands/tree/main/microagents/github.md). |
| 70 | + |
| 71 | +### 2. Repository Agents |
| 72 | + |
| 73 | +Repository agents provide repository-specific knowledge and guidelines. They are: |
| 74 | +- Loaded from `.openhands/microagents/repo.md` |
| 75 | +- Specific to individual repositories |
| 76 | +- Automatically activated for their repository |
| 77 | +- Perfect for team practices and project conventions |
| 78 | + |
| 79 | +Key features: |
| 80 | +- **Project-specific**: Contains guidelines unique to the repository |
| 81 | +- **Team-focused**: Enforces team conventions and practices |
| 82 | +- **Always active**: Automatically loaded for the repository |
| 83 | +- **Locally maintained**: Updated with the project |
| 84 | + |
| 85 | +You can see an example of a repo agent in [the agent for the OpenHands repo itself](https://github.com/All-Hands-AI/OpenHands/blob/main/.openhands/microagents/repo.md). |
| 86 | + |
| 87 | + |
| 88 | +## Contributing |
| 89 | + |
| 90 | +### When to Contribute |
| 91 | + |
| 92 | +1. **Knowledge Agents** - When you have: |
| 93 | + - Language/framework best practices |
| 94 | + - Tool usage patterns |
| 95 | + - Common problem solutions |
| 96 | + - General development guidelines |
| 97 | + |
| 98 | + |
| 99 | +2. **Repository Agents** - When you need: |
| 100 | + - Project-specific guidelines |
| 101 | + - Team conventions and practices |
| 102 | + - Custom workflow documentation |
| 103 | + - Repository-specific setup instructions |
| 104 | + |
| 105 | +### Best Practices |
| 106 | + |
| 107 | +1. **For Knowledge Agents**: |
| 108 | + - Choose distinctive triggers |
| 109 | + - Focus on one area of expertise |
| 110 | + - Include practical examples |
| 111 | + - Use file patterns when relevant |
| 112 | + - Keep knowledge general and reusable |
| 113 | + |
| 114 | + |
| 115 | +2. **For Repository Agents**: |
| 116 | + - Document clear setup instructions |
| 117 | + - Include repository structure details |
| 118 | + - Specify testing and build procedures |
| 119 | + - List environment requirements |
| 120 | + - Document CI workflows and checks |
| 121 | + - Include information about code quality standards |
| 122 | + - Maintain up-to-date team practices |
| 123 | + - Consider using OpenHands to generate a comprehensive repo.md (see [Creating a Repository Agent](#creating-a-repository-agent)) |
| 124 | + - YAML frontmatter is optional - files without frontmatter will be loaded with default settings |
| 125 | + |
| 126 | +### Submission Process |
| 127 | + |
| 128 | +1. Create your agent file in the appropriate directory: |
| 129 | + - `microagents/` for expertise (public, shareable) |
| 130 | + - Note: Repository-specific agents should remain in their respective repositories' `.openhands/microagents/` directory |
| 131 | +2. Test thoroughly |
| 132 | +3. Submit a pull request to OpenHands |
| 133 | + |
| 134 | + |
| 135 | +## License |
| 136 | + |
| 137 | +All microagents are subject to the same license as OpenHands. See the root LICENSE file for details. |
0 commit comments