Skip to content

Update documentation for command-style microagents with user input support #8990

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 63 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
ad6311d
Add back microagent files and add special handling for user input var…
openhands-agent Apr 29, 2025
a1e6ed4
Add special handling for microagents that require user input
openhands-agent Apr 29, 2025
e90b841
Update microagent files to match original ones with added triggers an…
openhands-agent Apr 29, 2025
6c144e6
Add back microagent files with special handling for user inputs
openhands-agent Apr 29, 2025
bcc9bd0
Move task microagent tests to test_microagent_task.py
openhands-agent Apr 29, 2025
cb09940
🤖 Auto-fix Python linting issues
openhands-agent Apr 29, 2025
b55bfed
Update microagents/address_pr_comments.md
xingyaoww Apr 30, 2025
f4024cc
Update microagents/update_pr_description.md
xingyaoww Apr 30, 2025
7c35ce1
Merge branch 'main' into add-back-microagents
xingyaoww Apr 30, 2025
bf2c3de
cleanup tests
xingyaoww Apr 30, 2025
f26d770
remove hardcoded last line
xingyaoww May 1, 2025
405f006
revert some changes
xingyaoww May 1, 2025
58c574a
revert changes
xingyaoww May 1, 2025
e088d2d
simplify microagent
xingyaoww May 1, 2025
98e454e
fix lint and missing imports
xingyaoww May 1, 2025
fdc5913
add remain
xingyaoww May 1, 2025
4519a7f
fix test
xingyaoww May 1, 2025
cd464c0
rename files
xingyaoww May 1, 2025
0236e09
fix test
xingyaoww May 2, 2025
3c07193
Add microagent suggestions feature to chat input
openhands-agent May 2, 2025
3790ec7
Add tests for microagent suggestions component
openhands-agent May 2, 2025
f2e3bc3
Fix microagent suggestions feature
openhands-agent May 2, 2025
a07cf97
Merge commit '6032d2620d6ec252d3c80695a6de1fc88da9c87a' into add-back…
xingyaoww May 2, 2025
5dfa1bb
Fix microagent suggestions UI and TypeScript errors
openhands-agent May 2, 2025
4c361ab
Add mock handler for microagents endpoint
openhands-agent May 2, 2025
642cc52
Fix linting issues in handlers.ts
openhands-agent May 2, 2025
da935f9
Merge branch 'main' into add-back-microagents
xingyaoww May 2, 2025
fc07622
Implement microagent suggestions using TipTap
openhands-agent May 12, 2025
6ce9f49
Fix linting issues in TipTap editor component
openhands-agent May 12, 2025
f3934be
Fix microagent suggestions using tippy.js for better popup handling
openhands-agent May 12, 2025
18c88f9
Merge from main to resolve conflicts
openhands-agent May 17, 2025
802b765
Add microagent button and dropdown to trajectory actions
openhands-agent May 17, 2025
54cd9f7
Fix unlocalized strings in microagent-dropdown.tsx
openhands-agent May 19, 2025
3e4ab4f
Fix docstring formatting in KnowledgeMicroagent class
openhands-agent May 19, 2025
34b0971
Fix linting issues in frontend and Python code
openhands-agent May 19, 2025
7b956b6
revert docs to look like main
xingyaoww Jun 3, 2025
6f1a74e
merge main
xingyaoww Jun 3, 2025
dd988d0
revert fe
xingyaoww Jun 3, 2025
c444dbf
remove fe changes
xingyaoww Jun 3, 2025
85c6539
revert changes
xingyaoww Jun 3, 2025
32e610a
revert unnecessary change
xingyaoww Jun 7, 2025
6763f21
Merge branch 'main' into add-back-microagents
xingyaoww Jun 7, 2025
4837c4d
Update microagents/get_test_to_pass.md
xingyaoww Jun 8, 2025
469d184
address engel comment
xingyaoww Jun 8, 2025
58845b0
rename more files
xingyaoww Jun 8, 2025
401262f
Update documentation for task microagents with user input support
openhands-agent Jun 8, 2025
53c80d1
Merge branch 'main' into update-microagent-docs
xingyaoww Jun 8, 2025
6fe9680
Consolidate task microagent documentation into keyword-triggered micr…
openhands-agent Jun 8, 2025
9d9f931
Remove unused fields from microagent documentation and example
openhands-agent Jun 8, 2025
17212bb
Remove unused fields from microagent code and update all microagent f…
openhands-agent Jun 8, 2025
6c49686
Add MCP tools documentation and update microagent field requirements
openhands-agent Jun 8, 2025
0fe5b80
Update microagent code to use filename as name when not specified
openhands-agent Jun 8, 2025
bd3ff43
Remove name field from microagent files
openhands-agent Jun 8, 2025
fc16da8
Update microagent documentation to clarify that type field is optional
openhands-agent Jun 8, 2025
0691e5c
Remove type: field from all microagent markdown files
openhands-agent Jun 8, 2025
283f503
Exclude name field in MicroagentMetadata as it's deprecated
openhands-agent Jun 8, 2025
0ca3188
Merge branch 'main' into update-microagent-docs
xingyaoww Jun 18, 2025
8c2d4db
Merge branch 'main' into update-microagent-docs
xingyaoww Jun 23, 2025
eee12bf
fix test
xingyaoww Jun 23, 2025
1a95f86
fix all remaining issue'
xingyaoww Jun 23, 2025
1d3ff66
Fix failing tests: add missing newlines and pytest-asyncio dependency
openhands-agent Jun 24, 2025
e70595f
Fix microagent tests and remove debug prints
openhands-agent Jun 24, 2025
93287ef
Fix microagent test filenames to match expected names
openhands-agent Jun 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 146 additions & 7 deletions docs/usage/prompting/microagents-keyword.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,111 @@ description: Keyword-triggered microagents provide OpenHands with specific instr

