Skip to content

Commit d164585

Browse files
committed
Update core container
1 parent 933fc04 commit d164585

210 files changed

Lines changed: 7431 additions & 3807 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

containers/runtime/Dockerfile

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
FROM nikolaik/python-nodejs:python3.13-nodejs24-slim
22

3+
SHELL ["/bin/bash", "-c"]
4+
35
# Shared environment variables
46
ENV POETRY_VIRTUALENVS_PATH=/openhands/poetry \
57
MAMBA_ROOT_PREFIX=/openhands/micromamba \
@@ -60,12 +62,18 @@ RUN mkdir -p /openhands && \
6062

6163

6264
# ================================================================
65+
# Define Docker installation macro
66+
67+
68+
# Install Docker only if not a swebench or mswebench image
69+
70+
6371
# Install Docker following official documentation
6472
# https://docs.docker.com/engine/install/ubuntu/
6573
# https://docs.docker.com/engine/install/debian/
6674
RUN \
6775
# Determine OS type and install accordingly
68-
if [[ "nikolaik/python-nodejs:python3.13-nodejs24-slim" == *"ubuntu"* ]] || [[ "nikolaik/python-nodejs:python3.13-nodejs24-slim" == *"mswebench"* ]]; then \
76+
if [[ "nikolaik/python-nodejs:python3.13-nodejs24-slim" == *"ubuntu"* ]]; then \
6977
# Handle Ubuntu (following https://docs.docker.com/engine/install/ubuntu/)
7078
# Add Docker's official GPG key
7179
apt-get update && \
@@ -84,13 +92,8 @@ RUN \
8492
install -m 0755 -d /etc/apt/keyrings && \
8593
curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc && \
8694
chmod a+r /etc/apt/keyrings/docker.asc && \
87-
# Add the repository to Apt sources
88-
# For Debian, if it's noble (testing/unstable), use bookworm (stable) repository
89-
if [ "$(lsb_release -cs)" = "noble" ]; then \
90-
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian bookworm stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null; \
91-
else \
92-
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null; \
93-
fi; \
95+
# Add the repository to Apt sources (default to bookworm for stability)
96+
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian bookworm stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null; \
9497
fi && \
9598
# Install Docker Engine, containerd, and Docker Compose
9699
apt-get update && \
@@ -101,6 +104,8 @@ RUN \
101104
# Configure Docker daemon with MTU 1450 to prevent packet fragmentation issues
102105
RUN mkdir -p /etc/docker && \
103106
echo '{"mtu": 1450}' > /etc/docker/daemon.json
107+
108+
104109
# ================================================================
105110

106111

@@ -113,7 +118,7 @@ RUN mkdir -p /openhands/micromamba/bin && \
113118

114119
# Create the openhands virtual environment and install poetry and python
115120
RUN /openhands/micromamba/bin/micromamba create -n openhands -y && \
116-
/openhands/micromamba/bin/micromamba install -n openhands -c conda-forge poetry python=3.13 -y
121+
/openhands/micromamba/bin/micromamba install -n openhands -c conda-forge poetry python=3.12 -y
117122

