Bladeren bron

[Resolver]: Support custom sandbox (#5348)

Rohit Malhotra 1 jaar geleden
bovenliggende
commit
64a7fef57e

+ 6 - 0
.github/workflows/openhands-resolver.yml

@@ -16,6 +16,11 @@ on:
         type: string
         default: "main"
         description: "Target branch to pull and create PR against"
+      base_container_image:
+        required: false
+        type: string
+        default: ""
+        description: "Custom sandbox env"
     secrets:
       LLM_MODEL:
         required: true
@@ -139,6 +144,7 @@ jobs:
 
           echo "MAX_ITERATIONS=${{ inputs.max_iterations || 50 }}" >> $GITHUB_ENV
           echo "SANDBOX_ENV_GITHUB_TOKEN=${{ secrets.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 }}" >> $GITHUB_ENV

+ 13 - 4
docs/modules/usage/how-to/github-action.md

@@ -37,12 +37,15 @@ the [README for the OpenHands Resolver](https://github.com/All-Hands-AI/OpenHand
 
 You can provide custom directions for OpenHands by following the [README for the resolver](https://github.com/All-Hands-AI/OpenHands/blob/main/openhands/resolver/README.md#providing-custom-instructions).
 
-### Configure custom macro
+### Custom configurations
 
-To customize the default macro (`@openhands-agent`):
+Github resolver will automatically check for valid [repository secrets](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions?tool=webui#creating-secrets-for-a-repository) or [repository variables](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#creating-configuration-variables-for-a-repository) to customize its behavior. The customization options you can set are:
 
-1. [Create a repository variable](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#creating-configuration-variables-for-a-repository) named `OPENHANDS_MACRO`
-2. Assign the variable a custom value
+| **Attribute name**               | **Type** | **Purpose**                                                                                         | **Example**                                     |
+| -------------------------------- | -------- | --------------------------------------------------------------------------------------------------- | ----------------------------------------------- |
+| `OPENHANDS_MAX_ITER`             | Variable | Set max limit for agent iterations                                                                  | `OPENHANDS_MAX_ITER=10`                         |
+| `OPENHANDS_MACRO`                | Variable | Customize default macro for invoking the resolver                                                   | `OPENHANDS_MACRO=@resolveit`                    |
+| `OPENHANDS_BASE_CONTAINER_IMAGE` | Variable | Custom Sandbox ([learn more](https://docs.all-hands.dev/modules/usage/how-to/custom-sandbox-guide)) | `OPENHANDS_BASE_CONTAINER_IMAGE="custom_image"` |
 
 ## Writing Effective .openhands_instructions Files
 
@@ -55,6 +58,7 @@ The `.openhands_instructions` file is a file that you can put in the root direct
 2. **Repository Structure**: Explain the key directories and their purposes, especially highlighting where different types of code (e.g., frontend, backend) are located.
 
 3. **Development Workflows**: Document the essential commands for:
+
    - Building and setting up the project
    - Running tests
    - Linting and code quality checks
@@ -69,24 +73,29 @@ The `.openhands_instructions` file is a file that you can put in the root direct
 
 ```markdown
 # Repository Overview
+
 [Brief description of the project]
 
 ## General Setup
+
 - Main build command
 - Development environment setup
 - Pre-commit checks
 
 ## Backend
+
 - Location and structure
 - Testing instructions
 - Environment requirements
 
 ## Frontend
+
 - Setup prerequisites
 - Build and test commands
 - Environment variables
 
 ## Additional Guidelines
+
 - Code style requirements
 - Special considerations
 - Common workflows

+ 1 - 0
openhands/resolver/examples/openhands-resolver.yml

@@ -23,6 +23,7 @@ jobs:
     with:
       macro: ${{ vars.OPENHANDS_MACRO || '@openhands-agent' }}
       max_iterations: ${{ fromJson(vars.OPENHANDS_MAX_ITER || 50) }}
+      base_container_image: ${{ vars.OPENHANDS_BASE_CONTAINER_IMAGE || "" }}
     secrets:
       PAT_TOKEN: ${{ secrets.PAT_TOKEN }}
       PAT_USERNAME: ${{ secrets.PAT_USERNAME }}