## Usage

These microagents are only loaded when a prompt includes one of the trigger words.
Keyword-triggered microagents are only loaded when a prompt includes one of the trigger words. There are two types of keyword-triggered microagents:

1. **Standard Keyword Microagents**: Triggered by keywords embedded in text
2. **Command-Style Microagents**: Triggered by command-style inputs (e.g., `/fix_test`) that can prompt for user input

Additionally, there's a special type of microagent that's always active:

3. **Repository Microagents**: Always active for a specific repository, providing repository-specific context and tools

## Frontmatter Syntax

Frontmatter is required for keyword-triggered microagents. It must be placed at the top of the file,
above the guidelines.
above the guidelines. Enclose the frontmatter in triple dashes (---).

### Standard Keyword Microagents

Enclose the frontmatter in triple dashes (---) and include the following fields:
For standard keyword microagents, include the following fields:

| Field | Description | Required | Default |
|------------|--------------------------------------------------|----------|------------------|
| `name` | The name of the microagent | No | Filename |
| `type` | The type of microagent (`knowledge`) | No | Inferred |
| `triggers` | A list of keywords that activate the microagent. | Yes | None |
| `agent` | The agent this microagent applies to. | No | 'CodeActAgent' |

### Command-Style Microagents

For command-style microagents that require user input, include the following fields:

| Field | Description | Required | Default |
|------------|------------------------------------------------------------|----------|------------------|
| `name` | The name of the microagent | No | Filename |
| `type` | The type of microagent (`task`) | No | Inferred |
| `triggers` | A list of command triggers (e.g., `/fix_test`) | No | `/[name]` |
| `inputs` | A list of input variables the microagent requires | Yes | None |

### Repository Microagents

## Example
Repository microagents are always active for a specific repository. They provide repository-specific context and tools.

| Field | Description | Required | Default |
|------------|------------------------------------------------------------|----------|------------------|
| `name` | The name of the microagent | No | Filename |
| `type` | The type of microagent (`repo`) | No | Inferred |