118123
# Create a clean openhands directory including only the pyproject.toml, poetry.lock and openhands/__init__.py
119124
RUN \
@@ -133,14 +138,12 @@ WORKDIR /openhands/code
133138
RUN \
134139
/openhands/micromamba/bin/micromamba config set changeps1 False && \
135140
/openhands/micromamba/bin/micromamba run -n openhands poetry config virtualenvs.path /openhands/poetry && \
136-
/openhands/micromamba/bin/micromamba run -n openhands poetry env use python3.13 && \
141+
/openhands/micromamba/bin/micromamba run -n openhands poetry env use python3.12 && \
137142
# Install project dependencies
138143
/openhands/micromamba/bin/micromamba run -n openhands poetry install --only main,runtime --no-interaction --no-root && \
139144
# Update and install additional tools
140145
# (There used to be an "apt-get update" here, hopefully we can skip it.)
141-
142146
/openhands/micromamba/bin/micromamba run -n openhands poetry run playwright install --with-deps chromium && \
143-
144147
# Set environment variables
145148
/openhands/micromamba/bin/micromamba run -n openhands poetry run python -c "import sys; print('OH_INTERPRETER_PATH=' + sys.executable)" >> /etc/environment && \
146149
# Set permissions
@@ -198,7 +201,8 @@ RUN if [ -z "${RELEASE_TAG}" ]; then \
198201
# ================================================================
199202
RUN if [ -d /openhands/code/openhands ]; then rm -rf /openhands/code/openhands; fi
200203
COPY ./code/pyproject.toml ./code/poetry.lock /openhands/code/
201-
204+
RUN if [ -d /openhands/code/microagents ]; then rm -rf /openhands/code/microagents; fi
205+
COPY ./code/microagents /openhands/code/microagents
202206
COPY ./code/openhands /openhands/code/openhands
203207
RUN chmod a+rwx /openhands/code/openhands/__init__.py
204208

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
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.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
name: add_agent
3+
type: knowledge
4+
version: 1.0.0
5+
agent: CodeActAgent
6+
triggers:
7+
- new agent
8+
- new microagent
9+
- create agent
10+
- create an agent
11+
- create microagent
12+
- create a microagent
13+
- add agent
14+
- add an agent
15+
- add microagent
16+
- add a microagent
17+
- microagent template
18+
---
19+
20+
This agent helps create new microagents in the `.openhands/microagents` directory by providing guidance and templates.
21+
22+
Microagents are specialized prompts that provide context and capabilities for specific domains or tasks. They are activated by trigger words in the conversation and help the AI assistant understand what capabilities are available, how to use specific APIs or tools, what limitations exist, and how to handle common scenarios.
23+
24+
When creating a new microagent:
25+
26+
- Create a markdown file in `.openhands/microagents/` with an appropriate name (e.g., `github.md`, `google_workspace.md`)
27+
- Include YAML frontmatter with metadata (name, type, version, agent, triggers)
28+
- type is by DEFAULT knowledge
29+
- version is DEFAULT 1.0.0
30+
- agent is by DEFAULT CodeActAgent
31+
- Document any credentials, environment variables, or API access needed
32+
- Keep trigger words specific to avoid false activations
33+
- Include error handling guidance and limitations
34+
- Provide clear usage examples
35+
- Keep the prompt focused and concise
36+
37+
For detailed information, see:
38+
39+
- [Microagents Overview](https://docs.all-hands.dev/usage/prompting/microagents-overview)
40+
- [Example GitHub Microagent](https://github.com/All-Hands-AI/OpenHands/blob/main/microagents/github.md)
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
name: add_repo_inst
3+
version: 1.0.0
4+
author: openhands
5+
agent: CodeActAgent
6+
triggers:
7+
- /add_repo_inst
8+
inputs:
9+
- name: REPO_FOLDER_NAME
10+
description: "Branch for the agent to work on"
11+
---
12+
13+
Please browse the current repository under /workspace/{{ REPO_FOLDER_NAME }}, look at the documentation and relevant code, and understand the purpose of this repository.
14+
15+
Specifically, I want you to create a `.openhands/microagents/repo.md` file. This file should contain succinct information that summarizes (1) the purpose of this repository, (2) the general setup of this repo, and (3) a brief description of the structure of this repo.
16+
17+
Here's an example:
18+
```markdown
19+
---
20+
name: repo
21+
type: repo
22+
agent: CodeActAgent
23+
---
24+
25+
This repository contains the code for OpenHands, an automated AI software engineer. It has a Python backend
26+
(in the `openhands` directory) and React frontend (in the `frontend` directory).
27+
28+
## General Setup:
29+
To set up the entire repo, including frontend and backend, run `make build`.
30+
You don't need to do this unless the user asks you to, or if you're trying to run the entire application.
31+
32+
Before pushing any changes, you should ensure that any lint errors or simple test errors have been fixed.
33+
34+
* If you've made changes to the backend, you should run `pre-commit run --all-files --config ./dev_config/python/.pre-commit-config.yaml`
35+
* If you've made changes to the frontend, you should run `cd frontend && npm run lint:fix && npm run build ; cd ..`
36+
37+
If either command fails, it may have automatically fixed some issues. You should fix any issues that weren't automatically fixed,
38+
then re-run the command to ensure it passes.
39+
40+
## Repository Structure
41+
Backend:
42+
- Located in the `openhands` directory
43+
- Testing:
44+
- All tests are in `tests/unit/test_*.py`
45+
- To test new code, run `poetry run pytest tests/unit/test_xxx.py` where `xxx` is the appropriate file for the current functionality
46+
- Write all tests with pytest
47+
48+
Frontend:
49+
- Located in the `frontend` directory
50+
- Prerequisites: A recent version of NodeJS / NPM
51+
- Setup: Run `npm install` in the frontend directory
52+
- Testing:
53+
- Run tests: `npm run test`
54+
- To run specific tests: `npm run test -- -t "TestName"`
55+
- Building:
56+
- Build for production: `npm run build`
57+
- Environment Variables:
58+
- Set in `frontend/.env` or as environment variables
59+
- Available variables: VITE_BACKEND_HOST, VITE_USE_TLS, VITE_INSECURE_SKIP_VERIFY, VITE_FRONTEND_PORT
60+
- Internationalization:
61+
- Generate i18n declaration file: `npm run make-i18n`
62+
```
63+
64+
Now, please write a similar markdown for the current repository.
65+
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.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: address_pr_comments
3+
version: 1.0.0
4+
author: openhands
5+
agent: CodeActAgent
6+
triggers:
7+
- /address_pr_comments
8+
inputs:
9+
- name: PR_URL
10+
description: "URL of the pull request"
11+
- name: BRANCH_NAME
12+
description: "Branch name corresponds to the pull request"
13+
---
14+
15+
First, check the branch {{ BRANCH_NAME }} and read the diff against the main branch to understand the purpose.
16+
17+
This branch corresponds to this PR {{ PR_URL }}
18+
19+
Next, you should use the GitHub API to read the reviews and comments on this PR and address them.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
name: agent_memory
3+
type: knowledge
4+
version: 1.0.0
5+
agent: CodeActAgent
6+
triggers:
7+
- /remember
8+
---
9+
10+
* Repository memory: Use .openhands/microagents/repo.md under each repository root to store and access important information.
11+
- If this file exists, it will be added to your context automatically.
12+
- If missing, you should create it unless the user has explicitly asked you to not do so.
13+
14+
* Store and maintain **general knowledge** that will be helpful for most future tasks:
15+
1. Repository structure
16+
2. Common commands (build, lint, test, pre-commit, etc.)
17+
3. Code style preferences
18+
4. Workflows and best practices
19+
5. Any other repository-specific knowledge you learn
20+
21+
* IMPORTANT: ONLY LOG the information that would be helpful for different future tasks, for example, how to configure the settings, how to setup the repository. Do NOT add issue-specific information (e.g., what specific error you have ran into and how you fix it).
22+
23+
* When adding new information:
24+
- ALWAYS ask for user confirmation first by listing the exact items (numbered 1, 2, 3, etc.) you plan to save to repo.md
25+
- Only save the items the user approves (they may ask you to save a subset)
26+
- Ensure it integrates nicely with existing knowledge in repo.md
27+
- Reorganize the content if needed to maintain clarity and organization
28+
- Group related information together under appropriate sections or headings
29+
- If you've only explored a portion of the codebase, clearly note this limitation in the repository structure documentation
30+
- 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)
31+
32+
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.

0 commit comments

Comments
 (0)