Spaces:
Configuration error
Configuration error
upload
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- .dockerignoreAdded+5
- .gitattributes+9-35
- .github/.codecov.ymlAdded+19
- .github/ISSUE_TEMPLATE/bug_template.ymlAdded+62
- .github/ISSUE_TEMPLATE/feature_request.mdAdded+18
- .github/ISSUE_TEMPLATE/technical_proposal.mdAdded+18
- .github/dependabot.ymlAdded+71
- .github/pull_request_template.mdAdded+12
- .github/scripts/check_version_consistency.pyAdded+66
- .github/workflows/clean-up.ymlAdded+69
- .github/workflows/deploy-docs.ymlAdded+72
- .github/workflows/dummy-agent-test.ymlAdded+53
- .github/workflows/fe-unit-tests.ymlAdded+48
- .github/workflows/ghcr-build.ymlAdded+402
- .github/workflows/integration-runner.ymlAdded+199
- .github/workflows/lint-fix.ymlAdded+91
- .github/workflows/lint.ymlAdded+68
- .github/workflows/openhands-resolver.ymlAdded+419
- .github/workflows/py-unit-tests.ymlAdded+55
- .github/workflows/pypi-release.ymlAdded+31
- .github/workflows/run-eval.ymlAdded+53
- .github/workflows/stale.ymlAdded+22
- .gitignoreAdded+235
- .nvmrcAdded+1
- .openhands/microagents/glossary.mdAdded+172
- .openhands/microagents/repo.mdAdded+48
- .openhands/setup.shAdded+5
- CITATION.cffAdded+55
- CODE_OF_CONDUCT.mdAdded+147
- COMMUNITY.mdAdded+43
- CONTRIBUTING.mdAdded+123
- CREDITS.mdAdded+312
- Development.mdAdded+163
- ISSUE_TRIAGE.mdAdded+32
- LICENSEAdded+25
- MANIFEST.inAdded+5
- MakefileAdded+303
- README.md+139-8
- build.shAdded+4
- config.template.tomlAdded+386
- containers/README.mdAdded+12
- containers/app/DockerfileAdded+98
- containers/app/config.shAdded+4
- containers/app/entrypoint.shAdded+69
- containers/build.shAdded+156
- containers/dev/DockerfileAdded+124
- containers/dev/README.mdAdded+57
- containers/dev/compose.ymlAdded+38
- containers/dev/dev.shAdded+39
- containers/e2b-sandbox/DockerfileAdded+19
12345frontend/node_modulesconfig.toml.envrc.env.git1234567891011121314151617181920212223242526272829303132333435123456789*.7z filter=lfs diff=lfs merge=lfs -text*.arrow filter=lfs diff=lfs merge=lfs -text*.bin filter=lfs diff=lfs merge=lfs -text*.bz2 filter=lfs diff=lfs merge=lfs -text*.ckpt filter=lfs diff=lfs merge=lfs -text*.ftz filter=lfs diff=lfs merge=lfs -text*.gz filter=lfs diff=lfs merge=lfs -text*.h5 filter=lfs diff=lfs merge=lfs -text*.joblib filter=lfs diff=lfs merge=lfs -text*.lfs.* filter=lfs diff=lfs merge=lfs -text*.mlmodel filter=lfs diff=lfs merge=lfs -text*.model filter=lfs diff=lfs merge=lfs -text*.msgpack filter=lfs diff=lfs merge=lfs -text*.npy filter=lfs diff=lfs merge=lfs -text*.npz filter=lfs diff=lfs merge=lfs -text*.onnx filter=lfs diff=lfs merge=lfs -text*.ot filter=lfs diff=lfs merge=lfs -text*.parquet filter=lfs diff=lfs merge=lfs -text*.pb filter=lfs diff=lfs merge=lfs -text*.pickle filter=lfs diff=lfs merge=lfs -text*.pkl filter=lfs diff=lfs merge=lfs -text*.pt filter=lfs diff=lfs merge=lfs -text*.pth filter=lfs diff=lfs merge=lfs -text*.rar filter=lfs diff=lfs merge=lfs -text*.safetensors filter=lfs diff=lfs merge=lfs -textsaved_model/**/* filter=lfs diff=lfs merge=lfs -text*.tar.* filter=lfs diff=lfs merge=lfs -text*.tar filter=lfs diff=lfs merge=lfs -text*.tflite filter=lfs diff=lfs merge=lfs -text*.tgz filter=lfs diff=lfs merge=lfs -text*.wasm filter=lfs diff=lfs merge=lfs -text*.xz filter=lfs diff=lfs merge=lfs -text*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text*.ipynb linguist-vendoreddocs/static/img/backend_architecture.png filter=lfs diff=lfs merge=lfs -textdocs/static/img/logo-square.png filter=lfs diff=lfs merge=lfs -textdocs/static/img/results.png filter=lfs diff=lfs merge=lfs -textdocs/static/img/screenshot.png filter=lfs diff=lfs merge=lfs -textdocs/static/img/system_architecture_overview.png filter=lfs diff=lfs merge=lfs -textdocs/static/img/teaser.mp4 filter=lfs diff=lfs merge=lfs -textevaluation/static/example_task_1.png filter=lfs diff=lfs merge=lfs -textfrontend/src/assets/logo.png filter=lfs diff=lfs merge=lfs -text12345678910111213141516171819codecov: notify: wait_for_ci: true # our project is large, so 6 builds are typically uploaded. this waits till 5/6 # See https://docs.codecov.com/docs/notifications#section-preventing-notifications-until-after-n-builds after_n_builds: 5
coverage: status: patch: default: threshold: 100% # allow patch coverage to be lower than project coverage by any amount project: default: threshold: 5% # allow project coverage to drop at most 5%
comment: falsegithub_checks: annotations: false1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162name: Bugdescription: Report a problem with OpenHandstitle: '[Bug]: 'labels: ['bug']body: - type: markdown attributes: value: Thank you for taking the time to fill out this bug report. Please provide as much information as possible to help us understand and address the issue effectively.
- type: checkboxes attributes: label: Is there an existing issue for the same bug? description: Please check if an issue already exists for the bug you encountered. options: - label: I have checked the existing issues. required: true
- type: textarea id: bug-description attributes: label: Describe the bug and reproduction steps description: Provide a description of the issue along with any reproduction steps. validations: required: true
- type: dropdown id: installation attributes: label: OpenHands Installation description: How are you running OpenHands? options: - Docker command in README - GitHub resolver - Development workflow - app.all-hands.dev - Other default: 0
- type: input id: openhands-version attributes: label: OpenHands Version description: What version of OpenHands are you using? placeholder: ex. 0.9.8, main, etc.
- type: dropdown id: os attributes: label: Operating System options: - MacOS - Linux - WSL on Windows
- type: textarea id: additional-context attributes: label: Logs, Errors, Screenshots, and Additional Context description: Please provide any additional information you think might help. If you want to share the chat history you can click the thumbs-down (👎) button above the input field and you will get a shareable link (you can also click thumbs up when things are going well of course!). LLM logs will be stored in the `logs/llm/default` folder. Please add any additional context about the problem here.123456789101112131415161718---name: Feature Requestabout: Suggest an idea for OpenHands featurestitle: ''labels: 'enhancement'assignees: ''
---
**What problem or use case are you trying to solve?**
**Describe the UX of the solution you'd like**
**Do you have thoughts on the technical implementation?**
**Describe alternatives you've considered**
**Additional context**123456789101112131415161718---name: Technical Proposalabout: Propose a new architecture or technologytitle: ''labels: 'proposal'assignees: ''
---
**Summary**
**Motivation**
**Technical Design**
**Alternatives to Consider**
**Additional context**1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071version: 2updates: - package-ecosystem: "pip" directory: "/" schedule: interval: "daily" open-pull-requests-limit: 1 groups: # put packages in their own group if they have a history of breaking the build or needing to be reverted pre-commit: patterns: - "pre-commit" browsergym: patterns: - "browsergym*" security-all: applies-to: "security-updates" patterns: - "*" version-all: applies-to: "version-updates" patterns: - "*"
- package-ecosystem: "npm" directory: "/frontend" schedule: interval: "daily" open-pull-requests-limit: 1 groups: docusaurus: patterns: - "*docusaurus*" eslint: patterns: - "*eslint*" security-all: applies-to: "security-updates" patterns: - "*" version-all: applies-to: "version-updates" patterns: - "*"
- package-ecosystem: "npm" directory: "/docs" schedule: interval: "weekly" day: "wednesday" open-pull-requests-limit: 1 groups: docusaurus: patterns: - "*docusaurus*" eslint: patterns: - "*eslint*" security-all: applies-to: "security-updates" patterns: - "*" version-all: applies-to: "version-updates" patterns: - "*"
- package-ecosystem: "github-actions" directory: "/" schedule: interval: "weekly"123456789101112- [ ] This change is worth documenting at https://docs.all-hands.dev/- [ ] Include this change in the Release Notes. If checked, you **must** provide an **end-user friendly** description for your change below
**End-user friendly description of the problem this fixes or functionality that this introduces.**
---**Give a summary of what the PR does, explaining any non-trivial design decisions.**
---**Link of any specific issues this addresses.**123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566#!/usr/bin/env python3import osimport reimport sysfrom typing import Set, Tuple
def find_version_references(directory: str) -> Tuple[Set[str], Set[str]]: openhands_versions = set() runtime_versions = set()
version_pattern_openhands = re.compile(r'openhands:(\d{1})\.(\d{2})') version_pattern_runtime = re.compile(r'runtime:(\d{1})\.(\d{2})')
for root, _, files in os.walk(directory): # Skip .git directory if '.git' in root: continue
for file in files: if file.endswith( ('.md', '.yml', '.yaml', '.txt', '.html', '.py', '.js', '.ts') ): file_path = os.path.join(root, file) try: with open(file_path, 'r', encoding='utf-8') as f: content = f.read()
# Find all openhands version references matches = version_pattern_openhands.findall(content) openhands_versions.update(matches)
# Find all runtime version references matches = version_pattern_runtime.findall(content) runtime_versions.update(matches) except Exception as e: print(f'Error reading {file_path}: {e}', file=sys.stderr)
return openhands_versions, runtime_versions
def main(): repo_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')) openhands_versions, runtime_versions = find_version_references(repo_root)
exit_code = 0
if len(openhands_versions) > 1: print('Error: Multiple openhands versions found:', file=sys.stderr) print('Found versions:', sorted(openhands_versions), file=sys.stderr) exit_code = 1 elif len(openhands_versions) == 0: print('Warning: No openhands version references found', file=sys.stderr)
if len(runtime_versions) > 1: print('Error: Multiple runtime versions found:', file=sys.stderr) print('Found versions:', sorted(runtime_versions), file=sys.stderr) exit_code = 1 elif len(runtime_versions) == 0: print('Warning: No runtime version references found', file=sys.stderr)
sys.exit(exit_code)
if __name__ == '__main__': main()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869# Workflow that cleans up outdated and old workflows to prevent out of disk issuesname: Delete old workflow runs
# This workflow is currently only triggered manuallyon: workflow_dispatch: inputs: days: description: 'Days-worth of runs to keep for each workflow' required: true default: '30' minimum_runs: description: 'Minimum runs to keep for each workflow' required: true default: '10' delete_workflow_pattern: description: 'Name or filename of the workflow (if not set, all workflows are targeted)' required: false delete_workflow_by_state_pattern: description: 'Filter workflows by state: active, deleted, disabled_fork, disabled_inactivity, disabled_manually' required: true default: "ALL" type: choice options: - "ALL" - active - deleted - disabled_inactivity - disabled_manually delete_run_by_conclusion_pattern: description: 'Remove runs based on conclusion: action_required, cancelled, failure, skipped, success' required: true default: 'ALL' type: choice options: - 'ALL' - 'Unsuccessful: action_required,cancelled,failure,skipped' - action_required - cancelled - failure - skipped - success dry_run: description: 'Logs simulated changes, no deletions are performed' required: false
jobs: del_runs: runs-on: blacksmith-4vcpu-ubuntu-2204 permissions: actions: write contents: read steps: - name: Delete workflow runs uses: Mattraks/delete-workflow-runs@v2 with: token: ${{ github.token }} repository: ${{ github.repository }} retain_days: ${{ github.event.inputs.days }} keep_minimum_runs: ${{ github.event.inputs.minimum_runs }} delete_workflow_pattern: ${{ github.event.inputs.delete_workflow_pattern }} delete_workflow_by_state_pattern: ${{ github.event.inputs.delete_workflow_by_state_pattern }} delete_run_by_conclusion_pattern: >- ${{ startsWith(github.event.inputs.delete_run_by_conclusion_pattern, 'Unsuccessful:') && 'action_required,cancelled,failure,skipped' || github.event.inputs.delete_run_by_conclusion_pattern }} dry_run: ${{ github.event.inputs.dry_run }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172# Workflow that builds and deploys the documentation websitename: Deploy Docs to GitHub Pages
# * Always run on "main"# * Run on PRs that target the "main" branch and have changes in the "docs" folder or this workflowon: push: branches: - main pull_request: paths: - 'docs/**' - '.github/workflows/deploy-docs.yml' branches: - main
# If triggered by a PR, it will be in the same group. However, each commit on main will be in its own unique groupconcurrency: group: ${{ github.workflow }}-${{ (github.head_ref && github.ref) || github.run_id }} cancel-in-progress: true
jobs: # Build the documentation website build: if: github.repository == 'All-Hands-AI/OpenHands' name: Build Docusaurus runs-on: blacksmith-4vcpu-ubuntu-2204 steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - uses: useblacksmith/setup-node@v5 with: node-version: 18 cache: npm cache-dependency-path: docs/package-lock.json - name: Set up Python uses: useblacksmith/setup-python@v6 with: python-version: '3.12' - name: Install dependencies run: cd docs && npm ci - name: Build website run: cd docs && npm run build - name: Upload Build Artifact if: github.ref == 'refs/heads/main' uses: actions/upload-pages-artifact@v3 with: path: docs/build
# Deploy the documentation website deploy: if: github.ref == 'refs/heads/main' && github.repository == 'All-Hands-AI/OpenHands' name: Deploy to GitHub Pages runs-on: blacksmith-4vcpu-ubuntu-2204 # This job only runs on "main" so only run one of these jobs at a time # otherwise it will fail if one is already running concurrency: group: ${{ github.workflow }}-${{ github.ref }} needs: build # Grant GITHUB_TOKEN the permissions required to make a Pages deployment permissions: pages: write # to deploy to Pages id-token: write # to verify the deployment originates from an appropriate source # Deploy to the github-pages environment environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} steps: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v41234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253# Workflow that uses the DummyAgent to run a simple taskname: Run E2E test with dummy agent
# Always run on "main"# Always run on PRson: push: branches: - main pull_request:
# If triggered by a PR, it will be in the same group. However, each commit on main will be in its own unique groupconcurrency: group: ${{ github.workflow }}-${{ (github.head_ref && github.ref) || github.run_id }} cancel-in-progress: true
jobs: test: runs-on: blacksmith-4vcpu-ubuntu-2204 steps: - uses: actions/checkout@v4 - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v3 - name: Install tmux run: sudo apt-get update && sudo apt-get install -y tmux - name: Setup Node.js uses: useblacksmith/setup-node@v5 with: node-version: '22.x' - name: Install poetry via pipx run: pipx install poetry - name: Set up Python uses: useblacksmith/setup-python@v6 with: python-version: '3.12' cache: 'poetry' - name: Install Python dependencies using Poetry run: poetry install --without evaluation - name: Build Environment run: make build - name: Run tests run: | set -e SANDBOX_FORCE_REBUILD_RUNTIME=True poetry run python3 openhands/core/main.py -t "do a flip" -d ./workspace/ -c DummyAgent - name: Check exit code run: | if [ $? -ne 0 ]; then echo "Test failed" exit 1 else echo "Test passed" fi123456789101112131415161718192021222324252627282930313233343536373839404142434445464748# Workflow that runs frontend unit testsname: Run Frontend Unit Tests
# * Always run on "main"# * Run on PRs that have changes in the "frontend" folder or this workflowon: push: branches: - main pull_request: paths: - 'frontend/**' - '.github/workflows/fe-unit-tests.yml'
# If triggered by a PR, it will be in the same group. However, each commit on main will be in its own unique groupconcurrency: group: ${{ github.workflow }}-${{ (github.head_ref && github.ref) || github.run_id }} cancel-in-progress: true
jobs: # Run frontend unit tests fe-test: name: FE Unit Tests runs-on: blacksmith-4vcpu-ubuntu-2204 strategy: matrix: node-version: [20, 22] fail-fast: true steps: - name: Checkout uses: actions/checkout@v4 - name: Set up Node.js uses: useblacksmith/setup-node@v5 with: node-version: ${{ matrix.node-version }} - name: Install dependencies working-directory: ./frontend run: npm ci - name: Run TypeScript compilation working-directory: ./frontend run: npm run make-i18n && tsc - name: Run tests and collect coverage working-directory: ./frontend run: npm run test:coverage - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402# Workflow that builds, tests and then pushes the OpenHands and runtime docker images to the ghcr.io repositoryname: Docker
# Always run on "main"# Always run on tags# Always run on PRs# Can also be triggered manuallyon: push: branches: - main tags: - '*' pull_request: workflow_dispatch: inputs: reason: description: 'Reason for manual trigger' required: true default: ''
# If triggered by a PR, it will be in the same group. However, each commit on main will be in its own unique groupconcurrency: group: ${{ github.workflow }}-${{ (github.head_ref && github.ref) || github.run_id }} cancel-in-progress: true
env: BASE_IMAGE_FOR_HASH_EQUIVALENCE_TEST: nikolaik/python-nodejs:python3.12-nodejs22 RELEVANT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
jobs: # Builds the OpenHands Docker images ghcr_build_app: name: Build App Image runs-on: blacksmith-4vcpu-ubuntu-2204 permissions: contents: read packages: write outputs: hash_from_app_image: ${{ steps.get_hash_in_app_image.outputs.hash_from_app_image }} steps: - name: Checkout uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} - name: Set up QEMU uses: docker/setup-qemu-action@v3.6.0 with: image: tonistiigi/binfmt:latest - name: Login to GHCR uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v3 - name: Lowercase Repository Owner run: | echo REPO_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV - name: Build and push app image if: "!github.event.pull_request.head.repo.fork" run: | ./containers/build.sh -i openhands -o ${{ env.REPO_OWNER }} --push - name: Build app image if: "github.event.pull_request.head.repo.fork" run: | ./containers/build.sh -i openhands -o ${{ env.REPO_OWNER }} --load - name: Get hash in App Image id: get_hash_in_app_image run: | # Run the build script in the app image docker run -e SANDBOX_USER_ID=0 -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/${{ env.REPO_OWNER }}/openhands:${{ env.RELEVANT_SHA }} /bin/bash -c "mkdir -p containers/runtime; python3 openhands/runtime/utils/runtime_build.py --base_image ${{ env.BASE_IMAGE_FOR_HASH_EQUIVALENCE_TEST }} --build_folder containers/runtime --force_rebuild" 2>&1 | tee docker-outputs.txt # Get the hash from the build script hash_from_app_image=$(cat docker-outputs.txt | grep "Hash for docker build directory" | awk -F "): " '{print $2}' | uniq | head -n1) echo "hash_from_app_image=$hash_from_app_image" >> $GITHUB_OUTPUT echo "Hash from app image: $hash_from_app_image"
# Builds the runtime Docker images ghcr_build_runtime: name: Build Image runs-on: blacksmith-4vcpu-ubuntu-2204 permissions: contents: read packages: write strategy: matrix: base_image: - image: 'nikolaik/python-nodejs:python3.12-nodejs22' tag: nikolaik steps: - name: Checkout uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} - name: Set up QEMU uses: docker/setup-qemu-action@v3.6.0 with: image: tonistiigi/binfmt:latest - name: Login to GHCR uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v3 - name: Set up Python uses: useblacksmith/setup-python@v6 with: python-version: '3.12' - name: Cache Poetry dependencies uses: useblacksmith/cache@v5 with: path: | ~/.cache/pypoetry ~/.virtualenvs key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} restore-keys: | ${{ runner.os }}-poetry- - name: Install poetry via pipx run: pipx install poetry - name: Install Python dependencies using Poetry run: make install-python-dependencies - name: Create source distribution and Dockerfile run: poetry run python3 openhands/runtime/utils/runtime_build.py --base_image ${{ matrix.base_image.image }} --build_folder containers/runtime --force_rebuild - name: Lowercase Repository Owner run: | echo REPO_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV - name: Build and push runtime image ${{ matrix.base_image.image }} if: github.event.pull_request.head.repo.fork != true run: | ./containers/build.sh -i runtime -o ${{ env.REPO_OWNER }} --push -t ${{ matrix.base_image.tag }} # Forked repos can't push to GHCR, so we need to upload the image as an artifact - name: Build runtime image ${{ matrix.base_image.image }} for fork if: github.event.pull_request.head.repo.fork uses: docker/build-push-action@v6 with: tags: ghcr.io/${{ env.REPO_OWNER }}/runtime:${{ env.RELEVANT_SHA }}-${{ matrix.base_image.tag }} outputs: type=docker,dest=/tmp/runtime-${{ matrix.base_image.tag }}.tar context: containers/runtime - name: Upload runtime image for fork if: github.event.pull_request.head.repo.fork uses: actions/upload-artifact@v4 with: name: runtime-${{ matrix.base_image.tag }} path: /tmp/runtime-${{ matrix.base_image.tag }}.tar
verify_hash_equivalence_in_runtime_and_app: name: Verify Hash Equivalence in Runtime and Docker images runs-on: blacksmith-4vcpu-ubuntu-2204 needs: [ghcr_build_runtime, ghcr_build_app] strategy: fail-fast: false matrix: base_image: ['nikolaik'] steps: - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} - name: Cache Poetry dependencies uses: useblacksmith/cache@v5 with: path: | ~/.cache/pypoetry ~/.virtualenvs key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} restore-keys: | ${{ runner.os }}-poetry- - name: Set up Python uses: useblacksmith/setup-python@v6 with: python-version: '3.12' - name: Install poetry via pipx run: pipx install poetry - name: Install Python dependencies using Poetry run: make install-python-dependencies - name: Get hash in App Image run: | echo "Hash from app image: ${{ needs.ghcr_build_app.outputs.hash_from_app_image }}" echo "hash_from_app_image=${{ needs.ghcr_build_app.outputs.hash_from_app_image }}" >> $GITHUB_ENV
- name: Get hash using code (development mode) run: | mkdir -p containers/runtime poetry run python3 openhands/runtime/utils/runtime_build.py --base_image ${{ env.BASE_IMAGE_FOR_HASH_EQUIVALENCE_TEST }} --build_folder containers/runtime --force_rebuild > output.txt 2>&1 hash_from_code=$(cat output.txt | grep "Hash for docker build directory" | awk -F "): " '{print $2}' | uniq | head -n1) echo "hash_from_code=$hash_from_code" >> $GITHUB_ENV
- name: Compare hashes run: | echo "Hash from App Image: ${{ env.hash_from_app_image }}" echo "Hash from Code: ${{ env.hash_from_code }}" if [ "${{ env.hash_from_app_image }}" = "${{ env.hash_from_code }}" ]; then echo "Hashes match!" else echo "Hashes do not match!" exit 1 fi
# Run unit tests with the Docker runtime Docker images as root test_runtime_root: name: RT Unit Tests (Root) needs: [ghcr_build_runtime] runs-on: blacksmith-4vcpu-ubuntu-2204 strategy: fail-fast: false matrix: base_image: ['nikolaik'] steps: - uses: actions/checkout@v4 - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v3 # Forked repos can't push to GHCR, so we need to download the image as an artifact - name: Download runtime image for fork if: github.event.pull_request.head.repo.fork uses: actions/download-artifact@v4 with: name: runtime-${{ matrix.base_image }} path: /tmp - name: Load runtime image for fork if: github.event.pull_request.head.repo.fork run: | docker load --input /tmp/runtime-${{ matrix.base_image }}.tar - name: Cache Poetry dependencies uses: useblacksmith/cache@v5 with: path: | ~/.cache/pypoetry ~/.virtualenvs key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} restore-keys: | ${{ runner.os }}-poetry- - name: Set up Python uses: useblacksmith/setup-python@v6 with: python-version: '3.12' - name: Install poetry via pipx run: pipx install poetry - name: Install Python dependencies using Poetry run: make install-python-dependencies - name: Lowercase Repository Owner run: | echo REPO_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV - name: Run docker runtime tests run: | # We install pytest-xdist in order to run tests across CPUs poetry run pip install pytest-xdist
# Install to be able to retry on failures for flaky tests poetry run pip install pytest-rerunfailures
image_name=ghcr.io/${{ env.REPO_OWNER }}/runtime:${{ env.RELEVANT_SHA }}-${{ matrix.base_image }}
TEST_RUNTIME=docker \ SANDBOX_USER_ID=$(id -u) \ SANDBOX_RUNTIME_CONTAINER_IMAGE=$image_name \ TEST_IN_CI=true \ RUN_AS_OPENHANDS=false \ poetry run pytest -n 3 -raRs --reruns 2 --reruns-delay 5 --cov=openhands --cov-report=xml -s ./tests/runtime --ignore=tests/runtime/test_browsergym_envs.py - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# Run unit tests with the Docker runtime Docker images as openhands user test_runtime_oh: name: RT Unit Tests (openhands) runs-on: blacksmith-4vcpu-ubuntu-2204 needs: [ghcr_build_runtime] strategy: matrix: base_image: ['nikolaik'] steps: - uses: actions/checkout@v4 - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v3 # Forked repos can't push to GHCR, so we need to download the image as an artifact - name: Download runtime image for fork if: github.event.pull_request.head.repo.fork uses: actions/download-artifact@v4 with: name: runtime-${{ matrix.base_image }} path: /tmp - name: Load runtime image for fork if: github.event.pull_request.head.repo.fork run: | docker load --input /tmp/runtime-${{ matrix.base_image }}.tar - name: Cache Poetry dependencies uses: useblacksmith/cache@v5 with: path: | ~/.cache/pypoetry ~/.virtualenvs key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} restore-keys: | ${{ runner.os }}-poetry- - name: Set up Python uses: useblacksmith/setup-python@v6 with: python-version: '3.12' - name: Install poetry via pipx run: pipx install poetry - name: Install Python dependencies using Poetry run: make install-python-dependencies - name: Lowercase Repository Owner run: | echo REPO_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV - name: Run runtime tests run: | # We install pytest-xdist in order to run tests across CPUs poetry run pip install pytest-xdist
# Install to be able to retry on failures for flaky tests poetry run pip install pytest-rerunfailures
image_name=ghcr.io/${{ env.REPO_OWNER }}/runtime:${{ env.RELEVANT_SHA }}-${{ matrix.base_image }}
TEST_RUNTIME=docker \ SANDBOX_USER_ID=$(id -u) \ SANDBOX_RUNTIME_CONTAINER_IMAGE=$image_name \ TEST_IN_CI=true \ RUN_AS_OPENHANDS=true \ poetry run pytest -n 3 -raRs --reruns 2 --reruns-delay 5 --cov=openhands --cov-report=xml -s ./tests/runtime --ignore=tests/runtime/test_browsergym_envs.py - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# The two following jobs (named identically) are to check whether all the runtime tests have passed as the # "All Runtime Tests Passed" is a required job for PRs to merge # Due to this bug: https://github.com/actions/runner/issues/2566, we want to create a job that runs when the # prerequisites have been cancelled or failed so merging is disallowed, otherwise Github considers "skipped" as "success" runtime_tests_check_success: name: All Runtime Tests Passed if: ${{ !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }} runs-on: blacksmith-4vcpu-ubuntu-2204 needs: [test_runtime_root, test_runtime_oh, verify_hash_equivalence_in_runtime_and_app] steps: - name: All tests passed run: echo "All runtime tests have passed successfully!"
runtime_tests_check_fail: name: All Runtime Tests Passed if: ${{ cancelled() || contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} runs-on: blacksmith-4vcpu-ubuntu-2204 needs: [test_runtime_root, test_runtime_oh, verify_hash_equivalence_in_runtime_and_app] steps: - name: Some tests failed run: | echo "Some runtime tests failed or were cancelled" exit 1 update_pr_description: name: Update PR Description if: github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' needs: [ghcr_build_runtime] runs-on: blacksmith-4vcpu-ubuntu-2204 steps: - name: Checkout uses: actions/checkout@v4
- name: Get short SHA id: short_sha run: echo "SHORT_SHA=$(echo ${{ github.event.pull_request.head.sha }} | cut -c1-7)" >> $GITHUB_OUTPUT
- name: Update PR Description env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ github.event.pull_request.number }} REPO: ${{ github.repository }} SHORT_SHA: ${{ steps.short_sha.outputs.SHORT_SHA }} run: | echo "updating PR description" DOCKER_RUN_COMMAND="docker run -it --rm \ -p 3000:3000 \ -v /var/run/docker.sock:/var/run/docker.sock \ --add-host host.docker.internal:host-gateway \ -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:$SHORT_SHA-nikolaik \ --name openhands-app-$SHORT_SHA \ docker.all-hands.dev/all-hands-ai/openhands:$SHORT_SHA"
PR_BODY=$(gh pr view $PR_NUMBER --json body --jq .body)
if echo "$PR_BODY" | grep -q "To run this PR locally, use the following command:"; then UPDATED_PR_BODY=$(echo "${PR_BODY}" | sed -E "s|docker run -it --rm.*|$DOCKER_RUN_COMMAND|") else UPDATED_PR_BODY="${PR_BODY}
---
To run this PR locally, use the following command: \`\`\` $DOCKER_RUN_COMMAND \`\`\`" fi
echo "updated body: $UPDATED_PR_BODY" gh pr edit $PR_NUMBER --body "$UPDATED_PR_BODY"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199name: Run Integration Tests
on: pull_request: types: [labeled] workflow_dispatch: inputs: reason: description: 'Reason for manual trigger' required: true default: '' schedule: - cron: '30 22 * * *' # Runs at 10:30pm UTC every day
env: N_PROCESSES: 10 # Global configuration for number of parallel processes for evaluation
jobs: run-integration-tests: if: github.event.label.name == 'integration-test' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' runs-on: blacksmith-4vcpu-ubuntu-2204 permissions: contents: "read" id-token: "write" pull-requests: "write" issues: "write" strategy: matrix: python-version: ["3.12"] steps: - name: Checkout repository uses: actions/checkout@v4
- name: Install poetry via pipx run: pipx install poetry
- name: Set up Python uses: useblacksmith/setup-python@v6 with: python-version: ${{ matrix.python-version }} cache: "poetry"
- name: Setup Node.js uses: useblacksmith/setup-node@v5 with: node-version: '22.x'
- name: Comment on PR if 'integration-test' label is present if: github.event_name == 'pull_request' && github.event.label.name == 'integration-test' uses: KeisukeYamashita/create-comment@v1 with: unique: false comment: | Hi! I started running the integration tests on your PR. You will receive a comment with the results shortly.
- name: Install Python dependencies using Poetry run: poetry install --without evaluation
- name: Configure config.toml for testing with Haiku env: LLM_MODEL: "litellm_proxy/claude-3-5-haiku-20241022" LLM_API_KEY: ${{ secrets.LLM_API_KEY }} LLM_BASE_URL: ${{ secrets.LLM_BASE_URL }} MAX_ITERATIONS: 10 run: | echo "[llm.eval]" > config.toml echo "model = \"$LLM_MODEL\"" >> config.toml echo "api_key = \"$LLM_API_KEY\"" >> config.toml echo "base_url = \"$LLM_BASE_URL\"" >> config.toml echo "temperature = 0.0" >> config.toml
- name: Build environment run: make build
- name: Run integration test evaluation for Haiku env: SANDBOX_FORCE_REBUILD_RUNTIME: True run: | poetry run ./evaluation/integration_tests/scripts/run_infer.sh llm.eval HEAD CodeActAgent '' 10 $N_PROCESSES '' 'haiku_run'
# get integration tests report REPORT_FILE_HAIKU=$(find evaluation/evaluation_outputs/outputs/integration_tests/CodeActAgent/*haiku*_maxiter_10_N* -name "report.md" -type f | head -n 1) echo "REPORT_FILE: $REPORT_FILE_HAIKU" echo "INTEGRATION_TEST_REPORT_HAIKU<<EOF" >> $GITHUB_ENV cat $REPORT_FILE_HAIKU >> $GITHUB_ENV echo >> $GITHUB_ENV echo "EOF" >> $GITHUB_ENV
- name: Wait a little bit run: sleep 10
- name: Configure config.toml for testing with DeepSeek env: LLM_MODEL: "litellm_proxy/deepseek-chat" LLM_API_KEY: ${{ secrets.LLM_API_KEY }} LLM_BASE_URL: ${{ secrets.LLM_BASE_URL }} MAX_ITERATIONS: 10 run: | echo "[llm.eval]" > config.toml echo "model = \"$LLM_MODEL\"" >> config.toml echo "api_key = \"$LLM_API_KEY\"" >> config.toml echo "base_url = \"$LLM_BASE_URL\"" >> config.toml echo "temperature = 0.0" >> config.toml
- name: Run integration test evaluation for DeepSeek env: SANDBOX_FORCE_REBUILD_RUNTIME: True run: | poetry run ./evaluation/integration_tests/scripts/run_infer.sh llm.eval HEAD CodeActAgent '' 10 $N_PROCESSES '' 'deepseek_run'
# get integration tests report REPORT_FILE_DEEPSEEK=$(find evaluation/evaluation_outputs/outputs/integration_tests/CodeActAgent/deepseek*_maxiter_10_N* -name "report.md" -type f | head -n 1) echo "REPORT_FILE: $REPORT_FILE_DEEPSEEK" echo "INTEGRATION_TEST_REPORT_DEEPSEEK<<EOF" >> $GITHUB_ENV cat $REPORT_FILE_DEEPSEEK >> $GITHUB_ENV echo >> $GITHUB_ENV echo "EOF" >> $GITHUB_ENV
# ------------------------------------------------------------- # Run VisualBrowsingAgent tests for DeepSeek, limited to t05 and t06 - name: Wait a little bit (again) run: sleep 5
- name: Configure config.toml for testing VisualBrowsingAgent (DeepSeek) env: LLM_MODEL: "litellm_proxy/deepseek-chat" LLM_API_KEY: ${{ secrets.LLM_API_KEY }} LLM_BASE_URL: ${{ secrets.LLM_BASE_URL }} MAX_ITERATIONS: 15 run: | echo "[llm.eval]" > config.toml echo "model = \"$LLM_MODEL\"" >> config.toml echo "api_key = \"$LLM_API_KEY\"" >> config.toml echo "base_url = \"$LLM_BASE_URL\"" >> config.toml echo "temperature = 0.0" >> config.toml - name: Run integration test evaluation for VisualBrowsingAgent (DeepSeek) env: SANDBOX_FORCE_REBUILD_RUNTIME: True run: | poetry run ./evaluation/integration_tests/scripts/run_infer.sh llm.eval HEAD VisualBrowsingAgent '' 15 $N_PROCESSES "t05_simple_browsing,t06_github_pr_browsing.py" 'visualbrowsing_deepseek_run'
# Find and export the visual browsing agent test results REPORT_FILE_VISUALBROWSING_DEEPSEEK=$(find evaluation/evaluation_outputs/outputs/integration_tests/VisualBrowsingAgent/deepseek*_maxiter_15_N* -name "report.md" -type f | head -n 1) echo "REPORT_FILE_VISUALBROWSING_DEEPSEEK: $REPORT_FILE_VISUALBROWSING_DEEPSEEK" echo "INTEGRATION_TEST_REPORT_VISUALBROWSING_DEEPSEEK<<EOF" >> $GITHUB_ENV cat $REPORT_FILE_VISUALBROWSING_DEEPSEEK >> $GITHUB_ENV echo >> $GITHUB_ENV echo "EOF" >> $GITHUB_ENV
- name: Create archive of evaluation outputs run: | TIMESTAMP=$(date +'%y-%m-%d-%H-%M') cd evaluation/evaluation_outputs/outputs # Change to the outputs directory tar -czvf ../../../integration_tests_${TIMESTAMP}.tar.gz integration_tests/CodeActAgent/* integration_tests/VisualBrowsingAgent/* # Only include the actual result directories
- name: Upload evaluation results as artifact uses: actions/upload-artifact@v4 id: upload_results_artifact with: name: integration-test-outputs-${{ github.run_id }}-${{ github.run_attempt }} path: integration_tests_*.tar.gz
- name: Get artifact URLs run: | echo "ARTIFACT_URL=${{ steps.upload_results_artifact.outputs.artifact-url }}" >> $GITHUB_ENV
- name: Set timestamp and trigger reason run: | echo "TIMESTAMP=$(date +'%Y-%m-%d-%H-%M')" >> $GITHUB_ENV if [[ "${{ github.event_name }}" == "pull_request" ]]; then echo "TRIGGER_REASON=pr-${{ github.event.pull_request.number }}" >> $GITHUB_ENV elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then echo "TRIGGER_REASON=manual-${{ github.event.inputs.reason }}" >> $GITHUB_ENV else echo "TRIGGER_REASON=nightly-scheduled" >> $GITHUB_ENV fi
- name: Comment with results and artifact link id: create_comment uses: KeisukeYamashita/create-comment@v1 with: # if triggered by PR, use PR number, otherwise use 5318 as fallback issue number for manual triggers number: ${{ github.event_name == 'pull_request' && github.event.pull_request.number || 5318 }} unique: false comment: | Trigger by: ${{ github.event_name == 'pull_request' && format('Pull Request (integration-test label on PR #{0})', github.event.pull_request.number) || (github.event_name == 'workflow_dispatch' && format('Manual Trigger: {0}', github.event.inputs.reason)) || 'Nightly Scheduled Run' }} Commit: ${{ github.sha }} **Integration Tests Report (Haiku)** Haiku LLM Test Results: ${{ env.INTEGRATION_TEST_REPORT_HAIKU }} --- **Integration Tests Report (DeepSeek)** DeepSeek LLM Test Results: ${{ env.INTEGRATION_TEST_REPORT_DEEPSEEK }} --- **Integration Tests Report VisualBrowsing (DeepSeek)** ${{ env.INTEGRATION_TEST_REPORT_VISUALBROWSING_DEEPSEEK }} --- Download testing outputs (includes both Haiku and DeepSeek results): [Download](${{ steps.upload_results_artifact.outputs.artifact-url }})12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091name: Lint Fix
on: pull_request: types: [labeled]
jobs: # Frontend lint fixes lint-fix-frontend: if: github.event.label.name == 'lint-fix' name: Fix frontend linting issues runs-on: blacksmith-4vcpu-ubuntu-2204 permissions: contents: write pull-requests: write steps: - uses: actions/checkout@v4 with: ref: ${{ github.head_ref }} repository: ${{ github.event.pull_request.head.repo.full_name }} fetch-depth: 0 token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Node.js 20 uses: useblacksmith/setup-node@v5 with: node-version: 20 - name: Install frontend dependencies run: | cd frontend npm install --frozen-lockfile - name: Fix frontend lint issues run: | cd frontend npm run lint:fix
# Commit and push changes if any - name: Check for changes id: git-check run: | git diff --quiet || echo "changes=true" >> $GITHUB_OUTPUT - name: Commit and push if there are changes if: steps.git-check.outputs.changes == 'true' run: | git config --local user.email "openhands@all-hands.dev" git config --local user.name "OpenHands Bot" git add -A git commit -m "🤖 Auto-fix frontend linting issues" git push
# Python lint fixes lint-fix-python: if: github.event.label.name == 'lint-fix' name: Fix Python linting issues runs-on: blacksmith-4vcpu-ubuntu-2204 permissions: contents: write pull-requests: write steps: - uses: actions/checkout@v4 with: ref: ${{ github.head_ref }} repository: ${{ github.event.pull_request.head.repo.full_name }} fetch-depth: 0 token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up python uses: useblacksmith/setup-python@v6 with: python-version: 3.12 cache: 'pip' - name: Install pre-commit run: pip install pre-commit==3.7.0 - name: Fix python lint issues run: | # Run all pre-commit hooks and continue even if they modify files (exit code 1) pre-commit run --config ./dev_config/python/.pre-commit-config.yaml --files openhands/**/* evaluation/**/* tests/**/* || true
# Commit and push changes if any - name: Check for changes id: git-check run: | git diff --quiet || echo "changes=true" >> $GITHUB_OUTPUT - name: Commit and push if there are changes if: steps.git-check.outputs.changes == 'true' run: | git config --local user.email "openhands@all-hands.dev" git config --local user.name "OpenHands Bot" git add -A git commit -m "🤖 Auto-fix Python linting issues" git push1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768# Workflow that runs lint on the frontend and python codename: Lint
# The jobs in this workflow are required, so they must run at all times# Always run on "main"# Always run on PRson: push: branches: - main pull_request:
# If triggered by a PR, it will be in the same group. However, each commit on main will be in its own unique groupconcurrency: group: ${{ github.workflow }}-${{ (github.head_ref && github.ref) || github.run_id }} cancel-in-progress: true
jobs: # Run lint on the frontend code lint-frontend: name: Lint frontend runs-on: blacksmith-4vcpu-ubuntu-2204 steps: - uses: actions/checkout@v4 - name: Install Node.js 20 uses: useblacksmith/setup-node@v5 with: node-version: 20 - name: Install dependencies run: | cd frontend npm install --frozen-lockfile - name: Lint and TypeScript compilation run: | cd frontend npm run lint npm run make-i18n && tsc
# Run lint on the python code lint-python: name: Lint python runs-on: blacksmith-4vcpu-ubuntu-2204 steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up python uses: useblacksmith/setup-python@v6 with: python-version: 3.12 cache: 'pip' - name: Install pre-commit run: pip install pre-commit==3.7.0 - name: Run pre-commit hooks run: pre-commit run --files openhands/**/* evaluation/**/* tests/**/* --show-diff-on-failure --config ./dev_config/python/.pre-commit-config.yaml
# Check version consistency across documentation check-version-consistency: name: Check version consistency runs-on: blacksmith-4vcpu-ubuntu-2204 steps: - uses: actions/checkout@v4 - name: Set up python uses: useblacksmith/setup-python@v6 with: python-version: 3.12 - name: Run version consistency check run: .github/scripts/check_version_consistency.py123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419name: Auto-Fix Tagged Issue with OpenHands
on: workflow_call: inputs: max_iterations: required: false type: number default: 50 macro: required: false type: string default: "@openhands-agent" target_branch: required: false type: string default: "main" description: "Target branch to pull and create PR against" LLM_MODEL: required: false type: string default: "anthropic/claude-3-5-sonnet-20241022" LLM_API_VERSION: required: false type: string default: "" base_container_image: required: false type: string default: "" description: "Custom sandbox env" secrets: LLM_MODEL: required: false LLM_API_KEY: required: true LLM_BASE_URL: required: false PAT_TOKEN: required: false PAT_USERNAME: required: false
issues: types: [labeled] pull_request: types: [labeled] issue_comment: types: [created] pull_request_review_comment: types: [created] pull_request_review: types: [submitted]
permissions: contents: write pull-requests: write issues: write
jobs: auto-fix: if: | github.event_name == 'workflow_call' || github.event.label.name == 'fix-me' || github.event.label.name == 'fix-me-experimental' || ( ((github.event_name == 'issue_comment' || github.event_name == 'pull_request_review_comment') && contains(github.event.comment.body, inputs.macro || '@openhands-agent') && (github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'MEMBER') ) ||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, inputs.macro || '@openhands-agent') && (github.event.review.author_association == 'OWNER' || github.event.review.author_association == 'COLLABORATOR' || github.event.review.author_association == 'MEMBER') ) ) runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4
- name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.12"
- name: Get latest versions and create requirements.txt run: | python -m pip index versions openhands-ai > openhands_versions.txt OPENHANDS_VERSION=$(head -n 1 openhands_versions.txt | awk '{print $2}' | tr -d '()')
# Create a new requirements.txt locally within the workflow, ensuring no reference to the repo's file echo "openhands-ai==${OPENHANDS_VERSION}" > /tmp/requirements.txt cat /tmp/requirements.txt
- name: Cache pip dependencies if: | !( github.event.label.name == 'fix-me-experimental' || ( (github.event_name == 'issue_comment' || github.event_name == 'pull_request_review_comment') && contains(github.event.comment.body, '@openhands-agent-exp') ) || ( github.event_name == 'pull_request_review' && contains(github.event.review.body, '@openhands-agent-exp') ) ) uses: actions/cache@v4 with: path: ${{ env.pythonLocation }}/lib/python3.12/site-packages/* key: ${{ runner.os }}-pip-openhands-resolver-${{ hashFiles('/tmp/requirements.txt') }} restore-keys: | ${{ runner.os }}-pip-openhands-resolver-${{ hashFiles('/tmp/requirements.txt') }}
- name: Check required environment variables env: LLM_MODEL: ${{ secrets.LLM_MODEL || inputs.LLM_MODEL }} LLM_API_KEY: ${{ secrets.LLM_API_KEY }} LLM_BASE_URL: ${{ secrets.LLM_BASE_URL }} LLM_API_VERSION: ${{ inputs.LLM_API_VERSION }} PAT_TOKEN: ${{ secrets.PAT_TOKEN }} PAT_USERNAME: ${{ secrets.PAT_USERNAME }} GITHUB_TOKEN: ${{ github.token }} run: | required_vars=("LLM_API_KEY") for var in "${required_vars[@]}"; do if [ -z "${!var}" ]; then echo "Error: Required environment variable $var is not set." exit 1 fi done
# Check optional variables and warn about fallbacks if [ -z "$LLM_BASE_URL" ]; then echo "Warning: LLM_BASE_URL is not set, will use default API endpoint" fi
if [ -z "$PAT_TOKEN" ]; then echo "Warning: PAT_TOKEN is not set, falling back to GITHUB_TOKEN" fi
if [ -z "$PAT_USERNAME" ]; then echo "Warning: PAT_USERNAME is not set, will use openhands-agent" fi
- name: Set environment variables run: | # Handle pull request events first if [ -n "${{ github.event.pull_request.number }}" ]; then echo "ISSUE_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV echo "ISSUE_TYPE=pr" >> $GITHUB_ENV # Handle pull request review events elif [ -n "${{ github.event.review.body }}" ]; then echo "ISSUE_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV echo "ISSUE_TYPE=pr" >> $GITHUB_ENV # Handle issue comment events that reference a PR elif [ -n "${{ github.event.issue.pull_request }}" ]; then echo "ISSUE_NUMBER=${{ github.event.issue.number }}" >> $GITHUB_ENV echo "ISSUE_TYPE=pr" >> $GITHUB_ENV # Handle regular issue events else echo "ISSUE_NUMBER=${{ github.event.issue.number }}" >> $GITHUB_ENV echo "ISSUE_TYPE=issue" >> $GITHUB_ENV fi
if [ -n "${{ github.event.review.body }}" ]; then echo "COMMENT_ID=${{ github.event.review.id || 'None' }}" >> $GITHUB_ENV else echo "COMMENT_ID=${{ github.event.comment.id || 'None' }}" >> $GITHUB_ENV fi
echo "MAX_ITERATIONS=${{ inputs.max_iterations || 50 }}" >> $GITHUB_ENV echo "SANDBOX_ENV_GITHUB_TOKEN=${{ secrets.PAT_TOKEN || github.token }}" >> $GITHUB_ENV echo "SANDBOX_ENV_BASE_CONTAINER_IMAGE=${{ inputs.base_container_image }}" >> $GITHUB_ENV
# Set branch variables echo "TARGET_BRANCH=${{ inputs.target_branch || 'main' }}" >> $GITHUB_ENV
- name: Comment on issue with start message uses: actions/github-script@v7 with: github-token: ${{ secrets.PAT_TOKEN || github.token }} script: | const issueType = process.env.ISSUE_TYPE; github.rest.issues.createComment({ issue_number: ${{ env.ISSUE_NUMBER }}, owner: context.repo.owner, repo: context.repo.repo, body: `[OpenHands](https://github.com/All-Hands-AI/OpenHands) started fixing the ${issueType}! You can monitor the progress [here](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}).` });
- name: Install OpenHands id: install_openhands uses: actions/github-script@v7 env: COMMENT_BODY: ${{ github.event.comment.body || '' }} REVIEW_BODY: ${{ github.event.review.body || '' }} LABEL_NAME: ${{ github.event.label.name || '' }} EVENT_NAME: ${{ github.event_name }} with: script: | const commentBody = process.env.COMMENT_BODY.trim(); const reviewBody = process.env.REVIEW_BODY.trim(); const labelName = process.env.LABEL_NAME.trim(); const eventName = process.env.EVENT_NAME.trim(); // Check conditions const isExperimentalLabel = labelName === "fix-me-experimental"; const isIssueCommentExperimental = (eventName === "issue_comment" || eventName === "pull_request_review_comment") && commentBody.includes("@openhands-agent-exp"); const isReviewCommentExperimental = eventName === "pull_request_review" && reviewBody.includes("@openhands-agent-exp");
// Set output variable core.setOutput('isExperimental', isExperimentalLabel || isIssueCommentExperimental || isReviewCommentExperimental);
// Perform package installation if (isExperimentalLabel || isIssueCommentExperimental || isReviewCommentExperimental) { console.log("Installing experimental OpenHands..."); await exec.exec("python -m pip install --upgrade pip"); await exec.exec("pip install git+https://github.com/all-hands-ai/openhands.git"); } else { console.log("Installing from requirements.txt..."); await exec.exec("python -m pip install --upgrade pip"); await exec.exec("pip install -r /tmp/requirements.txt"); }
- name: Attempt to resolve issue env: GITHUB_TOKEN: ${{ secrets.PAT_TOKEN || github.token }} GITHUB_USERNAME: ${{ secrets.PAT_USERNAME || 'openhands-agent' }} GIT_USERNAME: ${{ secrets.PAT_USERNAME || 'openhands-agent' }} LLM_MODEL: ${{ secrets.LLM_MODEL || inputs.LLM_MODEL }} LLM_API_KEY: ${{ secrets.LLM_API_KEY }} LLM_BASE_URL: ${{ secrets.LLM_BASE_URL }} LLM_API_VERSION: ${{ inputs.LLM_API_VERSION }} PYTHONPATH: "" run: | cd /tmp && python -m openhands.resolver.resolve_issue \ --selected-repo ${{ github.repository }} \ --issue-number ${{ env.ISSUE_NUMBER }} \ --issue-type ${{ env.ISSUE_TYPE }} \ --max-iterations ${{ env.MAX_ITERATIONS }} \ --comment-id ${{ env.COMMENT_ID }} \ --is-experimental ${{ steps.install_openhands.outputs.isExperimental }}
- name: Check resolution result id: check_result run: | if cd /tmp && grep -q '"success":true' output/output.jsonl; then echo "RESOLUTION_SUCCESS=true" >> $GITHUB_OUTPUT else echo "RESOLUTION_SUCCESS=false" >> $GITHUB_OUTPUT fi
- name: Upload output.jsonl as artifact uses: actions/upload-artifact@v4 if: always() # Upload even if the previous steps fail with: name: resolver-output path: /tmp/output/output.jsonl retention-days: 30 # Keep the artifact for 30 days
- name: Create draft PR or push branch if: always() # Create PR or branch even if the previous steps fail env: GITHUB_TOKEN: ${{ secrets.PAT_TOKEN || github.token }} GITHUB_USERNAME: ${{ secrets.PAT_USERNAME || 'openhands-agent' }} GIT_USERNAME: ${{ secrets.PAT_USERNAME || 'openhands-agent' }} LLM_MODEL: ${{ secrets.LLM_MODEL || inputs.LLM_MODEL }} LLM_API_KEY: ${{ secrets.LLM_API_KEY }} LLM_BASE_URL: ${{ secrets.LLM_BASE_URL }} LLM_API_VERSION: ${{ inputs.LLM_API_VERSION }} PYTHONPATH: "" run: | if [ "${{ steps.check_result.outputs.RESOLUTION_SUCCESS }}" == "true" ]; then cd /tmp && python -m openhands.resolver.send_pull_request \ --issue-number ${{ env.ISSUE_NUMBER }} \ --target-branch ${{ env.TARGET_BRANCH }} \ --pr-type draft \ --reviewer ${{ github.actor }} | tee pr_result.txt && \ grep "draft created" pr_result.txt | sed 's/.*\///g' > pr_number.txt else cd /tmp && python -m openhands.resolver.send_pull_request \ --issue-number ${{ env.ISSUE_NUMBER }} \ --pr-type branch \ --send-on-failure | tee branch_result.txt && \ grep "branch created" branch_result.txt | sed 's/.*\///g; s/.expand=1//g' > branch_name.txt fi
# Step leaves comment for when agent is invoked on PR - name: Analyze Push Logs (Updated PR or No Changes) # Skip comment if PR update was successful OR leave comment if the agent made no code changes uses: actions/github-script@v7 if: always() env: AGENT_RESPONDED: ${{ env.AGENT_RESPONDED || 'false' }} ISSUE_NUMBER: ${{ env.ISSUE_NUMBER }} with: github-token: ${{ secrets.PAT_TOKEN || github.token }} script: | const fs = require('fs'); const issueNumber = process.env.ISSUE_NUMBER; let logContent = '';
try { logContent = fs.readFileSync('/tmp/pr_result.txt', 'utf8').trim(); } catch (error) { console.error('Error reading pr_result.txt file:', error); }
const noChangesMessage = `No changes to commit for issue #${issueNumber}. Skipping commit.`;
// Check logs from send_pull_request.py (pushes code to GitHub) if (logContent.includes("Updated pull request")) { console.log("Updated pull request found. Skipping comment."); process.env.AGENT_RESPONDED = 'true'; } else if (logContent.includes(noChangesMessage)) { github.rest.issues.createComment({ issue_number: issueNumber, owner: context.repo.owner, repo: context.repo.repo, body: `The workflow to fix this issue encountered an error. Openhands failed to create any code changes.` }); process.env.AGENT_RESPONDED = 'true'; }
# Step leaves comment for when agent is invoked on issue - name: Comment on issue # Comment link to either PR or branch created by agent uses: actions/github-script@v7 if: always() # Comment on issue even if the previous steps fail env: AGENT_RESPONDED: ${{ env.AGENT_RESPONDED || 'false' }} ISSUE_NUMBER: ${{ env.ISSUE_NUMBER }} RESOLUTION_SUCCESS: ${{ steps.check_result.outputs.RESOLUTION_SUCCESS }} with: github-token: ${{ secrets.PAT_TOKEN || github.token }} script: | const fs = require('fs'); const path = require('path'); const issueNumber = process.env.ISSUE_NUMBER; const success = process.env.RESOLUTION_SUCCESS === 'true';
let prNumber = ''; let branchName = ''; let resultExplanation = '';
try { if (success) { prNumber = fs.readFileSync('/tmp/pr_number.txt', 'utf8').trim(); } else { branchName = fs.readFileSync('/tmp/branch_name.txt', 'utf8').trim(); } } catch (error) { console.error('Error reading file:', error); }
try { if (!success){ // Read result_explanation from JSON file for failed resolution const outputFilePath = path.resolve('/tmp/output/output.jsonl'); if (fs.existsSync(outputFilePath)) { const outputContent = fs.readFileSync(outputFilePath, 'utf8'); const jsonLines = outputContent.split('\n').filter(line => line.trim() !== '');
if (jsonLines.length > 0) { // First entry in JSON lines has the key 'result_explanation' const firstEntry = JSON.parse(jsonLines[0]); resultExplanation = firstEntry.result_explanation || ''; } } } } catch (error){ console.error('Error reading file:', error); }
// Check "success" log from resolver output if (success && prNumber) { github.rest.issues.createComment({ issue_number: issueNumber, owner: context.repo.owner, repo: context.repo.repo, body: `A potential fix has been generated and a draft PR #${prNumber} has been created. Please review the changes.` }); process.env.AGENT_RESPONDED = 'true'; } else if (!success && branchName) { let commentBody = `An attempt was made to automatically fix this issue, but it was unsuccessful. A branch named '${branchName}' has been created with the attempted changes. You can view the branch [here](https://github.com/${context.repo.owner}/${context.repo.repo}/tree/${branchName}). Manual intervention may be required.`;
if (resultExplanation) { commentBody += `\n\nAdditional details about the failure:\n${resultExplanation}`; }
github.rest.issues.createComment({ issue_number: issueNumber, owner: context.repo.owner, repo: context.repo.repo, body: commentBody }); process.env.AGENT_RESPONDED = 'true'; }
# Leave error comment when both PR/Issue comment handling fail - name: Fallback Error Comment uses: actions/github-script@v7 if: ${{ env.AGENT_RESPONDED == 'false' }} # Only run if no conditions were met in previous steps env: ISSUE_NUMBER: ${{ env.ISSUE_NUMBER }} with: github-token: ${{ secrets.PAT_TOKEN || github.token }} script: | const issueNumber = process.env.ISSUE_NUMBER;
github.rest.issues.createComment({ issue_number: issueNumber, owner: context.repo.owner, repo: context.repo.repo, body: `The workflow to fix this issue encountered an error. Please check the [workflow logs](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}) for more information.` });12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455# Workflow that runs python unit testsname: Run Python Unit Tests
# The jobs in this workflow are required, so they must run at all times# * Always run on "main"# * Always run on PRson: push: branches: - main pull_request:
# If triggered by a PR, it will be in the same group. However, each commit on main will be in its own unique groupconcurrency: group: ${{ github.workflow }}-${{ (github.head_ref && github.ref) || github.run_id }} cancel-in-progress: true
jobs: # Run python unit tests on Linux test-on-linux: name: Python Unit Tests on Linux runs-on: blacksmith-4vcpu-ubuntu-2204 env: INSTALL_DOCKER: '0' # Set to '0' to skip Docker installation strategy: matrix: python-version: ['3.12'] steps: - uses: actions/checkout@v4 - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v3 - name: Install tmux run: sudo apt-get update && sudo apt-get install -y tmux - name: Setup Node.js uses: useblacksmith/setup-node@v5 with: node-version: '22.x' - name: Install poetry via pipx run: pipx install poetry - name: Set up Python uses: useblacksmith/setup-python@v6 with: python-version: ${{ matrix.python-version }} cache: 'poetry' - name: Install Python dependencies using Poetry run: poetry install --without evaluation - name: Build Environment run: make build - name: Run Tests run: poetry run pytest --forked -n auto --cov=openhands --cov-report=xml -svv ./tests/unit - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}12345678910111213141516171819202122232425262728293031# Publishes the OpenHands PyPi packagename: Publish PyPi Package
# Triggered manuallyon: workflow_dispatch: inputs: reason: description: 'Reason for manual trigger' required: true default: ''
jobs: release: runs-on: blacksmith-4vcpu-ubuntu-2204 steps: - uses: actions/checkout@v4 - uses: useblacksmith/setup-python@v6 with: python-version: 3.12 - name: Install Poetry uses: snok/install-poetry@v1.4.1 with: virtualenvs-in-project: true virtualenvs-path: ~/.virtualenvs - name: Install Poetry Dependencies run: poetry install --no-interaction --no-root - name: Build poetry project run: ./build.sh - name: publish run: poetry publish -u __token__ -p ${{ secrets.PYPI_TOKEN }}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253# Run evaluation on a PRname: Run Eval
# Runs when a PR is labeled with one of the "run-eval-" labelson: pull_request: types: [labeled]
jobs: trigger-job: name: Trigger remote eval job if: ${{ github.event.label.name == 'run-eval-xs' || github.event.label.name == 'run-eval-s' || github.event.label.name == 'run-eval-m' }} runs-on: blacksmith-4vcpu-ubuntu-2204
steps: - name: Checkout PR branch uses: actions/checkout@v4 with: ref: ${{ github.head_ref }}
- name: Trigger remote job run: | REPO_URL="https://github.com/${{ github.repository }}" PR_BRANCH="${{ github.head_ref }}" echo "Repository URL: $REPO_URL" echo "PR Branch: $PR_BRANCH"
if [[ "${{ github.event.label.name }}" == "run-eval-xs" ]]; then EVAL_INSTANCES="1" elif [[ "${{ github.event.label.name }}" == "run-eval-s" ]]; then EVAL_INSTANCES="5" elif [[ "${{ github.event.label.name }}" == "run-eval-m" ]]; then EVAL_INSTANCES="30" fi
curl -X POST \ -H "Authorization: Bearer ${{ secrets.PAT_TOKEN }}" \ -H "Accept: application/vnd.github+json" \ -d "{\"ref\": \"main\", \"inputs\": {\"github-repo\": \"${REPO_URL}\", \"github-branch\": \"${PR_BRANCH}\", \"pr-number\": \"${{ github.event.pull_request.number }}\", \"eval-instances\": \"${EVAL_INSTANCES}\"}}" \ https://api.github.com/repos/All-Hands-AI/evaluation/actions/workflows/create-branch.yml/dispatches
# Send Slack message PR_URL="https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}" slack_text="PR $PR_URL has triggered evaluation on $EVAL_INSTANCES instances..." curl -X POST -H 'Content-type: application/json' --data '{"text":"'"$slack_text"'"}' \ https://hooks.slack.com/services/${{ secrets.SLACK_TOKEN }}
- name: Comment on PR uses: KeisukeYamashita/create-comment@v1 with: unique: false comment: | Running evaluation on the PR. Once eval is done, the results will be posted.12345678910111213141516171819202122# Workflow that marks issues and PRs with no activity for 30 days with "Stale" and closes them after 7 more days of no activityname: 'Close stale issues'
# Runs every day at 01:30on: schedule: - cron: '30 1 * * *'
jobs: stale: runs-on: blacksmith-4vcpu-ubuntu-2204 steps: - uses: actions/stale@v9 with: stale-issue-message: 'This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.' stale-pr-message: 'This PR is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.' days-before-stale: 30 exempt-issue-labels: 'tracked' close-issue-message: 'This issue was closed because it has been stalled for over 30 days with no activity.' close-pr-message: 'This PR was closed because it has been stalled for over 30 days with no activity.' days-before-close: 7 operations-per-run: 150123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235# Byte-compiled / optimized / DLL files__pycache__/*.py[cod]*$py.class
# C extensions*.so
# Distribution / packaging.Pythonbuild/develop-eggs/dist/downloads/eggs/.eggs/./lib/lib64/parts/sdist/var/wheels/share/python-wheels/*.egg-info/.installed.cfg*.eggMANIFESTrequirements.txt
# PyInstaller# Usually these files are written by a python script from a template# before PyInstaller builds the exe, so as to inject date/other infos into it.*.manifest*.spec
# Installer logspip-log.txtpip-delete-this-directory.txt
# Unit test / coverage reportshtmlcov/.tox/.nox/.coverage.coverage.*.cachenosetests.xmlcoverage.xml*.cover*.py,cover.hypothesis/.pytest_cache/cover/
# Translations*.mo*.pot
# Django stuff:local_settings.pydb.sqlite3db.sqlite3-journal
# Flask stuff:instance/.webassets-cache
# Scrapy stuff:.scrapy
# Sphinx documentationdocs/_build/
# PyBuilder.pybuilder/target/
# Jupyter Notebook.ipynb_checkpoints
# IPythonprofile_default/ipython_config.py
# pyenv# For a library or package, you might want to ignore these files since the code is# intended to run in multiple environments; otherwise, check them in:.python-version
# pipenv# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.# However, in case of collaboration, if having platform-specific dependencies or dependencies# having no cross-platform support, pipenv may install dependencies that don't work, or not# install all needed dependencies.#Pipfile.lock
# poetry# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.# This is especially recommended for binary packages to ensure reproducibility, and is more# commonly ignored for libraries.# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control# poetry.lock
# pdm# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.#pdm.lock# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it# in version control.# https://pdm.fming.dev/#use-with-ide.pdm.toml
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm__pypackages__/
# Celery stuffcelerybeat-schedulecelerybeat.pid
# SageMath parsed files*.sage.py
# Environments.envfrontend/.env.venvenv/venv/ENV/env.bak/.env.bakvenv.bak/*venv/
# Spyder project settings.spyderproject.spyproject
# Rope project settings.ropeproject
# mkdocs documentation/site
# mypy.mypy_cache/.dmypy.jsondmypy.json
# Pyre type checker.pyre/
# pytype static type analyzer.pytype/
# Cython debug symbolscython_debug/
# PyCharm# JetBrains specific template is maintained in a separate JetBrains.gitignore that can# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore# and can be added to the global gitignore or merged into this file. For a more nuclear# option (not recommended) you can uncomment the following to ignore the entire idea folder..idea/.vscode/.cursorignore
# evaluationevaluation/evaluation_outputsevaluation/outputsevaluation/swe_bench/eval_workspace*evaluation/SWE-bench/dataevaluation/webarena/scripts/webarena_env.shevaluation/bird/dataevaluation/gaia/dataevaluation/gorilla/dataevaluation/toolqa/dataevaluation/scienceagentbench/benchmarkevaluation/commit0_bench/repos
# openhands resolveroutput/
# frontend
# dependenciesfrontend/.pnpfrontend/bun.lockbfrontend/yarn.lock.pnp.js
# testingfrontend/coveragetest_results*/_test_files_tmp/
# productionfrontend/buildfrontend/dist
# misc.DS_Store.env.local.env.development.local.env.test.local.env.production.local
npm-debug.log*yarn-debug.log*yarn-error.log*
logs
# agent.envrc/workspace/_test_workspace/debugcache
# configurationconfig.tomlconfig.toml_config.toml.bak
# swe-bench-evalimage_build_logsrun_instance_logs
runtime_*.tar
# docker buildcontainers/runtime/Dockerfilecontainers/runtime/project.tar.gzcontainers/runtime/code**/node_modules/122123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172# OpenHands Glossary
### AgentThe core AI entity in OpenHands that can perform software development tasks by interacting with tools, browsing the web, and modifying code.
#### Agent ControllerA component that manages the agent's lifecycle, handles its state, and coordinates interactions between the agent and various tools.
#### Agent DelegationThe ability of an agent to hand off specific tasks to other specialized agents for better task completion.
#### Agent HubA central registry of different agent types and their capabilities, allowing for easy agent selection and instantiation.
#### Agent SkillA specific capability or function that an agent can perform, such as file manipulation, web browsing, or code editing.
#### Agent StateThe current context and status of an agent, including its memory, active tools, and ongoing tasks.
#### CodeAct Agent[A generalist agent in OpenHands](https://arxiv.org/abs/2407.16741) designed to perform tasks by editing and executing code.
### BrowserA system for web-based interactions and tasks.
#### Browser GymA testing and evaluation environment for browser-based agent interactions and tasks.
#### Web Browser ToolA tool that enables agents to interact with web pages and perform web-based tasks.
### CommandsTerminal and execution related functionality.
#### Bash SessionA persistent terminal session that maintains state and history for bash command execution.This uses tmux under the hood.
### ConfigurationSystem-wide settings and options.
#### Agent ConfigurationSettings that define an agent's behavior, capabilities, and limitations, including available tools and runtime settings.
#### Configuration OptionsSettings that control various aspects of OpenHands behavior, including runtime, security, and agent settings.
#### LLM ConfigConfiguration settings for language models used by agents, including model selection and parameters.
#### LLM Draft ConfigSettings for draft mode operations with language models, typically used for faster, lower-quality responses.
#### Runtime ConfigurationSettings that define how the runtime environment should be set up and operated.
#### Security OptionsConfiguration settings that control security features and restrictions.
### ConversationA sequence of interactions between a user and an agent, including messages, actions, and their results.
#### Conversation InfoMetadata about a conversation, including its status, participants, and timeline.
#### Conversation ManagerA component that handles the creation, storage, and retrieval of conversations.
#### Conversation MetadataAdditional information about conversations, such as tags, timestamps, and related resources.
#### Conversation StatusThe current state of a conversation, including whether it's active, completed, or failed.
#### Conversation StoreA storage system for maintaining conversation history and related data.
### Events
#### EventEvery Conversation comprises a series of Events. Each Event is either an Action or an Observation.
#### Event StreamA continuous flow of events that represents the ongoing activities and interactions in the system.
#### ActionA specific operation or command that an agent executes through available tools, such as running a command or editing a file.
#### ObservationThe response or result returned by a tool after an agent's action, providing feedback about the action's outcome.
### InterfaceDifferent ways to interact with OpenHands.
#### CLI ModeA command-line interface mode for interacting with OpenHands agents without a graphical interface.
#### GUI ModeA graphical user interface mode for interacting with OpenHands agents through a web interface.
#### Headless ModeA mode of operation where OpenHands runs without a user interface, suitable for automation and scripting.
### Agent MemoryThe system that decides which parts of the Event Stream (i.e. the conversation history) should be passed into each LLM prompt.
#### Memory StoreA storage system for maintaining agent memory and context across sessions.
#### CondenserA component that processes and summarizes conversation history to maintain context while staying within token limits.
#### TruncationA very simple Condenser strategy. Reduces conversation history or content to stay within token limits.
### MicroagentA specialized prompt that enhances OpenHands with domain-specific knowledge, repository-specific context, and task-specific workflows.
#### Microagent RegistryA central repository of available microagents and their configurations.
#### Public MicroagentA general-purpose microagent available to all OpenHands users, triggered by specific keywords.
#### Repository MicroagentA type of microagent that provides repository-specific context and guidelines, stored in the `.openhands/microagents/` directory.
### PromptComponents for managing and processing prompts.
#### Prompt CachingA system for caching and reusing common prompts to improve performance.
#### Prompt ManagerA component that handles the loading, processing, and management of prompts used by agents, including microagents.
#### Response ParsingThe process of interpreting and structuring responses from language models and tools.
### RuntimeThe execution environment where agents perform their tasks, which can be local, remote, or containerized.
#### Action Execution ServerA REST API that receives agent actions (e.g. bash commands, python code, browsing actions), executes them in the runtime environment, and returns the results.
#### Action Execution ClientA component that handles the execution of actions in the runtime environment, managing the communication between the agent and the runtime.
#### Docker RuntimeA containerized runtime environment that provides isolation and reproducibility for agent operations.
#### E2B RuntimeA specialized runtime environment built on E2B for secure and isolated code execution.
#### Local RuntimeA runtime environment that executes on the local machine, suitable for development and testing.
#### Modal RuntimeA runtime environment built on Modal for scalable and distributed agent operations.
#### Remote RuntimeA sandboxed environment that executes code and commands remotely, providing isolation and security for agent operations.
#### Runtime BuilderA component that builds a Docker image for the Action Execution Server based on a user-specified base image.
### SecuritySecurity-related components and features.
#### Security AnalyzerA component that checks agent actions for potential security risks.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748---name: repotype: repoagent: CodeActAgent---This repository contains the code for OpenHands, an automated AI software engineer. It has a Python backend(in the `openhands` directory) and React frontend (in the `frontend` directory).
## General Setup:To set up the entire repo, including frontend and backend, run `make build`.You don't need to do this unless the user asks you to, or if you're trying to run the entire application.
Before pushing any changes, you should ensure that any lint errors or simple test errors have been fixed.
* If you've made changes to the backend, you should run `pre-commit run --all-files --config ./dev_config/python/.pre-commit-config.yaml`* If you've made changes to the frontend, you should run `cd frontend && npm run lint:fix && npm run build ; cd ..`
If either command fails, it may have automatically fixed some issues. You should fix any issues that weren't automatically fixed,then re-run the command to ensure it passes.
## Repository StructureBackend:- Located in the `openhands` directory- Testing: - All tests are in `tests/unit/test_*.py` - To test new code, run `poetry run pytest tests/unit/test_xxx.py` where `xxx` is the appropriate file for the current functionality - Write all tests with pytest
Frontend:- Located in the `frontend` directory- Prerequisites: A recent version of NodeJS / NPM- Setup: Run `npm install` in the frontend directory- Testing: - Run tests: `npm run test` - To run specific tests: `npm run test -- -t "TestName"` - Our test framework is vitest- Building: - Build for production: `npm run build`- Environment Variables: - Set in `frontend/.env` or as environment variables - Available variables: VITE_BACKEND_HOST, VITE_USE_TLS, VITE_INSECURE_SKIP_VERIFY, VITE_FRONTEND_PORT- Internationalization: - Generate i18n declaration file: `npm run make-i18n`
## Template for Github Pull Request
If you are starting a pull request (PR), please follow the template in `.github/pull_request_template.md`.12345#! /bin/bash
echo "Setting up the environment..."
python -m pip install pre-commit12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455cff-version: 1.2.0message: "If you use this software, please cite it using the following metadata."title: "OpenHands: An Open Platform for AI Software Developers as Generalist Agents"authors: - family-names: Wang given-names: Xingyao - family-names: Li given-names: Boxuan - family-names: Song given-names: Yufan - family-names: Xu given-names: Frank F. - family-names: Tang given-names: Xiangru - family-names: Zhuge given-names: Mingchen - family-names: Pan given-names: Jiayi - family-names: Song given-names: Yueqi - family-names: Li given-names: Bowen - family-names: Singh given-names: Jaskirat - family-names: Tran given-names: Hoang H. - family-names: Li given-names: Fuqiang - family-names: Ma given-names: Ren - family-names: Zheng given-names: Mingzhang - family-names: Qian given-names: Bill - family-names: Shao given-names: Yanjun - family-names: Muennighoff given-names: Niklas - family-names: Zhang given-names: Yizhe - family-names: Hui given-names: Binyuan - family-names: Lin given-names: Junyang - family-names: Brennan given-names: Robert - family-names: Peng given-names: Hao - family-names: Ji given-names: Heng - family-names: Neubig given-names: Grahamyear: 2024doi: "10.48550/arXiv.2407.16741"url: "https://arxiv.org/abs/2407.16741"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
# Contributor Covenant Code of Conduct
## Our Pledge
We as members, contributors, and leaders pledge to make participation in ourcommunity a harassment-free experience for everyone, regardless of age, bodysize, visible or invisible disability, ethnicity, sex characteristics, genderidentity and expression, level of experience, education, socio-economic status,nationality, personal appearance, race, caste, color, religion, or sexualidentity and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming,diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for ourcommunity include:
* Demonstrating empathy and kindness toward other people.* Being respectful of differing opinions, viewpoints, and experiences.* Giving and gracefully accepting constructive feedback.* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience.* Focusing on what is best not just for us as individuals, but for the overall community.
Examples of unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or advances of any kind.* Trolling, insulting or derogatory comments, and personal or political attacks.* Public or private harassment.* Publishing others' private information, such as a physical or email address, without their explicit permission.* Other conduct which could reasonably be considered inappropriate in a professional setting.
## Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards ofacceptable behavior and will take appropriate and fair corrective action inresponse to any behavior that they deem inappropriate, threatening, offensive,or harmful.
Community leaders have the right and responsibility to remove, edit, or rejectcomments, commits, code, wiki edits, issues, and other contributions that arenot aligned to this Code of Conduct, and will communicate reasons for moderationdecisions when appropriate.
## Scope
This Code of Conduct applies within all community spaces, and also applies whenan individual is officially representing the community in public spaces.Examples of representing our community include using an official email address,posting via an official social media account, or acting as an appointedrepresentative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may bereported to the community leaders responsible for enforcement atcontact@all-hands.dev.All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of thereporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determiningthe consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemedunprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providingclarity around the nature of the violation and an explanation of why thebehavior was inappropriate. A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series ofactions.
**Consequence**: A warning with consequences for continued behavior. Nointeraction with the people involved, including unsolicited interaction withthose enforcing the Code of Conduct, for a specified period of time. Thisincludes avoiding interactions in community spaces as well as external channelslike social media. Violating these terms may lead to a temporary or permanentban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, includingsustained inappropriate behavior.
**Consequence**: A temporary ban from any sort of interaction or publiccommunication with the community for a specified period of time. No public orprivate interaction with the people involved, including unsolicited interactionwith those enforcing the Code of Conduct, is allowed during this period.Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of communitystandards, including sustained inappropriate behavior, harassment of anindividual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within thecommunity.
### Slack and Discord Etiquettes
These Slack and Discord etiquette guidelines are designed to foster an inclusive, respectful, and productive environment for all community members. By following these best practices, we ensure effective communication and collaboration while minimizing disruptions. Let’s work together to build a supportive and welcoming community!
- Communicate respectfully and professionally, avoiding sarcasm or harsh language, and remember that tone can be difficult to interpret in text.- Use threads for specific discussions to keep channels organized and easier to follow.- Tag others only when their input is critical or urgent, and use @here, @channel or @everyone sparingly to minimize disruptions.- Be patient, as open-source contributors and maintainers often have other commitments and may need time to respond.- Post questions or discussions in the most relevant channel (e.g., for [slack - #general](https://app.slack.com/client/T06P212QSEA/C06P5NCGSFP) for general topics, [slack - #questions](https://openhands-ai.slack.com/archives/C06U8UTKSAD) for queries/questions, [discord - #general](https://discord.com/channels/1222935860639563850/1222935861386018885)).- When asking for help or raising issues, include necessary details like links, screenshots, or clear explanations to provide context.- Keep discussions in public channels whenever possible to allow others to benefit from the conversation, unless the matter is sensitive or private.- Always adhere to [our standards](https://github.com/All-Hands-AI/OpenHands/blob/main/CODE_OF_CONDUCT.md#our-standards) to ensure a welcoming and collaborative environment.- If you choose to mute a channel, consider setting up alerts for topics that still interest you to stay engaged. For Slack, Go to Settings → Notifications → My Keywords to add specific keywords that will notify you when mentioned. For example, if you're here for discussions about LLMs, mute the channel if it’s too busy, but set notifications to alert you only when “LLMs” appears in messages. Also for Discord, go to the channel notifications and choose the option that best describes your need.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],version 2.1, available at[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
Community Impact Guidelines were inspired by[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
For answers to common questions about this code of conduct, see the FAQ at[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at[https://www.contributor-covenant.org/translations][translations].
[homepage]: https://www.contributor-covenant.org[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html[Mozilla CoC]: https://github.com/mozilla/diversity[FAQ]: https://www.contributor-covenant.org/faq[translations]: https://www.contributor-covenant.org/translations12345678910111213141516171819202122232425262728293031323334353637383940414243# 🙌 The OpenHands Community
The OpenHands community is built around the belief that (1) AI and AI agents are going to fundamentally change the waywe build software, and (2) if this is true, we should do everything we can to make sure that the benefits provided bysuch powerful technology are accessible to everyone.
If this resonates with you, we'd love to have you join us in our quest!
## 🤝 How to Join
Check out our [How to Join the Community section.](https://github.com/All-Hands-AI/OpenHands?tab=readme-ov-file#-how-to-join-the-community)
## 💪 Becoming a Contributor
We welcome contributions from everyone! Whether you're a developer, a researcher, or simply enthusiastic about advancingthe field of software engineering with AI, there are many ways to get involved:
- **Code Contributions:** Help us develop new core functionality, improve our agents, improve the frontend and otherinterfaces, or anything else that would help make OpenHands better.- **Research and Evaluation:** Contribute to our understanding of LLMs in software engineering, participate inevaluating the models, or suggest improvements.- **Feedback and Testing:** Use the OpenHands toolset, report bugs, suggest features, or provide feedback on usability.
For details, please check [CONTRIBUTING.md](./CONTRIBUTING.md).
## Code of Conduct
We have a [Code of Conduct](./CODE_OF_CONDUCT.md) that we expect all contributors to adhere to.Long story short, we are aiming for an open, welcoming, diverse, inclusive, and healthy community.All contributors are expected to contribute to building this sort of community.
## 🛠️ Becoming a Maintainer
For contributors who have made significant and sustained contributions to the project, there is a possibility of joiningthe maintainer team. The process for this is as follows:
1. Any contributor who has made sustained and high-quality contributions to the codebase can be nominated by anymaintainer. If you feel that you may qualify you can reach out to any of the maintainers that have reviewed your PRs and ask if you can be nominated.2. Once a maintainer nominates a new maintainer, there will be a discussion period among the maintainers for at least 3 days.3. If no concerns are raised the nomination will be accepted by acclamation, and if concerns are raised there will be a discussion and possible vote.
Note that just making many PRs does not immediately imply that you will become a maintainer. We will be lookingat sustained high-quality contributions over a period of time, as well as good teamwork and adherence to our [Code of Conduct](./CODE_OF_CONDUCT.md).123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123# Contributing
Thanks for your interest in contributing to OpenHands! We welcome and appreciate contributions.
## Understanding OpenHands's CodeBase
To understand the codebase, please refer to the README in each module:- [frontend](./frontend/README.md)- [evaluation](./evaluation/README.md)- [openhands](./openhands/README.md) - [agenthub](./openhands/agenthub/README.md) - [server](./openhands/server/README.md)
## Setting up Your Development Environment
We have a separate doc [Development.md](https://github.com/All-Hands-AI/OpenHands/blob/main/Development.md) that tells you how to set up a development workflow.
## How Can I Contribute?
There are many ways that you can contribute:
1. **Download and use** OpenHands, and send [issues](https://github.com/All-Hands-AI/OpenHands/issues) when you encounter something that isn't working or a feature that you'd like to see.2. **Send feedback** after each session by [clicking the thumbs-up thumbs-down buttons](https://docs.all-hands.dev/modules/usage/feedback), so we can see where things are working and failing, and also build an open dataset for training code agents.3. **Improve the Codebase** by sending [PRs](#sending-pull-requests-to-openhands) (see details below). In particular, we have some [good first issues](https://github.com/All-Hands-AI/OpenHands/labels/good%20first%20issue) that may be ones to start on.
## What Can I Build?Here are a few ways you can help improve the codebase.
#### UI/UXWe're always looking to improve the look and feel of the application. If you've got a small fixfor something that's bugging you, feel free to open up a PR that changes the [`./frontend`](./frontend) directory.
If you're looking to make a bigger change, add a new UI element, or significantly alter the styleof the application, please open an issue first, or better, join the #frontend channel in our Slackto gather consensus from our design team first.
#### Improving the agentOur main agent is the CodeAct agent. You can [see its prompts here](https://github.com/All-Hands-AI/OpenHands/tree/main/openhands/agenthub/codeact_agent).
Changes to these prompts, and to the underlying behavior in Python, can have a huge impact on user experience.You can try modifying the prompts to see how they change the behavior of the agent as you use the applocally, but we will need to do an end-to-end evaluation of any changes here to ensure that the agentis getting better over time.
We use the [SWE-bench](https://www.swebench.com/) benchmark to test our agent. You can join the #evaluationchannel in Slack to learn more.
#### Adding a new agentYou may want to experiment with building new types of agents. You can add an agent to [`openhands/agenthub`](./openhands/agenthub)to help expand the capabilities of OpenHands.
#### Adding a new runtimeThe agent needs a place to run code and commands. When you run OpenHands on your laptop, it uses a Docker containerto do this by default. But there are other ways of creating a sandbox for the agent.
If you work for a company that provides a cloud-based runtime, you could help us add support for that runtimeby implementing the [interface specified here](https://github.com/All-Hands-AI/OpenHands/blob/main/openhands/runtime/base.py).
#### TestingWhen you write code, it is also good to write tests. Please navigate to the [`./tests`](./tests) folder to see existing test suites.At the moment, we have two kinds of tests: [`unit`](./tests/unit) and [`integration`](./evaluation/integration_tests). Please refer to the README for each test suite. These tests also run on GitHub's continuous integration to ensure quality of the project.
## Sending Pull Requests to OpenHands
You'll need to fork our repository to send us a Pull Request. You can learn moreabout how to fork a GitHub repo and open a PR with your changes in [this article](https://medium.com/swlh/forks-and-pull-requests-how-to-contribute-to-github-repos-8843fac34ce8).
### Pull Request titleAs described [here](https://github.com/commitizen/conventional-commit-types/blob/master/index.json), a valid PR title should begin with one of the following prefixes:
- `feat`: A new feature- `fix`: A bug fix- `docs`: Documentation only changes- `style`: Changes that do not affect the meaning of the code (white space, formatting, missing semicolons, etc.)- `refactor`: A code change that neither fixes a bug nor adds a feature- `perf`: A code change that improves performance- `test`: Adding missing tests or correcting existing tests- `build`: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)- `ci`: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)- `chore`: Other changes that don't modify src or test files- `revert`: Reverts a previous commit
For example, a PR title could be:- `refactor: modify package path`- `feat(frontend): xxxx`, where `(frontend)` means that this PR mainly focuses on the frontend component.
You may also check out previous PRs in the [PR list](https://github.com/All-Hands-AI/OpenHands/pulls).
### Pull Request description- If your PR is small (such as a typo fix), you can go brief.- If it contains a lot of changes, it's better to write more details.
If your changes are user-facing (e.g. a new feature in the UI, a change in behavior, or a bugfix)please include a short message that we can add to our changelog.
## How to Make Effective Contributions
### Opening Issues
If you notice any bugs or have any feature requests please open them via the [issues page](https://github.com/All-Hands-AI/OpenHands/issues). We will triage based on how critical the bug is or how potentially useful the improvement is, discuss, and implement the ones that the community has interest/effort for.
Further, if you see an issue you like, please leave a "thumbs-up" or a comment, which will help us prioritize.
### Making Pull Requests
We're generally happy to consider all pull requests with the evaluation process varying based on the type of change:
#### For Small Improvements
Small improvements with few downsides are typically reviewed and approved quickly.One thing to check when making changes is to ensure that all continuous integration tests pass, which you can check before getting a review.
#### For Core Agent Changes
We need to be more careful with changes to the core agent, as it is imperative to maintain high quality. These PRs are evaluated based on three key metrics:
1. **Accuracy**2. **Efficiency**3. **Code Complexity**
If it improves accuracy, efficiency, or both with only a minimal change to code quality, that's great we're happy to merge it in!If there are bigger tradeoffs (e.g. helping efficiency a lot and hurting accuracy a little) we might want to put it behind a feature flag.Either way, please feel free to discuss on github issues or slack, and we will give guidance and preliminary feedback.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312# Credits
## Contributors
We would like to thank all the [contributors](https://github.com/All-Hands-AI/OpenHands/graphs/contributors) who have helped make OpenHands possible. We greatly appreciate your dedication and hard work.
## Open Source Projects
OpenHands includes and adapts the following open source projects. We are grateful for their contributions to the open source community:
#### [SWE Agent](https://github.com/princeton-nlp/swe-agent) - License: MIT License - Description: Adapted for use in OpenHands's agent hub
#### [Aider](https://github.com/paul-gauthier/aider) - License: Apache License 2.0 - Description: AI pair programming tool. OpenHands has adapted and integrated its linter module for code-related tasks in [`agentskills utilities`](https://github.com/All-Hands-AI/OpenHands/tree/main/openhands/runtime/plugins/agent_skills/utils/aider)
#### [BrowserGym](https://github.com/ServiceNow/BrowserGym) - License: Apache License 2.0 - Description: Adapted in implementing the browsing agent
### Reference Implementations for Evaluation BenchmarksOpenHands integrates code of the reference implementations for the following agent evaluation benchmarks:
#### [HumanEval](https://github.com/openai/human-eval) - License: MIT License
#### [DSP](https://github.com/microsoft/DataScienceProblems) - License: MIT License
#### [HumanEvalPack](https://github.com/bigcode-project/bigcode-evaluation-harness) - License: Apache License 2.0
#### [AgentBench](https://github.com/THUDM/AgentBench) - License: Apache License 2.0
#### [SWE-Bench](https://github.com/princeton-nlp/SWE-bench) - License: MIT License
#### [BIRD](https://bird-bench.github.io/) - License: MIT License - Dataset: CC-BY-SA 4.0
#### [Gorilla APIBench](https://github.com/ShishirPatil/gorilla) - License: Apache License 2.0
#### [GPQA](https://github.com/idavidrein/gpqa) - License: MIT License
#### [ProntoQA](https://github.com/asaparov/prontoqa) - License: Apache License 2.0
## Open Source licenses
### MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
### BSD 3-Clause License
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
### Apache License 2.0
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
### Non-Open Source Reference Implementations:
#### [MultiPL-E](https://github.com/nuprl/MultiPL-E) - License: BSD 3-Clause License with Machine Learning Restriction
BSD 3-Clause License with Machine Learning Restriction
Copyright (c) 2022, Northeastern University, Oberlin College, Roblox Inc,Stevens Institute of Technology, University of Massachusetts Amherst, andWellesley College.
All rights reserved.
Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
4. The contents of this repository may not be used as training data for any machine learning model, including but not limited to neural networks.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THEIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AREDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLEFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIALDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ORSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVERCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USEOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163# Development Guide
This guide is for people working on OpenHands and editing the source code.If you wish to contribute your changes, check out the [CONTRIBUTING.md](https://github.com/All-Hands-AI/OpenHands/blob/main/CONTRIBUTING.md) on how to clone and setup the project initially before moving on.Otherwise, you can clone the OpenHands project directly.
## Start the Server for Development
### 1. Requirements
- Linux, Mac OS, or [WSL on Windows](https://learn.microsoft.com/en-us/windows/wsl/install) [Ubuntu >= 22.04]- [Docker](https://docs.docker.com/engine/install/) (For those on MacOS, make sure to allow the default Docker socket to be used from advanced settings!)- [Python](https://www.python.org/downloads/) = 3.12- [NodeJS](https://nodejs.org/en/download/package-manager) >= 20.x- [Poetry](https://python-poetry.org/docs/#installing-with-the-official-installer) >= 1.8- OS-specific dependencies: - Ubuntu: build-essential => `sudo apt-get install build-essential` - WSL: netcat => `sudo apt-get install netcat`
Make sure you have all these dependencies installed before moving on to `make build`.
#### Develop without sudo access
If you want to develop without system admin/sudo access to upgrade/install `Python` and/or `NodeJs`, you can use `conda` or `mamba` to manage the packages for you:
```bash# Download and install Mamba (a faster version of conda)curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh"bash Miniforge3-$(uname)-$(uname -m).sh
# Install Python 3.12, nodejs, and poetrymamba install python=3.12mamba install conda-forge::nodejsmamba install conda-forge::poetry```
### 2. Build and Setup The Environment
Begin by building the project which includes setting up the environment and installing dependencies. This step ensures that OpenHands is ready to run on your system:
```bashmake build```
### 3. Configuring the Language Model
OpenHands supports a diverse array of Language Models (LMs) through the powerful [litellm](https://docs.litellm.ai) library.By default, we've chosen Claude Sonnet 3.5 as our go-to model, but the world is your oyster! You can unleash thepotential of any other LM that piques your interest.
To configure the LM of your choice, run:
```bashmake setup-config```
This command will prompt you to enter the LLM API key, model name, and other variables ensuring that OpenHands is tailored to your specific needs. Note that the model name will apply only when you run headless. If you use the UI, please set the model in the UI.
Note: If you have previously run OpenHands using the docker command, you may have already set some environmental variables in your terminal. The final configurations are set from highest to lowest priority:Environment variables > config.toml variables > default variables
**Note on Alternative Models:**See [our documentation](https://docs.all-hands.dev/modules/usage/llms) for recommended models.
### 4. Running the application
#### Option A: Run the Full Application
Once the setup is complete, this command starts both the backend and frontend servers, allowing you to interact with OpenHands:
```bashmake run```
#### Option B: Individual Server Startup
- **Start the Backend Server:** If you prefer, you can start the backend server independently to focus on backend-related tasks or configurations.
```bash make start-backend ```
- **Start the Frontend Server:** Similarly, you can start the frontend server on its own to work on frontend-related components or interface enhancements. ```bash make start-frontend ```
### 6. LLM Debugging
If you encounter any issues with the Language Model (LM) or you're simply curious, export DEBUG=1 in the environment and restart the backend.OpenHands will log the prompts and responses in the logs/llm/CURRENT_DATE directory, allowing you to identify the causes.
### 7. Help
Need help or info on available targets and commands? Use the help command for all the guidance you need with OpenHands.
```bashmake help```
### 8. Testing
To run tests, refer to the following:
#### Unit tests
```bashpoetry run pytest ./tests/unit/test_*.py```
### 9. Add or update dependency
1. Add your dependency in `pyproject.toml` or use `poetry add xxx`.2. Update the poetry.lock file via `poetry lock --no-update`.
### 9. Use existing Docker image
To reduce build time (e.g., if no changes were made to the client-runtime component), you can use an existing Docker container image bysetting the SANDBOX_RUNTIME_CONTAINER_IMAGE environment variable to the desired Docker image.
Example: `export SANDBOX_RUNTIME_CONTAINER_IMAGE=ghcr.io/all-hands-ai/runtime:0.30-nikolaik`
## Develop inside Docker container
TL;DR
```bashmake docker-dev```
See more details [here](./containers/dev/README.md).
If you are just interested in running `OpenHands` without installing all the required tools on your host.
```bashmake docker-run```
If you do not have `make` on your host, run:
```bashcd ./containers/dev./dev.sh```
You do need [Docker](https://docs.docker.com/engine/install/) installed on your host though.
## Key Documentation Resources
Here's a guide to the important documentation files in the repository:
- [/README.md](./README.md): Main project overview, features, and basic setup instructions- [/Development.md](./Development.md) (this file): Comprehensive guide for developers working on OpenHands- [/CONTRIBUTING.md](./CONTRIBUTING.md): Guidelines for contributing to the project, including code style and PR process- [/docs/DOC_STYLE_GUIDE.md](./docs/DOC_STYLE_GUIDE.md): Standards for writing and maintaining project documentation- [/openhands/README.md](./openhands/README.md): Details about the backend Python implementation- [/frontend/README.md](./frontend/README.md): Frontend React application setup and development guide- [/containers/README.md](./containers/README.md): Information about Docker containers and deployment- [/tests/unit/README.md](./tests/unit/README.md): Guide to writing and running unit tests- [/evaluation/README.md](./evaluation/README.md): Documentation for the evaluation framework and benchmarks- [/microagents/README.md](./microagents/README.md): Information about the microagents architecture and implementation- [/openhands/server/README.md](./openhands/server/README.md): Server implementation details and API documentation- [/openhands/runtime/README.md](./openhands/runtime/README.md): Documentation for the runtime environment and execution model1234567891011121314151617181920212223242526272829303132# Issue TriageThese are the procedures and guidelines on how issues are triaged in this repo by the maintainers.
## General* All issues must be tagged with **enhancement**, **bug** or **troubleshooting/help**.* Issues may be tagged with what it relates to (**agent quality**, **frontend**, **resolver**, etc.).
## Severity* **Low**: Minor issues or affecting single user.* **Medium**: Affecting multiple users.* **High**: High visibility issues or affecting many users.* **Critical**: Affecting all users or potential security issues.
## Effort* Issues may be estimated with effort required (**small effort**, **medium effort**, **large effort**).
## Difficulty* Issues with low implementation difficulty may be tagged with **good first issue**.
## Not Enough Information* User is asked to provide more information (logs, how to reproduce, etc.) when the issue is not clear.* If an issue is unclear and the author does not provide more information or respond to a request,the issue may be closed as **not planned** (Usually after a week).
## Multiple Requests/Fixes in One Issue* These issues will be narrowed down to one request/fix so the issue is more easily tracked and fixed.* Issues may be broken down into multiple issues if required.
## Stale and Auto Closures* In order to keep a maintainable backlog, issues that have no activity within 30 days are automatically marked as **Stale**.* If issues marked as **Stale** continue to have no activity for 7 more days, they will automatically be closed as not planned.* Issues may be reopened by maintainers if deemed important.12345678910111213141516171819202122232425The MIT License (MIT)=====================
Copyright © 2023
Permission is hereby granted, free of charge, to any personobtaining a copy of this software and associated documentationfiles (the “Software”), to deal in the Software withoutrestriction, including without limitation the rights to use,copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom theSoftware is furnished to do so, subject to the followingconditions:
The above copyright notice and this permission notice shall beincluded in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIESOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE ANDNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHTHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISINGFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OROTHER DEALINGS IN THE SOFTWARE.12345# Exclude all Python bytecode filesglobal-exclude *.pyc
# Exclude Python cache directoriesglobal-exclude __pycache__123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303SHELL=/usr/bin/env bash# Makefile for OpenHands project
# VariablesBACKEND_HOST ?= "127.0.0.1"BACKEND_PORT = 3000BACKEND_HOST_PORT = "$(BACKEND_HOST):$(BACKEND_PORT)"FRONTEND_PORT = 3001DEFAULT_WORKSPACE_DIR = "./workspace"DEFAULT_MODEL = "gpt-4o"CONFIG_FILE = config.tomlPRE_COMMIT_CONFIG_PATH = "./dev_config/python/.pre-commit-config.yaml"PYTHON_VERSION = 3.12
# ANSI color codesGREEN=$(shell tput -Txterm setaf 2)YELLOW=$(shell tput -Txterm setaf 3)RED=$(shell tput -Txterm setaf 1)BLUE=$(shell tput -Txterm setaf 6)RESET=$(shell tput -Txterm sgr0)
# Buildbuild: @echo "$(GREEN)Building project...$(RESET)" @$(MAKE) -s check-dependencies @$(MAKE) -s install-python-dependencies @$(MAKE) -s install-frontend-dependencies @$(MAKE) -s install-pre-commit-hooks @$(MAKE) -s build-frontend @echo "$(GREEN)Build completed successfully.$(RESET)"
check-dependencies: @echo "$(YELLOW)Checking dependencies...$(RESET)" @$(MAKE) -s check-system @$(MAKE) -s check-python @$(MAKE) -s check-npm @$(MAKE) -s check-nodejsifeq ($(INSTALL_DOCKER),) @$(MAKE) -s check-dockerendif @$(MAKE) -s check-poetry @echo "$(GREEN)Dependencies checked successfully.$(RESET)"
check-system: @echo "$(YELLOW)Checking system...$(RESET)" @if [ "$(shell uname)" = "Darwin" ]; then \ echo "$(BLUE)macOS detected.$(RESET)"; \ elif [ "$(shell uname)" = "Linux" ]; then \ if [ -f "/etc/manjaro-release" ]; then \ echo "$(BLUE)Manjaro Linux detected.$(RESET)"; \ else \ echo "$(BLUE)Linux detected.$(RESET)"; \ fi; \ elif [ "$$(uname -r | grep -i microsoft)" ]; then \ echo "$(BLUE)Windows Subsystem for Linux detected.$(RESET)"; \ else \ echo "$(RED)Unsupported system detected. Please use macOS, Linux, or Windows Subsystem for Linux (WSL).$(RESET)"; \ exit 1; \ fi
check-python: @echo "$(YELLOW)Checking Python installation...$(RESET)" @if command -v python$(PYTHON_VERSION) > /dev/null; then \ echo "$(BLUE)$(shell python$(PYTHON_VERSION) --version) is already installed.$(RESET)"; \ else \ echo "$(RED)Python $(PYTHON_VERSION) is not installed. Please install Python $(PYTHON_VERSION) to continue.$(RESET)"; \ exit 1; \ fi
check-npm: @echo "$(YELLOW)Checking npm installation...$(RESET)" @if command -v npm > /dev/null; then \ echo "$(BLUE)npm $(shell npm --version) is already installed.$(RESET)"; \ else \ echo "$(RED)npm is not installed. Please install Node.js to continue.$(RESET)"; \ exit 1; \ fi
check-nodejs: @echo "$(YELLOW)Checking Node.js installation...$(RESET)" @if command -v node > /dev/null; then \ NODE_VERSION=$(shell node --version | sed -E 's/v//g'); \ IFS='.' read -r -a NODE_VERSION_ARRAY <<< "$$NODE_VERSION"; \ if [ "$${NODE_VERSION_ARRAY[0]}" -ge 22 ]; then \ echo "$(BLUE)Node.js $$NODE_VERSION is already installed.$(RESET)"; \ else \ echo "$(RED)Node.js 22.x or later is required. Please install Node.js 22.x or later to continue.$(RESET)"; \ exit 1; \ fi; \ else \ echo "$(RED)Node.js is not installed. Please install Node.js to continue.$(RESET)"; \ exit 1; \ fi
check-docker: @echo "$(YELLOW)Checking Docker installation...$(RESET)" @if command -v docker > /dev/null; then \ echo "$(BLUE)$(shell docker --version) is already installed.$(RESET)"; \ else \ echo "$(RED)Docker is not installed. Please install Docker to continue.$(RESET)"; \ exit 1; \ fi
check-poetry: @echo "$(YELLOW)Checking Poetry installation...$(RESET)" @if command -v poetry > /dev/null; then \ POETRY_VERSION=$(shell poetry --version 2>&1 | sed -E 's/Poetry \(version ([0-9]+\.[0-9]+\.[0-9]+)\)/\1/'); \ IFS='.' read -r -a POETRY_VERSION_ARRAY <<< "$$POETRY_VERSION"; \ if [ $${POETRY_VERSION_ARRAY[0]} -gt 1 ] || ([ $${POETRY_VERSION_ARRAY[0]} -eq 1 ] && [ $${POETRY_VERSION_ARRAY[1]} -ge 8 ]); then \ echo "$(BLUE)$(shell poetry --version) is already installed.$(RESET)"; \ else \ echo "$(RED)Poetry 1.8 or later is required. You can install poetry by running the following command, then adding Poetry to your PATH:"; \ echo "$(RED) curl -sSL https://install.python-poetry.org | python$(PYTHON_VERSION) -$(RESET)"; \ echo "$(RED)More detail here: https://python-poetry.org/docs/#installing-with-the-official-installer$(RESET)"; \ exit 1; \ fi; \ else \ echo "$(RED)Poetry is not installed. You can install poetry by running the following command, then adding Poetry to your PATH:"; \ echo "$(RED) curl -sSL https://install.python-poetry.org | python$(PYTHON_VERSION) -$(RESET)"; \ echo "$(RED)More detail here: https://python-poetry.org/docs/#installing-with-the-official-installer$(RESET)"; \ exit 1; \ fi
install-python-dependencies: @echo "$(GREEN)Installing Python dependencies...$(RESET)" @if [ -z "${TZ}" ]; then \ echo "Defaulting TZ (timezone) to UTC"; \ export TZ="UTC"; \ fi poetry env use python$(PYTHON_VERSION) @if [ "$(shell uname)" = "Darwin" ]; then \ echo "$(BLUE)Installing chroma-hnswlib...$(RESET)"; \ export HNSWLIB_NO_NATIVE=1; \ poetry run pip install chroma-hnswlib; \ fi @poetry install @if [ -f "/etc/manjaro-release" ]; then \ echo "$(BLUE)Detected Manjaro Linux. Installing Playwright dependencies...$(RESET)"; \ poetry run pip install playwright; \ poetry run playwright install chromium; \ else \ if [ ! -f cache/playwright_chromium_is_installed.txt ]; then \ echo "Running playwright install --with-deps chromium..."; \ poetry run playwright install --with-deps chromium; \ mkdir -p cache; \ touch cache/playwright_chromium_is_installed.txt; \ else \ echo "Setup already done. Skipping playwright installation."; \ fi \ fi @echo "$(GREEN)Python dependencies installed successfully.$(RESET)"
install-frontend-dependencies: @echo "$(YELLOW)Setting up frontend environment...$(RESET)" @echo "$(YELLOW)Detect Node.js version...$(RESET)" @cd frontend && node ./scripts/detect-node-version.js echo "$(BLUE)Installing frontend dependencies with npm...$(RESET)" @cd frontend && npm install @echo "$(GREEN)Frontend dependencies installed successfully.$(RESET)"
install-pre-commit-hooks: @echo "$(YELLOW)Installing pre-commit hooks...$(RESET)" @git config --unset-all core.hooksPath || true @poetry run pre-commit install --config $(PRE_COMMIT_CONFIG_PATH) @echo "$(GREEN)Pre-commit hooks installed successfully.$(RESET)"
lint-backend: @echo "$(YELLOW)Running linters...$(RESET)" @poetry run pre-commit run --files openhands/**/* agenthub/**/* evaluation/**/* --show-diff-on-failure --config $(PRE_COMMIT_CONFIG_PATH)
lint-frontend: @echo "$(YELLOW)Running linters for frontend...$(RESET)" @cd frontend && npm run lint
lint: @$(MAKE) -s lint-frontend @$(MAKE) -s lint-backend
test-frontend: @echo "$(YELLOW)Running tests for frontend...$(RESET)" @cd frontend && npm run test
test: @$(MAKE) -s test-frontend
build-frontend: @echo "$(YELLOW)Building frontend...$(RESET)" @cd frontend && npm run build
# Start backendstart-backend: @echo "$(YELLOW)Starting backend...$(RESET)" @poetry run uvicorn openhands.server.listen:app --host $(BACKEND_HOST) --port $(BACKEND_PORT) --reload --reload-exclude "./workspace"
# Start frontendstart-frontend: @echo "$(YELLOW)Starting frontend...$(RESET)" @cd frontend && VITE_BACKEND_HOST=$(BACKEND_HOST_PORT) VITE_FRONTEND_PORT=$(FRONTEND_PORT) npm run dev -- --port $(FRONTEND_PORT) --host $(BACKEND_HOST)
# Common setup for running the app (non-callable)_run_setup: @if [ "$(OS)" = "Windows_NT" ]; then \ echo "$(RED) Windows is not supported, use WSL instead!$(RESET)"; \ exit 1; \ fi @mkdir -p logs @echo "$(YELLOW)Starting backend server...$(RESET)" @poetry run uvicorn openhands.server.listen:app --host $(BACKEND_HOST) --port $(BACKEND_PORT) & @echo "$(YELLOW)Waiting for the backend to start...$(RESET)" @until nc -z localhost $(BACKEND_PORT); do sleep 0.1; done @echo "$(GREEN)Backend started successfully.$(RESET)"
# Run the app (standard mode)run: @echo "$(YELLOW)Running the app...$(RESET)" @$(MAKE) -s _run_setup @$(MAKE) -s start-frontend @echo "$(GREEN)Application started successfully.$(RESET)"
# Run the app (in docker)docker-run: WORKSPACE_BASE ?= $(PWD)/workspacedocker-run: @if [ -f /.dockerenv ]; then \ echo "Running inside a Docker container. Exiting..."; \ exit 0; \ else \ echo "$(YELLOW)Running the app in Docker $(OPTIONS)...$(RESET)"; \ export WORKSPACE_BASE=${WORKSPACE_BASE}; \ export SANDBOX_USER_ID=$(shell id -u); \ export DATE=$(shell date +%Y%m%d%H%M%S); \ docker compose up $(OPTIONS); \ fi
# Run the app (WSL mode)run-wsl: @echo "$(YELLOW)Running the app in WSL mode...$(RESET)" @$(MAKE) -s _run_setup @cd frontend && echo "$(BLUE)Starting frontend with npm (WSL mode)...$(RESET)" && npm run dev_wsl -- --port $(FRONTEND_PORT) @echo "$(GREEN)Application started successfully in WSL mode.$(RESET)"
# Setup config.tomlsetup-config: @echo "$(YELLOW)Setting up config.toml...$(RESET)" @$(MAKE) setup-config-prompts @mv $(CONFIG_FILE).tmp $(CONFIG_FILE) @echo "$(GREEN)Config.toml setup completed.$(RESET)"
setup-config-prompts: @echo "[core]" > $(CONFIG_FILE).tmp
@read -p "Enter your workspace directory (as absolute path) [default: $(DEFAULT_WORKSPACE_DIR)]: " workspace_dir; \ workspace_dir=$${workspace_dir:-$(DEFAULT_WORKSPACE_DIR)}; \ echo "workspace_base=\"$$workspace_dir\"" >> $(CONFIG_FILE).tmp
@echo "" >> $(CONFIG_FILE).tmp
@echo "[llm]" >> $(CONFIG_FILE).tmp @read -p "Enter your LLM model name, used for running without UI. Set the model in the UI after you start the app. (see https://docs.litellm.ai/docs/providers for full list) [default: $(DEFAULT_MODEL)]: " llm_model; \ llm_model=$${llm_model:-$(DEFAULT_MODEL)}; \ echo "model=\"$$llm_model\"" >> $(CONFIG_FILE).tmp
@read -p "Enter your LLM api key: " llm_api_key; \ echo "api_key=\"$$llm_api_key\"" >> $(CONFIG_FILE).tmp
@read -p "Enter your LLM base URL [mostly used for local LLMs, leave blank if not needed - example: http://localhost:5001/v1/]: " llm_base_url; \ if [[ ! -z "$$llm_base_url" ]]; then echo "base_url=\"$$llm_base_url\"" >> $(CONFIG_FILE).tmp; fi
# Develop in containerdocker-dev: @if [ -f /.dockerenv ]; then \ echo "Running inside a Docker container. Exiting..."; \ exit 0; \ else \ echo "$(YELLOW)Build and run in Docker $(OPTIONS)...$(RESET)"; \ ./containers/dev/dev.sh $(OPTIONS); \ fi
# Clean up all cachesclean: @echo "$(YELLOW)Cleaning up caches...$(RESET)" @rm -rf openhands/.cache @echo "$(GREEN)Caches cleaned up successfully.$(RESET)"
# Helphelp: @echo "$(BLUE)Usage: make [target]$(RESET)" @echo "Targets:" @echo " $(GREEN)build$(RESET) - Build project, including environment setup and dependencies." @echo " $(GREEN)lint$(RESET) - Run linters on the project." @echo " $(GREEN)setup-config$(RESET) - Setup the configuration for OpenHands by providing LLM API key," @echo " LLM Model name, and workspace directory." @echo " $(GREEN)start-backend$(RESET) - Start the backend server for the OpenHands project." @echo " $(GREEN)start-frontend$(RESET) - Start the frontend server for the OpenHands project." @echo " $(GREEN)run$(RESET) - Run the OpenHands application, starting both backend and frontend servers." @echo " Backend Log file will be stored in the 'logs' directory." @echo " $(GREEN)docker-dev$(RESET) - Build and run the OpenHands application in Docker." @echo " $(GREEN)docker-run$(RESET) - Run the OpenHands application, starting both backend and frontend servers in Docker." @echo " $(GREEN)help$(RESET) - Display this help message, providing information on available targets."
# Phony targets.PHONY: build check-dependencies check-python check-npm check-docker check-poetry install-python-dependencies install-frontend-dependencies install-pre-commit-hooks lint start-backend start-frontend run run-wsl setup-config setup-config-prompts help.PHONY: docker-dev docker-run123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869234567870107172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141<a name="readme-top"></a>
<div align="center"> <img src="./docs/static/img/logo.png" alt="Logo" width="200"> <h1 align="center">OpenHands: Code Less, Make More</h1></div>
<div align="center"> <a href="https://github.com/All-Hands-AI/OpenHands/graphs/contributors"><img src="https://img.shields.io/github/contributors/All-Hands-AI/OpenHands?style=for-the-badge&color=blue" alt="Contributors"></a> <a href="https://github.com/All-Hands-AI/OpenHands/stargazers"><img src="https://img.shields.io/github/stars/All-Hands-AI/OpenHands?style=for-the-badge&color=blue" alt="Stargazers"></a> <a href="https://codecov.io/github/All-Hands-AI/OpenHands?branch=main"><img alt="CodeCov" src="https://img.shields.io/codecov/c/github/All-Hands-AI/OpenHands?style=for-the-badge&color=blue"></a> <a href="https://github.com/All-Hands-AI/OpenHands/blob/main/LICENSE"><img src="https://img.shields.io/github/license/All-Hands-AI/OpenHands?style=for-the-badge&color=blue" alt="MIT License"></a> <br/> <a href="https://join.slack.com/t/openhands-ai/shared_invite/zt-2ngejmfw6-9gW4APWOC9XUp1n~SiQ6iw"><img src="https://img.shields.io/badge/Slack-Join%20Us-red?logo=slack&logoColor=white&style=for-the-badge" alt="Join our Slack community"></a> <a href="https://discord.gg/ESHStjSjD4"><img src="https://img.shields.io/badge/Discord-Join%20Us-purple?logo=discord&logoColor=white&style=for-the-badge" alt="Join our Discord community"></a> <a href="https://github.com/All-Hands-AI/OpenHands/blob/main/CREDITS.md"><img src="https://img.shields.io/badge/Project-Credits-blue?style=for-the-badge&color=FFE165&logo=github&logoColor=white" alt="Credits"></a> <br/> <a href="https://docs.all-hands.dev/modules/usage/getting-started"><img src="https://img.shields.io/badge/Documentation-000?logo=googledocs&logoColor=FFE165&style=for-the-badge" alt="Check out the documentation"></a> <a href="https://arxiv.org/abs/2407.16741"><img src="https://img.shields.io/badge/Paper%20on%20Arxiv-000?logoColor=FFE165&logo=arxiv&style=for-the-badge" alt="Paper on Arxiv"></a> <a href="https://huggingface.co/spaces/OpenHands/evaluation"><img src="https://img.shields.io/badge/Benchmark%20score-000?logoColor=FFE165&logo=huggingface&style=for-the-badge" alt="Evaluation Benchmark Score"></a> <hr></div>
Welcome to OpenHands (formerly OpenDevin), a platform for software development agents powered by AI.
OpenHands agents can do anything a human developer can: modify code, run commands, browse the web,call APIs, and yes—even copy code snippets from StackOverflow.
Learn more at [docs.all-hands.dev](https://docs.all-hands.dev), or jump to the [Quick Start](#-quick-start).
> [!IMPORTANT]> Using OpenHands for work? We'd love to chat! Fill out> [this short form](https://docs.google.com/forms/d/e/1FAIpQLSet3VbGaz8z32gW9Wm-Grl4jpt5WgMXPgJ4EDPVmCETCBpJtQ/viewform)> to join our Design Partner program, where you'll get early access to commercial features and the opportunity to provide input on our product roadmap.

## ⚡ Quick Start
The easiest way to run OpenHands is in Docker.See the [Running OpenHands](https://docs.all-hands.dev/modules/usage/installation) guide forsystem requirements and more information.
```bashdocker pull docker.all-hands.dev/all-hands-ai/runtime:0.30-nikolaik
docker run -it --rm --pull=always \ -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.30-nikolaik \ -e LOG_ALL_EVENTS=true \ -v /var/run/docker.sock:/var/run/docker.sock \ -v ~/.openhands-state:/.openhands-state \ -p 3000:3000 \ --add-host host.docker.internal:host-gateway \ --name openhands-app \ docker.all-hands.dev/all-hands-ai/openhands:0.30```
> [!WARNING]> On a public network? See our [Hardened Docker Installation](https://docs.all-hands.dev/modules/usage/runtimes/docker#hardened-docker-installation) guide> to secure your deployment by restricting network binding and implementing additional security measures.
You'll find OpenHands running at [http://localhost:3000](http://localhost:3000)!
Finally, you'll need a model provider and API key.[Anthropic's Claude 3.5 Sonnet](https://www.anthropic.com/api) (`anthropic/claude-3-5-sonnet-20241022`)works best, but you have [many options](https://docs.all-hands.dev/modules/usage/llms).
---title: READMEemoji: 🐢colorFrom: indigocolorTo: graysdk: dockerpinned: false---
Edit this `README.md` markdown file to author your organization card.You can also [connect OpenHands to your local filesystem](https://docs.all-hands.dev/modules/usage/runtimes#connecting-to-your-filesystem),run OpenHands in a scriptable [headless mode](https://docs.all-hands.dev/modules/usage/how-to/headless-mode),interact with it via a [friendly CLI](https://docs.all-hands.dev/modules/usage/how-to/cli-mode),or run it on tagged issues with [a github action](https://docs.all-hands.dev/modules/usage/how-to/github-action).
Visit [Running OpenHands](https://docs.all-hands.dev/modules/usage/installation) for more information and setup instructions.
> [!CAUTION]> OpenHands is meant to be run by a single user on their local workstation.> It is not appropriate for multi-tenant deployments where multiple users share the same instance. There is no built-in isolation or scalability.>> If you're interested in running OpenHands in a multi-tenant environment, please> [get in touch with us](https://docs.google.com/forms/d/e/1FAIpQLSet3VbGaz8z32gW9Wm-Grl4jpt5WgMXPgJ4EDPVmCETCBpJtQ/viewform)> for advanced deployment options.
If you want to modify the OpenHands source code, check out [Development.md](https://github.com/All-Hands-AI/OpenHands/blob/main/Development.md).
Having issues? The [Troubleshooting Guide](https://docs.all-hands.dev/modules/usage/troubleshooting) can help.
## 📖 Documentation
To learn more about the project, and for tips on using OpenHands,check out our [documentation](https://docs.all-hands.dev/modules/usage/getting-started).
There you'll find resources on how to use different LLM providers,troubleshooting resources, and advanced configuration options.
## 🤝 How to Join the Community
OpenHands is a community-driven project, and we welcome contributions from everyone. We do most of our communicationthrough Slack, so this is the best place to start, but we also are happy to have you contact us on Discord or Github:
- [Join our Slack workspace](https://join.slack.com/t/openhands-ai/shared_invite/zt-2ngejmfw6-9gW4APWOC9XUp1n~SiQ6iw) - Here we talk about research, architecture, and future development.- [Join our Discord server](https://discord.gg/ESHStjSjD4) - This is a community-run server for general discussion, questions, and feedback.- [Read or post Github Issues](https://github.com/All-Hands-AI/OpenHands/issues) - Check out the issues we're working on, or add your own ideas.
See more about the community in [COMMUNITY.md](./COMMUNITY.md) or find details on contributing in [CONTRIBUTING.md](./CONTRIBUTING.md).
## 📈 Progress
See the monthly OpenHands roadmap [here](https://github.com/orgs/All-Hands-AI/projects/1) (updated at the maintainer's meeting at the end of each month).
<p align="center"> <a href="https://star-history.com/#All-Hands-AI/OpenHands&Date"> <img src="https://api.star-history.com/svg?repos=All-Hands-AI/OpenHands&type=Date" width="500" alt="Star History Chart"> </a></p>
## 📜 License
Distributed under the MIT License. See [`LICENSE`](./LICENSE) for more information.
## 🙏 Acknowledgements
OpenHands is built by a large number of contributors, and every contribution is greatly appreciated! We also build upon other open source projects, and we are deeply thankful for their work.
For a list of open source projects and licenses used in OpenHands, please see our [CREDITS.md](./CREDITS.md) file.
## 📚 Cite
```@misc{openhands, title={{OpenHands: An Open Platform for AI Software Developers as Generalist Agents}}, author={Xingyao Wang and Boxuan Li and Yufan Song and Frank F. Xu and Xiangru Tang and Mingchen Zhuge and Jiayi Pan and Yueqi Song and Bowen Li and Jaskirat Singh and Hoang H. Tran and Fuqiang Li and Ren Ma and Mingzhang Zheng and Bill Qian and Yanjun Shao and Niklas Muennighoff and Yizhe Zhang and Binyuan Hui and Junyang Lin and Robert Brennan and Hao Peng and Heng Ji and Graham Neubig}, year={2024}, eprint={2407.16741}, archivePrefix={arXiv}, primaryClass={cs.SE}, url={https://arxiv.org/abs/2407.16741},}```1234#!/usr/bin/env bashset -e
poetry build -v123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386###################### OpenHands Configuration Example ######################## All settings have default values, so you only need to uncomment and# modify what you want to change# The fields within each section are sorted in alphabetical order.###############################################################################
#################################### Core ##################################### General core configurations##############################################################################[core]# API key for E2B#e2b_api_key = ""
# API key for Modal#modal_api_token_id = ""#modal_api_token_secret = ""
# API key for Daytona#daytona_api_key = ""
# Daytona Target#daytona_target = ""
# Base path for the workspace#workspace_base = "./workspace"
# Cache directory path#cache_dir = "/tmp/cache"
# Reasoning effort for o1 models (low, medium, high, or not set)#reasoning_effort = "medium"
# Debugging enabled#debug = false
# Disable color in terminal output#disable_color = false
# Path to store trajectories, can be a folder or a file# If it's a folder, the session id will be used as the file name#save_trajectory_path="./trajectories"
# Whether to save screenshots in the trajectory# The screenshots are encoded and can make trajectory json files very large#save_screenshots_in_trajectory = false
# Path to replay a trajectory, must be a file path# If provided, trajectory will be loaded and replayed before the# agent responds to any user instruction#replay_trajectory_path = ""
# File store path#file_store_path = "/tmp/file_store"
# File store type#file_store = "memory"
# Maximum file size for uploads, in megabytes#file_uploads_max_file_size_mb = 0
# Maximum budget per task, 0.0 means no limit#max_budget_per_task = 0.0
# Maximum number of iterations#max_iterations = 250
# Path to mount the workspace in the sandbox#workspace_mount_path_in_sandbox = "/workspace"
# Path to mount the workspace#workspace_mount_path = ""
# Path to rewrite the workspace mount path to#workspace_mount_rewrite = ""
# Run as openhands#run_as_openhands = true
# Runtime environment#runtime = "docker"
# Name of the default agent#default_agent = "CodeActAgent"
# JWT secret for authentication#jwt_secret = ""
# Restrict file types for file uploads#file_uploads_restrict_file_types = false
# List of allowed file extensions for uploads#file_uploads_allowed_extensions = [".*"]
# Whether to enable the default LLM summarizing condenser when no condenser is specified in config# When true, a LLMSummarizingCondenserConfig will be used as the default condenser# When false, a NoOpCondenserConfig (no summarization) will be used#enable_default_condenser = true
# Maximum number of concurrent conversations per user#max_concurrent_conversations = 3
# Maximum age of conversations in seconds before they are automatically closed#conversation_max_age_seconds = 864000 # 10 days
#################################### LLM ###################################### Configuration for LLM models (group name starts with 'llm')# use 'llm' for the default LLM config##############################################################################[llm]# AWS access key ID#aws_access_key_id = ""
# AWS region name#aws_region_name = ""
# AWS secret access key#aws_secret_access_key = ""
# API key to use (For Headless / CLI only - In Web this is overridden by Session Init)api_key = ""
# API base URL (For Headless / CLI only - In Web this is overridden by Session Init)#base_url = ""
# API version#api_version = ""
# Cost per input token#input_cost_per_token = 0.0
# Cost per output token#output_cost_per_token = 0.0
# Custom LLM provider#custom_llm_provider = ""
# Maximum number of characters in an observation's content#max_message_chars = 10000
# Maximum number of input tokens#max_input_tokens = 0
# Maximum number of output tokens#max_output_tokens = 0
# Model to use. (For Headless / CLI only - In Web this is overridden by Session Init)model = "gpt-4o"
# Number of retries to attempt when an operation fails with the LLM.# Increase this value to allow more attempts before giving up#num_retries = 8
# Maximum wait time (in seconds) between retry attempts# This caps the exponential backoff to prevent excessively long#retry_max_wait = 120
# Minimum wait time (in seconds) between retry attempts# This sets the initial delay before the first retry#retry_min_wait = 15
# Multiplier for exponential backoff calculation# The wait time increases by this factor after each failed attempt# A value of 2.0 means each retry waits twice as long as the previous one#retry_multiplier = 2.0
# Drop any unmapped (unsupported) params without causing an exception#drop_params = false
# Modify params for litellm to do transformations like adding a default message, when a message is empty.# Note: this setting is global, unlike drop_params, it cannot be overridden in each call to litellm.#modify_params = true
# Using the prompt caching feature if provided by the LLM and supported#caching_prompt = true
# Base URL for the OLLAMA API#ollama_base_url = ""
# Temperature for the API#temperature = 0.0
# Timeout for the API#timeout = 0
# Top p for the API#top_p = 1.0
# If model is vision capable, this option allows to disable image processing (useful for cost reduction).#disable_vision = true
# Custom tokenizer to use for token counting# https://docs.litellm.ai/docs/completion/token_usage#custom_tokenizer = ""
# Whether to use native tool calling if supported by the model. Can be true, false, or None by default, which chooses the model's default behavior based on the evaluation.# ATTENTION: Based on evaluation, enabling native function calling may lead to worse results# in some scenarios. Use with caution and consider testing with your specific use case.# https://github.com/All-Hands-AI/OpenHands/pull/4711#native_tool_calling = None
[llm.gpt4o-mini]api_key = ""model = "gpt-4o"
#################################### Agent #################################### Configuration for agents (group name starts with 'agent')# Use 'agent' for the default agent config# otherwise, group name must be `agent.<agent_name>` (case-sensitive), e.g.# agent.CodeActAgent##############################################################################[agent]
# Whether the browsing tool is enabledcodeact_enable_browsing = true
# Whether the LLM draft editor is enabledcodeact_enable_llm_editor = false
# Whether the IPython tool is enabledcodeact_enable_jupyter = true
# LLM config group to use#llm_config = 'your-llm-config-group'
# Whether to use prompt extension (e.g., microagent, repo/runtime info) at all#enable_prompt_extensions = true
# List of microagents to disable#disabled_microagents = []
# Whether history should be truncated to continue the session when hitting LLM context# length limitenable_history_truncation = true
[agent.RepoExplorerAgent]# Example: use a cheaper model for RepoExplorerAgent to reduce cost, especially# useful when an agent doesn't demand high quality but uses a lot of tokensllm_config = 'gpt3'
#################################### Sandbox #################################### Configuration for the sandbox##############################################################################[sandbox]# Sandbox timeout in seconds#timeout = 120
# Sandbox user ID#user_id = 1000
# Container image to use for the sandbox#base_container_image = "nikolaik/python-nodejs:python3.12-nodejs22"
# Use host network#use_host_network = false
# Runtime extra build args#runtime_extra_build_args = ["--network=host", "--add-host=host.docker.internal:host-gateway"]
# Enable auto linting after editing#enable_auto_lint = false
# Whether to initialize plugins#initialize_plugins = true
# Extra dependencies to install in the runtime image#runtime_extra_deps = ""
# Environment variables to set at the launch of the runtime#runtime_startup_env_vars = {}
# BrowserGym environment to use for evaluation#browsergym_eval_env = ""
# Platform to use for building the runtime image (e.g., "linux/amd64")#platform = ""
# Force rebuild of runtime image even if it exists#force_rebuild_runtime = false
# Runtime container image to use (if not provided, will be built from base_container_image)#runtime_container_image = ""
# Keep runtime alive after session ends#keep_runtime_alive = false
# Pause closed runtimes instead of stopping them#pause_closed_runtimes = false
# Delay in seconds before closing idle runtimes#close_delay = 300
# Remove all containers when stopping the runtime#rm_all_containers = false
# Enable GPU support in the runtime#enable_gpu = false
# Additional Docker runtime kwargs#docker_runtime_kwargs = {}
#################################### Security #################################### Configuration for security features##############################################################################[security]
# Enable confirmation mode (For Headless / CLI only - In Web this is overridden by Session Init)#confirmation_mode = false
# The security analyzer to use (For Headless / CLI only - In Web this is overridden by Session Init)#security_analyzer = ""
# Whether to enable security analyzer#enable_security_analyzer = false
#################################### Condenser ################################## Condensers control how conversation history is managed and compressed when# the context grows too large. Each agent uses one condenser configuration.##############################################################################[condenser]# The type of condenser to use. Available options:# - "noop": No condensing, keeps full history (default)# - "observation_masking": Keeps full event structure but masks older observations# - "recent": Keeps only recent events and discards older ones# - "llm": Uses an LLM to summarize conversation history# - "amortized": Intelligently forgets older events while preserving important context# - "llm_attention": Uses an LLM to prioritize most relevant contexttype = "noop"
# Examples for each condenser type (uncomment and modify as needed):
# 1. NoOp Condenser - No additional settings needed#type = "noop"
# 2. Observation Masking Condenser#type = "observation_masking"# Number of most-recent events where observations will not be masked#attention_window = 100
# 3. Recent Events Condenser#type = "recent"# Number of initial events to always keep (typically includes task description)#keep_first = 1# Maximum number of events to keep in history#max_events = 100
# 4. LLM Summarizing Condenser#type = "llm"# Reference to an LLM config to use for summarization#llm_config = "condenser"# Number of initial events to always keep (typically includes task description)#keep_first = 1# Maximum size of history before triggering summarization#max_size = 100
# 5. Amortized Forgetting Condenser#type = "amortized"# Number of initial events to always keep (typically includes task description)#keep_first = 1# Maximum size of history before triggering forgetting#max_size = 100
# 6. LLM Attention Condenser#type = "llm_attention"# Reference to an LLM config to use for attention scoring#llm_config = "condenser"# Number of initial events to always keep (typically includes task description)#keep_first = 1# Maximum size of history before triggering attention mechanism#max_size = 100
# Example of a custom LLM configuration for condensers that require an LLM# If not provided, it falls back to the default LLM#[llm.condenser]#model = "gpt-4o"#temperature = 0.1#max_tokens = 1024
#################################### Eval ##################################### Configuration for the evaluation, please refer to the specific evaluation# plugin for the available options##############################################################################123456789101112# Docker Containers
Each folder here contains a Dockerfile, and a config.sh describing how to buildthe images and where to push them. These images are built and pushed in GitHub Actionsby the `ghcr.yml` workflow.
## Building Manually
```bashdocker build -f containers/app/Dockerfile -t openhands .docker build -f containers/sandbox/Dockerfile -t sandbox .```1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798ARG OPENHANDS_BUILD_VERSION=devFROM node:21.7.2-bookworm-slim AS frontend-builder
WORKDIR /app
COPY ./frontend/package.json frontend/package-lock.json ./RUN npm install -g npm@10.5.1RUN npm ci
COPY ./frontend ./RUN npm run build
FROM python:3.12.3-slim AS backend-builder
WORKDIR /appENV PYTHONPATH='/app'
ENV POETRY_NO_INTERACTION=1 \ POETRY_VIRTUALENVS_IN_PROJECT=1 \ POETRY_VIRTUALENVS_CREATE=1 \ POETRY_CACHE_DIR=/tmp/poetry_cache
RUN apt-get update -y \ && apt-get install -y curl make git build-essential \ && python3 -m pip install poetry==1.8.2 --break-system-packages
COPY ./pyproject.toml ./poetry.lock ./RUN touch README.mdRUN export POETRY_CACHE_DIR && poetry install --without evaluation --no-root && rm -rf $POETRY_CACHE_DIR
FROM python:3.12.3-slim AS openhands-app
WORKDIR /app
ARG OPENHANDS_BUILD_VERSION #re-declare for this section
ENV RUN_AS_OPENHANDS=true# A random number--we need this to be different from the user's UID on the host machineENV OPENHANDS_USER_ID=42420ENV SANDBOX_LOCAL_RUNTIME_URL=http://host.docker.internalENV USE_HOST_NETWORK=falseENV WORKSPACE_BASE=/opt/workspace_baseENV OPENHANDS_BUILD_VERSION=$OPENHANDS_BUILD_VERSIONENV SANDBOX_USER_ID=0ENV FILE_STORE=localENV FILE_STORE_PATH=/.openhands-stateRUN mkdir -p $FILE_STORE_PATHRUN mkdir -p $WORKSPACE_BASE
RUN apt-get update -y \ && apt-get install -y curl ssh sudo
# Default is 1000, but OSX is often 501RUN sed -i 's/^UID_MIN.*/UID_MIN 499/' /etc/login.defs# Default is 60000, but we've seen up to 200000RUN sed -i 's/^UID_MAX.*/UID_MAX 1000000/' /etc/login.defs
RUN groupadd appRUN useradd -l -m -u $OPENHANDS_USER_ID -s /bin/bash openhands && \ usermod -aG app openhands && \ usermod -aG sudo openhands && \ echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoersRUN chown -R openhands:app /app && chmod -R 770 /appRUN sudo chown -R openhands:app $WORKSPACE_BASE && sudo chmod -R 770 $WORKSPACE_BASEUSER openhands
ENV VIRTUAL_ENV=/app/.venv \ PATH="/app/.venv/bin:$PATH" \ PYTHONPATH='/app'
COPY --chown=openhands:app --chmod=770 --from=backend-builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}RUN playwright install --with-deps chromium
COPY --chown=openhands:app --chmod=770 ./microagents ./microagentsCOPY --chown=openhands:app --chmod=770 ./openhands ./openhandsCOPY --chown=openhands:app --chmod=777 ./openhands/runtime/plugins ./openhands/runtime/pluginsCOPY --chown=openhands:app --chmod=770 ./openhands/agenthub ./openhands/agenthubCOPY --chown=openhands:app ./pyproject.toml ./pyproject.tomlCOPY --chown=openhands:app ./poetry.lock ./poetry.lockCOPY --chown=openhands:app ./README.md ./README.mdCOPY --chown=openhands:app ./MANIFEST.in ./MANIFEST.inCOPY --chown=openhands:app ./LICENSE ./LICENSE
# This is run as "openhands" user, and will create __pycache__ with openhands:openhands ownershipRUN python openhands/core/download.py # No-op to download assets# Add this line to set group ownership of all files/directories not already in "app" group# openhands:openhands -> openhands:appRUN find /app \! -group app -exec chgrp app {} +
COPY --chown=openhands:app --chmod=770 --from=frontend-builder /app/build ./frontend/buildCOPY --chown=openhands:app --chmod=770 ./containers/app/entrypoint.sh /app/entrypoint.sh
USER root
WORKDIR /app
ENTRYPOINT ["/app/entrypoint.sh"]CMD ["uvicorn", "openhands.server.listen:app", "--host", "0.0.0.0", "--port", "3000"]1234DOCKER_REGISTRY=ghcr.ioDOCKER_ORG=all-hands-aiDOCKER_IMAGE=openhandsDOCKER_BASE_DIR="."123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869#!/bin/bashset -eo pipefail
echo "Starting OpenHands..."if [[ $NO_SETUP == "true" ]]; then echo "Skipping setup, running as $(whoami)" "$@" exit 0fi
if [ "$(id -u)" -ne 0 ]; then echo "The OpenHands entrypoint.sh must run as root" exit 1fi
if [ -z "$SANDBOX_USER_ID" ]; then echo "SANDBOX_USER_ID is not set" exit 1fi
if [ -z "$WORKSPACE_MOUNT_PATH" ]; then # This is set to /opt/workspace in the Dockerfile. But if the user isn't mounting, we want to unset it so that OpenHands doesn't mount at all unset WORKSPACE_BASEfi
if [[ "$SANDBOX_USER_ID" -eq 0 ]]; then echo "Running OpenHands as root" export RUN_AS_OPENHANDS=false mkdir -p /root/.cache/ms-playwright/ if [ -d "/home/openhands/.cache/ms-playwright/" ]; then mv /home/openhands/.cache/ms-playwright/ /root/.cache/ fi "$@"else echo "Setting up enduser with id $SANDBOX_USER_ID" if id "enduser" &>/dev/null; then echo "User enduser already exists. Skipping creation." else if ! useradd -l -m -u $SANDBOX_USER_ID -s /bin/bash enduser; then echo "Failed to create user enduser with id $SANDBOX_USER_ID. Moving openhands user." incremented_id=$(($SANDBOX_USER_ID + 1)) usermod -u $incremented_id openhands if ! useradd -l -m -u $SANDBOX_USER_ID -s /bin/bash enduser; then echo "Failed to create user enduser with id $SANDBOX_USER_ID for a second time. Exiting." exit 1 fi fi fi usermod -aG app enduser # get the user group of /var/run/docker.sock and set openhands to that group DOCKER_SOCKET_GID=$(stat -c '%g' /var/run/docker.sock) echo "Docker socket group id: $DOCKER_SOCKET_GID" if getent group $DOCKER_SOCKET_GID; then echo "Group with id $DOCKER_SOCKET_GID already exists" else echo "Creating group with id $DOCKER_SOCKET_GID" groupadd -g $DOCKER_SOCKET_GID docker fi
mkdir -p /home/enduser/.cache/huggingface/hub/ mkdir -p /home/enduser/.cache/ms-playwright/ if [ -d "/home/openhands/.cache/ms-playwright/" ]; then mv /home/openhands/.cache/ms-playwright/ /home/enduser/.cache/ fi
usermod -aG $DOCKER_SOCKET_GID enduser echo "Running as enduser" su enduser /bin/bash -c "${*@Q}" # This magically runs any arguments passed to the script as a commandfi123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156#!/usr/bin/env bashset -eo pipefail
# Initialize variables with default valuesimage_name=""org_name=""push=0load=0tag_suffix=""
# Function to display usage informationusage() { echo "Usage: $0 -i <image_name> [-o <org_name>] [--push] [--load] [-t <tag_suffix>]" echo " -i: Image name (required)" echo " -o: Organization name" echo " --push: Push the image" echo " --load: Load the image" echo " -t: Tag suffix" exit 1}
# Parse command-line optionswhile [[ $# -gt 0 ]]; do case $1 in -i) image_name="$2"; shift 2 ;; -o) org_name="$2"; shift 2 ;; --push) push=1; shift ;; --load) load=1; shift ;; -t) tag_suffix="$2"; shift 2 ;; *) usage ;; esacdone# Check if required arguments are providedif [[ -z "$image_name" ]]; then echo "Error: Image name is required." usagefi
echo "Building: $image_name"tags=()
OPENHANDS_BUILD_VERSION="dev"
cache_tag_base="buildcache"cache_tag="$cache_tag_base"
if [[ -n $RELEVANT_SHA ]]; then git_hash=$(git rev-parse --short "$RELEVANT_SHA") tags+=("$git_hash") tags+=("$RELEVANT_SHA")fi
if [[ -n $GITHUB_REF_NAME ]]; then # check if ref name is a version number if [[ $GITHUB_REF_NAME =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then major_version=$(echo "$GITHUB_REF_NAME" | cut -d. -f1) minor_version=$(echo "$GITHUB_REF_NAME" | cut -d. -f1,2) tags+=("$major_version" "$minor_version") tags+=("latest") fi sanitized_ref_name=$(echo "$GITHUB_REF_NAME" | sed 's/[^a-zA-Z0-9.-]\+/-/g') OPENHANDS_BUILD_VERSION=$sanitized_ref_name sanitized_ref_name=$(echo "$sanitized_ref_name" | tr '[:upper:]' '[:lower:]') # lower case is required in tagging tags+=("$sanitized_ref_name") cache_tag+="-${sanitized_ref_name}"fi
if [[ -n $tag_suffix ]]; then cache_tag+="-${tag_suffix}" for i in "${!tags[@]}"; do tags[$i]="${tags[$i]}-$tag_suffix" donefi
echo "Tags: ${tags[@]}"
if [[ "$image_name" == "openhands" ]]; then dir="./containers/app"elif [[ "$image_name" == "runtime" ]]; then dir="./containers/runtime"else dir="./containers/$image_name"fi
if [[ (! -f "$dir/Dockerfile") && "$image_name" != "runtime" ]]; then # Allow runtime to be built without a Dockerfile echo "No Dockerfile found" exit 1fiif [[ ! -f "$dir/config.sh" ]]; then echo "No config.sh found for Dockerfile" exit 1fi
source "$dir/config.sh"
if [[ -n "$org_name" ]]; then DOCKER_ORG="$org_name"fi
# If $DOCKER_IMAGE_SOURCE_TAG is set, add it to the tagsif [[ -n "$DOCKER_IMAGE_SOURCE_TAG" ]]; then tags+=("$DOCKER_IMAGE_SOURCE_TAG")fi# If $DOCKER_IMAGE_TAG is set, add it to the tagsif [[ -n "$DOCKER_IMAGE_TAG" ]]; then tags+=("$DOCKER_IMAGE_TAG")fi
DOCKER_REPOSITORY="$DOCKER_REGISTRY/$DOCKER_ORG/$DOCKER_IMAGE"DOCKER_REPOSITORY=${DOCKER_REPOSITORY,,} # lowercaseecho "Repo: $DOCKER_REPOSITORY"echo "Base dir: $DOCKER_BASE_DIR"
args=""for tag in "${tags[@]}"; do args+=" -t $DOCKER_REPOSITORY:$tag"done
if [[ $push -eq 1 ]]; then args+=" --push" args+=" --cache-to=type=registry,ref=$DOCKER_REPOSITORY:$cache_tag,mode=max"fi
if [[ $load -eq 1 ]]; then args+=" --load"fi
echo "Args: $args"
# Modify the platform selection based on --load flagif [[ $load -eq 1 ]]; then # When loading, build only for the current platform platform=$(docker version -f '{{.Server.Os}}/{{.Server.Arch}}')else # For push or without load, build for multiple platforms platform="linux/amd64,linux/arm64"fi
echo "Building for platform(s): $platform"
docker buildx build \ $args \ --build-arg OPENHANDS_BUILD_VERSION="$OPENHANDS_BUILD_VERSION" \ --cache-from=type=registry,ref=$DOCKER_REPOSITORY:$cache_tag \ --cache-from=type=registry,ref=$DOCKER_REPOSITORY:$cache_tag_base-main \ --platform $platform \ --provenance=false \ -f "$dir/Dockerfile" \ "$DOCKER_BASE_DIR"
# If load was requested, print the loaded imagesif [[ $load -eq 1 ]]; then echo "Local images built:" docker images "$DOCKER_REPOSITORY" --format "{{.Repository}}:{{.Tag}}"fi123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124# syntax=docker/dockerfile:1
###FROM ubuntu:22.04 AS dind
# https://docs.docker.com/engine/install/ubuntu/RUN apt-get update && apt-get install -y \ ca-certificates \ curl \ && install -m 0755 -d /etc/apt/keyrings \ && curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc \ && chmod a+r /etc/apt/keyrings/docker.asc \ && echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
RUN apt-get update && apt-get install -y \ docker-ce \ docker-ce-cli \ containerd.io \ docker-buildx-plugin \ docker-compose-plugin \ && rm -rf /var/lib/apt/lists/* \ && apt-get clean \ && apt-get autoremove -y
###FROM dind AS openhands
ENV DEBIAN_FRONTEND=noninteractive
#RUN apt-get update && apt-get install -y \ bash \ build-essential \ curl \ git \ git-lfs \ software-properties-common \ make \ netcat \ sudo \ wget \ && rm -rf /var/lib/apt/lists/* \ && apt-get clean \ && apt-get autoremove -y
# https://github.com/cli/cli/blob/trunk/docs/install_linux.mdRUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \ && chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \ && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \ && apt-get update && apt-get -y install \ gh \ && rm -rf /var/lib/apt/lists/* \ && apt-get clean \ && apt-get autoremove -y
# Python 3.12RUN add-apt-repository ppa:deadsnakes/ppa \ && apt-get update \ && apt-get install -y python3.12 python3.12-venv python3.12-dev python3-pip \ && ln -s /usr/bin/python3.12 /usr/bin/python
# NodeJS >= 18.17.1RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \ && apt-get install -y nodejs
# Poetry >= 1.8RUN curl -fsSL https://install.python-poetry.org | python3.12 - \ && ln -s ~/.local/bin/poetry /usr/local/bin/poetry
#RUN <<EOF#!/bin/bashprintf "#!/bin/bashset +xuname -adocker --versiongh --version | head -n 1git --version#python --versionecho node `node --version`echo npm `npm --version`poetry --versionnetcat -h 2>&1 | head -n 1" > /version.shchmod a+x /version.shEOF
###FROM openhands AS dev
RUN apt-get update && apt-get install -y \ dnsutils \ file \ iproute2 \ jq \ lsof \ ripgrep \ silversearcher-ag \ vim \ && rm -rf /var/lib/apt/lists/* \ && apt-get clean \ && apt-get autoremove -y
WORKDIR /app
# cache build dependenciesRUN \ --mount=type=bind,source=./,target=/app/ \ <<EOF#!/bin/bashmake -s cleanmake -s check-dependenciesmake -s install-python-dependencies
# NOTE# node_modules are .dockerignore-d therefore not mountable# make -s install-frontend-dependenciesEOF
#CMD ["bash"]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657# Develop in Docker
> [!WARNING]> This is not officially supported and may not work.
Install [Docker](https://docs.docker.com/engine/install/) on your host machine and run:
```bashmake docker-dev# same as:cd ./containers/dev./dev.sh```
It could take some time if you are running for the first time as Docker will pull all the tools required for building OpenHands. The next time you run again, it should be instant.
## Build and run
If everything goes well, you should be inside a container after Docker finishes building the `openhands:dev` image similar to the following:
```bashBuild and run in Docker ...root@93fc0005fcd2:/app#```
You may now proceed with the normal [build and run](../../Development.md) workflow as if you were on the host.
## Make changes
The source code on the host is mounted as `/app` inside docker. You may edit the files as usual either inside the Docker container or on your host with your favorite IDE/editors.
The following are also mapped as readonly from your host:
```yaml# host credentials- $HOME/.git-credentials:/root/.git-credentials:ro- $HOME/.gitconfig:/root/.gitconfig:ro- $HOME/.npmrc:/root/.npmrc:ro```
## VSCode
Alternatively, if you use VSCode, you could also [attach to the running container](https://code.visualstudio.com/docs/devcontainers/attach-container).
See details for [developing in docker](https://code.visualstudio.com/docs/devcontainers/containers) or simply ask `OpenHands` ;-)
## Rebuild dev image
You could optionally pass additional options to the build script.
```bashmake docker-dev OPTIONS="--build"# or./containers/dev/dev.sh --build```
See [docker compose run](https://docs.docker.com/reference/cli/docker/compose/run/) for more options.1234567891011121314151617181920212223242526272829303132333435363738#services: dev: privileged: true build: context: ${OPENHANDS_WORKSPACE:-../../} dockerfile: ./containers/dev/Dockerfile image: openhands:dev container_name: openhands-dev environment: - BACKEND_HOST=${BACKEND_HOST:-"0.0.0.0"} - SANDBOX_API_HOSTNAME=host.docker.internal # - SANDBOX_RUNTIME_CONTAINER_IMAGE=${SANDBOX_RUNTIME_CONTAINER_IMAGE:-ghcr.io/all-hands-ai/runtime:0.30-nikolaik} - SANDBOX_USER_ID=${SANDBOX_USER_ID:-1234} - WORKSPACE_MOUNT_PATH=${WORKSPACE_BASE:-$PWD/workspace} ports: - "3000:3000" extra_hosts: - "host.docker.internal:host-gateway" volumes: - /var/run/docker.sock:/var/run/docker.sock - ${WORKSPACE_BASE:-$PWD/workspace}:/opt/workspace_base # source code - ${OPENHANDS_WORKSPACE:-../../}:/app # host credentials - $HOME/.git-credentials:/root/.git-credentials:ro - $HOME/.gitconfig:/root/.gitconfig:ro - $HOME/.npmrc:/root/.npmrc:ro # cache - cache-data:/root/.cache pull_policy: never stdin_open: true tty: true
##volumes: cache-data:123456789101112131415161718192021222324252627282930313233343536373839#!/usr/bin/env bashset -o pipefail
function get_docker() { echo "Docker is required to build and run OpenHands." echo "https://docs.docker.com/get-started/get-docker/" exit 1}
function check_tools() { command -v docker &>/dev/null || get_docker}
function exit_if_indocker() { if [ -f /.dockerenv ]; then echo "Running inside a Docker container. Exiting..." exit 1 fi}
#exit_if_indocker
check_tools
##OPENHANDS_WORKSPACE=$(git rev-parse --show-toplevel)
cd "$OPENHANDS_WORKSPACE/containers/dev/" || exit 1
##export BACKEND_HOST="0.0.0.0"#export SANDBOX_USER_ID=$(id -u)export WORKSPACE_BASE=${WORKSPACE_BASE:-$OPENHANDS_WORKSPACE/workspace}
docker compose run --rm --service-ports "$@" dev
##12345678910111213141516171819FROM ubuntu:22.04
# install basic packagesRUN apt-get update && apt-get install -y \ curl \ wget \ git \ vim \ nano \ unzip \ zip \ python3 \ python3-pip \ python3-venv \ python3-dev \ build-essential \ openssh-server \ sudo \ && rm -rf /var/lib/apt/lists/*.dockerignoreAdded+5
.gitattributes+9-35
.github/.codecov.ymlAdded+19
.github/ISSUE_TEMPLATE/bug_template.ymlAdded+62
.github/ISSUE_TEMPLATE/feature_request.mdAdded+18
.github/ISSUE_TEMPLATE/technical_proposal.mdAdded+18
.github/dependabot.ymlAdded+71
.github/pull_request_template.mdAdded+12
.github/scripts/check_version_consistency.pyAdded+66
.github/workflows/clean-up.ymlAdded+69
.github/workflows/deploy-docs.ymlAdded+72
.github/workflows/dummy-agent-test.ymlAdded+53
.github/workflows/fe-unit-tests.ymlAdded+48
.github/workflows/ghcr-build.ymlAdded+402
.github/workflows/integration-runner.ymlAdded+199
.github/workflows/lint-fix.ymlAdded+91
.github/workflows/lint.ymlAdded+68
.github/workflows/openhands-resolver.ymlAdded+419
.github/workflows/py-unit-tests.ymlAdded+55
.github/workflows/pypi-release.ymlAdded+31
.github/workflows/run-eval.ymlAdded+53
.github/workflows/stale.ymlAdded+22
.gitignoreAdded+235
.nvmrcAdded+1
.openhands/microagents/glossary.mdAdded+172
.openhands/microagents/repo.mdAdded+48
.openhands/setup.shAdded+5
CITATION.cffAdded+55
CODE_OF_CONDUCT.mdAdded+147
COMMUNITY.mdAdded+43
CONTRIBUTING.mdAdded+123
CREDITS.mdAdded+312
Development.mdAdded+163
ISSUE_TRIAGE.mdAdded+32
LICENSEAdded+25
MANIFEST.inAdded+5
MakefileAdded+303
README.md+139-8
build.shAdded+4
config.template.tomlAdded+386
containers/README.mdAdded+12
containers/app/DockerfileAdded+98
containers/app/config.shAdded+4
containers/app/entrypoint.shAdded+69
containers/build.shAdded+156
containers/dev/DockerfileAdded+124
containers/dev/README.mdAdded+57
containers/dev/compose.ymlAdded+38
containers/dev/dev.shAdded+39
containers/e2b-sandbox/DockerfileAdded+19