#### Repository Microagent Example

Here's an example of a repository microagent:

```yaml
---
# The type field is optional and will be inferred as 'repo' when no triggers are present
---

Keyword-triggered microagent file example located at `.openhands/microagents/yummy.md`:
# Repository Guidelines

This repository follows these coding standards:
1. Use PEP 8 for Python code
2. Use ESLint for JavaScript code
3. Write unit tests for all new features
```

This microagent is always active when working with the repository and provides repository-specific guidelines.

### MCP Tools Support

Microagents can also provide additional MCP (Model-Code-Prompt) tools to the agent. This is useful for extending the agent's capabilities with custom tools.

| Field | Description | Required | Default |
|--------------|-----------------------------------------------------------|----------|------------------|
| `mcp_tools` | Configuration for additional MCP tools | No | None |

#### MCP Tools Example

Here's an example of a microagent that provides an additional MCP tool (the `fetch` tool for accessing web content):

```yaml
---
# The type field is optional and will be inferred as 'repo' when no triggers are present
mcp_tools:
stdio_servers:
- name: "fetch"
command: uvx
args:
- mcp-server-fetch
---
```

This microagent is a repository microagent (always active) that adds the `fetch` tool to the agent's capabilities.

Each input in the `inputs` list requires:

| Field | Description | Required |
|---------------|--------------------------------------------------|----------|
| `name` | The name of the input variable | Yes |
| `description` | A description of what the input should contain | Yes |


## Examples

### Standard Keyword Microagent Example

Standard keyword microagent file example located at `.openhands/microagents/yummy.md`:
```yaml
---
# The type field is optional and will be inferred as 'knowledge' when triggers are present
triggers:
- yummyhappy
- happyyummy
Expand All @@ -33,4 +118,58 @@ triggers:
The user has said the magic word. Respond with "That was delicious!"
```

