<h1 align="center">
<a href="https://prompts.chat">
(in the `openhands` directory) and React frontend (in the `frontend` directory).
Sign in to like and favorite skills
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).
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.
To run the full application to debug issues:
export INSTALL_DOCKER=0 export RUNTIME=local make build && make run FRONTEND_PORT=12000 FRONTEND_HOST=0.0.0.0 BACKEND_HOST=0.0.0.0 &> /tmp/openhands-log.txt &
IMPORTANT: Before making any changes to the codebase, ALWAYS run
make install-pre-commit-hooks to ensure pre-commit hooks are properly installed.
Before pushing any changes, you MUST ensure that any lint errors or simple test errors have been fixed.
pre-commit run --config ./dev_config/python/.pre-commit-config.yaml (this will run on staged files).cd frontend && npm run lint:fix && npm run build ; cd ..cd openhands/integrations/vscode && npm run lint:fix && npm run compile ; cd ../../..The pre-commit hooks MUST pass successfully before pushing any changes to the repository. This is a mandatory requirement to maintain code quality and consistency.
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. Common issues include:
git add <filename> instead of git add . to avoid accidentally staging unintended filesgit reset --hard after staging files, as it will remove accidentally staged filesgit fetch upstream && git rebase upstream/<branch> on the same branchBackend:
openhands directorytests/unit/test_*.pypoetry run pytest tests/unit/test_xxx.py where xxx is the appropriate file for the current functionalityFrontend:
frontend directorynpm install in the frontend directorynpm run testnpm run test -- -t "TestName"npm run buildfrontend/.env or as environment variablesnpm run make-i18nfrontend/src/api and should never be called directly from UI components - they must always be wrapped with TanStack Queryfrontend/src/hooks/query/ and frontend/src/hooks/mutation/useConversationSkills)useDeleteConversation)frontend/src/api) → API endpointsVSCode Extension:
openhands/integrations/vscode directorynpm install in the extension directorynpm run lint:fixnpm run lintnpm run typechecknpm run compilenpm run package-vsixnpm run testvscode.window.createOutputChannel() for debug logging instead of showErrorMessage() popupsThe
enterprise/ directory contains additional functionality that extends the open-source OpenHands codebase. This includes:
Prerequisites:
Setup Steps:
make buildcd enterprise && poetry install --with dev,test (This can take a very long time. Be patient.)poetry run pre-commit install --config ./dev_config/python/.pre-commit-config.yamlRunning Enterprise Tests:
# Enterprise unit tests (full suite) PYTHONPATH=".:$PYTHONPATH" poetry run --project=enterprise pytest --forked -n auto -s -p no:ddtrace -p no:ddtrace.pytest_bdd -p no:ddtrace.pytest_benchmark ./enterprise/tests/unit --cov=enterprise --cov-branch # Test specific modules (faster for development) cd enterprise PYTHONPATH=".:$PYTHONPATH" poetry run pytest tests/unit/telemetry/ --confcutdir=tests/unit/telemetry # Enterprise linting (IMPORTANT: use --show-diff-on-failure to match GitHub CI) poetry run pre-commit run --all-files --show-diff-on-failure --config ./dev_config/python/.pre-commit-config.yaml
Running Enterprise Server:
cd enterprise make start-backend # Development mode with hot reload # or make run # Full application (backend + frontend)
Key Configuration Files:
enterprise/pyproject.toml - Enterprise-specific dependenciesenterprise/Makefile - Enterprise build and run commandsenterprise/dev_config/python/ - Linting and type checking configurationenterprise/migrations/ - Database migration filesDatabase Migrations: Enterprise uses Alembic for database migrations. When making schema changes:
enterprise/migrations/versions/Integration Development: The enterprise codebase includes integrations for:
Each integration follows a consistent pattern with service classes, storage models, and API endpoints.
Important Notes:
enterprise/migrations/Enterprise Testing Best Practices:
Database Testing:
sqlite:///:memory:) for unit tests instead of real PostgreSQLconftest.py files with database fixturesImport Patterns:
enterprise. prefix in enterprise codefrom storage.database import session_maker not from enterprise.storage.database import session_makerTest Structure:
enterprise/tests/unit/ following the same structure as the source code--confcutdir=tests/unit/[module] when testing specific modulesMocking Strategy:
AsyncMock for async operations and MagicMock for complex objectspatch with correct import paths (e.g., telemetry.registry.logger not enterprise.telemetry.registry.logger)Coverage Goals:
--cov-report=term-missing to identify uncovered linesTroubleshooting:
poetry install --with dev,testmake buildlogs/ directory for runtime issuesPYTHONPATH=".:$PYTHONPATH" is set--show-diff-on-failure flag to match CI behavior exactlyIf you are starting a pull request (PR), please follow the template in
.github/pull_request_template.md.
These details may or may not be useful for your current task.
Microagents are specialized prompts that enhance OpenHands with domain-specific knowledge and task-specific workflows. They are Markdown files that can include frontmatter for configuration.
microagents/, available to all users.openhands/microagents/, specific to this repository--- triggers: - keyword1 - keyword2 --- # Microagent Content Your specialized knowledge and instructions here...
frontend/src/types/action-type.tsHANDLED_ACTIONS array in frontend/src/state/chat-slice.ts determines which actions are displayed as collapsible UI elementsHANDLED_ACTIONS arrayaddAssistantAction function in chat-slice.tsACTION_MESSAGE$ACTION_NAME to the i18n filesthought property are displayed in the UI based on their action type:
Settings type in frontend/src/types/settings.tsApiSettings type in the same fileDEFAULT_SETTINGS in frontend/src/services/settings.tsuseSettings hook in frontend/src/hooks/query/use-settings.ts to map the API responseuseSaveSettings hook in frontend/src/hooks/mutation/use-save-settings.ts to include the setting in API requestsfrontend/src/routes/app-settings.tsx)frontend/src/i18n/translation.jsonfrontend/src/i18n/declaration.tsSettings model in openhands/storage/data_models/settings.pyThere are two main patterns for saving settings in the OpenHands frontend:
Pattern 1: Entity-based Resources (Immediate Save)
isDirty trackinguse-add-mcp-server.ts, use-delete-mcp-server.ts)Pattern 2: Form-based Settings (Manual Save)
isDirty trackinguseSaveSettings hook to save all changes at onceWhen to use each pattern:
To add a new LLM model to OpenHands, you need to update multiple files across both frontend and backend:
Frontend Model Arrays (
frontend/src/utils/verified-models.ts):
VERIFIED_MODELS array (main list of all verified models)VERIFIED_OPENAI_MODELS for OpenAI modelsVERIFIED_ANTHROPIC_MODELS for Anthropic modelsVERIFIED_MISTRAL_MODELS for Mistral modelsVERIFIED_OPENHANDS_MODELS for models available through OpenHands providerBackend CLI Integration (
openhands/cli/utils.py):
VERIFIED_*_MODELS arraysBackend Model List (
openhands/utils/llm.py):
openhands_models list (lines 57-66) if using OpenHands provider'openhands/model-name' (e.g., 'openhands/o3')Backend LLM Configuration (
openhands/llm/llm.py):
FUNCTION_CALLING_SUPPORTED_MODELS if the model supports function callingREASONING_EFFORT_SUPPORTED_MODELS if the model supports reasoning effort parametersCACHE_PROMPT_SUPPORTED_MODELS if the model supports prompt cachingMODELS_WITHOUT_STOP_WORDS if the model doesn't support stop wordsValidation:
pre-commit run --config ./dev_config/python/.pre-commit-config.yamlcd frontend && npm run lint:fixcd frontend && npm run buildextractModelAndProvider utility automatically detects provider from model arraysorganize_models_and_providers function groups models by provider