[See examples of microagents triggered by keywords in the official OpenHands repository](https://github.com/All-Hands-AI/OpenHands/tree/main/microagents)
### Command-Style Microagent Example

Command-style microagent file example located at `.openhands/microagents/fix_test.md`:
```yaml
---
# The type field is optional and will be inferred as 'task' when inputs are present
triggers:
- /fix_test
inputs:
- name: BRANCH_NAME
description: "Branch for the agent to work on"
- name: TEST_COMMAND_TO_RUN
description: "The test command you want the agent to work on. For example, `pytest tests/unit/test_bash_parsing.py`"
- name: FUNCTION_TO_FIX
description: "The name of function to fix"
- name: FILE_FOR_FUNCTION
description: "The path of the file that contains the function"
---

Can you check out branch "{{ BRANCH_NAME }}", and run {{ TEST_COMMAND_TO_RUN }}.

Help me fix these tests to pass by fixing the {{ FUNCTION_TO_FIX }} function in file {{ FILE_FOR_FUNCTION }}.

PLEASE DO NOT modify the tests by yourself -- Let me know if you think some of the tests are incorrect.
```

## Using Command-Style Microagents

Command-style microagents are designed to streamline common development tasks by providing structured templates for specific operations. They are triggered using a command-style format and will prompt the user for any required inputs.

### How to Use

1. Type `/` in the chat input to see available command-style microagents
2. Select a microagent from the dropdown or type its name (e.g., `/fix_test`)
3. The agent will prompt you for any required inputs
4. Provide the requested information
5. The agent will execute the task with your inputs

### Template Variables

In the body of a command-style microagent, you can reference input variables using the `{{ VARIABLE_NAME }}` syntax. These will be replaced with the user-provided values when the microagent is triggered.

### Available Command-Style Microagents

OpenHands includes several built-in command-style microagents:

| Command | Description |
|----------------------|-------------------------------------------------------|
| `/fix_test` | Fix failing tests by modifying a specific function |
| `/update_test` | Update tests for a new implementation |
| `/update_pr` | Update a pull request description |
| `/address_pr_comments` | Address comments on a pull request |
| `/add_repo_instruction` | Add instructions to the repository microagent |

[See examples of microagents in the official OpenHands repository](https://github.com/All-Hands-AI/OpenHands/tree/main/microagents)
10 changes: 5 additions & 5 deletions docs/usage/prompting/microagents-overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description: Microagents are specialized prompts that enhance OpenHands with dom
Currently OpenHands supports the following types of microagents:

- [General Microagents](./microagents-repo): General guidelines for OpenHands about the repository.
- [Keyword-Triggered Microagents](./microagents-keyword): Guidelines activated by specific keywords in prompts.
- [Keyword-Triggered Microagents](./microagents-keyword): Guidelines activated by specific keywords in prompts, including command-style microagents that prompt for user inputs.

To customize OpenHands' behavior, create a .openhands/microagents/ directory in the root of your repository and
add `<microagent_name>.md` files inside. For repository-specific guidelines, you can ask OpenHands to analyze your repository and create a comprehensive `repo.md` file (see [General Microagents](./microagents-repo) for details).
Expand All @@ -34,7 +34,7 @@ some-repository/
Each microagent file may include frontmatter that provides additional information. In some cases, this frontmatter
is required:

| Microagent Type | Required |
|---------------------------------|----------|
| `General Microagents` | No |
| `Keyword-Triggered Microagents` | Yes |
| Microagent Type | Required |
|------------------------------------------------|----------|
| `General Microagents` | No |
| `Keyword-Triggered Microagents (all types)` | Yes |
29 changes: 13 additions & 16 deletions microagents/add_agent.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
---
name: add_agent
type: knowledge
version: 1.0.0
agent: CodeActAgent
triggers:
- new agent
- new microagent
- create agent
- create an agent
- create microagent
- create a microagent
- add agent
- add an agent
- add microagent
- add a microagent
- microagent template
- new agent
- new microagent
- create agent
- create an agent
- create microagent
- create a microagent
- add agent
- add an agent
- add microagent
- add a microagent
- microagent template
type: knowledge
---

This agent helps create new microagents in the `.openhands/microagents` directory by providing guidance and templates.
Expand All @@ -38,4 +35,4 @@ For detailed information, see:

- [Microagents Overview](https://docs.all-hands.dev/usage/prompting/microagents-overview)
- [Microagents Syntax](https://docs.all-hands.dev/usage/prompting/microagents-syntax)
- [Example GitHub Microagent](https://github.com/All-Hands-AI/OpenHands/blob/main/microagents/github.md)
- [Example GitHub Microagent](https://github.com/All-Hands-AI/OpenHands/blob/main/microagents/github.md)
12 changes: 4 additions & 8 deletions microagents/add_repo_inst.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
---
name: add_repo_inst
version: 1.0.0
author: openhands
agent: CodeActAgent
inputs:
- description: Branch for the agent to work on
name: REPO_FOLDER_NAME
triggers:
- /add_repo_inst
inputs:
- name: REPO_FOLDER_NAME
description: "Branch for the agent to work on"
---

Please browse the current repository under /workspace/{{ REPO_FOLDER_NAME }}, look at the documentation and relevant code, and understand the purpose of this repository.
Expand Down Expand Up @@ -62,4 +58,4 @@ Frontend:
```

Now, please write a similar markdown for the current repository.
Read all the GitHub workflows under .github/ of the repository (if this folder exists) to understand the CI checks (e.g., linter, pre-commit), and include those in the repo.md file.
Read all the GitHub workflows under .github/ of the repository (if this folder exists) to understand the CI checks (e.g., linter, pre-commit), and include those in the repo.md file.
16 changes: 6 additions & 10 deletions microagents/address_pr_comments.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
---
name: address_pr_comments
version: 1.0.0
author: openhands
agent: CodeActAgent
inputs:
- description: URL of the pull request
name: PR_URL
- description: Branch name corresponds to the pull request
name: BRANCH_NAME
triggers:
- /address_pr_comments
inputs:
- name: PR_URL
description: "URL of the pull request"
- name: BRANCH_NAME
description: "Branch name corresponds to the pull request"
---

First, check the branch {{ BRANCH_NAME }} and read the diff against the main branch to understand the purpose.

This branch corresponds to this PR {{ PR_URL }}

Next, you should use the GitHub API to read the reviews and comments on this PR and address them.
Next, you should use the GitHub API to read the reviews and comments on this PR and address them.
7 changes: 2 additions & 5 deletions microagents/agent_memory.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
---
name: agent_memory
type: knowledge
version: 1.0.0
agent: CodeActAgent
triggers:
- /remember
type: knowledge
---

* Repository memory: Use .openhands/microagents/repo.md under each repository root to store and access important information.
Expand All @@ -29,4 +26,4 @@ triggers:
- If you've only explored a portion of the codebase, clearly note this limitation in the repository structure documentation
- If you don't know the essential commands for working with the repository, such as lint or typecheck, ask the user and suggest adding them to repo.md for future reference (with permission)

When you receive this message, please review and summarize your recent actions and observations, then present a list of valuable information that should be saved in repo.md to the user.
When you receive this message, please review and summarize your recent actions and observations, then present a list of valuable information that should be saved in repo.md to the user.
18 changes: 6 additions & 12 deletions microagents/default-tools.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
---
# This is a repo microagent that is always activated
# to include necessary default tools implemented with MCP
name: default-tools
type: repo
version: 1.0.0
agent: CodeActAgent
mcp_tools:
stdio_servers:
- name: "fetch"
command: "uvx"
args: ["mcp-server-fetch"]
# We leave the body empty because MCP tools will automatically add the
# tool description for LLMs in tool calls, so there's no need to add extra descriptions.
---
- args:
- mcp-server-fetch
command: uvx
name: fetch
type: repo
---
7 changes: 2 additions & 5 deletions microagents/docker.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
---
name: docker
type: knowledge
version: 1.0.0
agent: CodeActAgent
triggers:
- docker
- container
type: knowledge
---

# Docker Installation and Usage Guide
Expand Down Expand Up @@ -52,4 +49,4 @@ To verify Docker is working correctly, run the hello-world container:

```bash
sudo docker run hello-world
```
```
25 changes: 11 additions & 14 deletions microagents/fix_test.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
---
name: fix_test
version: 1.0.0
author: openhands
agent: CodeActAgent
inputs:
- description: Branch for the agent to work on
name: BRANCH_NAME
- description: The test command you want the agent to work on. For example, `pytest
tests/unit/test_bash_parsing.py`
name: TEST_COMMAND_TO_RUN
- description: The name of function to fix
name: FUNCTION_TO_FIX
- description: The path of the file that contains the function
name: FILE_FOR_FUNCTION
triggers:
- /fix_test
inputs:
- name: BRANCH_NAME
description: "Branch for the agent to work on"
- name: TEST_COMMAND_TO_RUN
description: "The test command you want the agent to work on. For example, `pytest tests/unit/test_bash_parsing.py`"
- name: FUNCTION_TO_FIX
description: "The name of function to fix"
- name: FILE_FOR_FUNCTION
description: "The path of the file that contains the function"
---

Can you check out branch "{{ BRANCH_NAME }}", and run {{ TEST_COMMAND_TO_RUN }}.

Help me fix these tests to pass by fixing the {{ FUNCTION_TO_FIX }} function in file {{ FILE_FOR_FUNCTION }}.

PLEASE DO NOT modify the tests by yourself -- Let me know if you think some of the tests are incorrect.
PLEASE DO NOT modify the tests by yourself -- Let me know if you think some of the tests are incorrect.
Loading
Loading