Compare commits

...

1 Commits

Author SHA1 Message Date
openhands
4979baa590 Fix issue #5830: Test openhands instructions 2024-12-26 18:35:20 +00:00
4 changed files with 36 additions and 12 deletions

View File

@@ -180,7 +180,29 @@ python -m openhands.resolver.send_pull_request --issue-number ISSUE_NUMBER --git
## Providing Custom Instructions
You can customize how the AI agent approaches issue resolution by adding a `.openhands_instructions` file to the root of your repository. If present, this file's contents will be injected into the prompt for openhands edits.
You can customize how the AI agent approaches issue resolution by adding repository instructions in `.openhands/microagents/repo.md` file. This file should contain repository-specific information and guidelines that will be injected into the prompt for OpenHands edits.
Example structure for `.openhands/microagents/repo.md`:
```markdown
---
name: repo
agent: CodeActAgent
---
# Repository Instructions
This repository contains [brief description of your project].
## Directory Structure
- src/: [description]
- tests/: [description]
...
## Development Guidelines
[Your specific coding standards and practices]
## Testing Requirements
[How to run tests and what types of tests are required]
```
## Troubleshooting

View File

@@ -123,10 +123,10 @@ async def resolve_issues(
logger.info(f'Base commit: {base_commit}')
if repo_instruction is None:
# Check for .openhands_instructions file in the workspace directory
openhands_instructions_path = os.path.join(repo_dir, '.openhands_instructions')
if os.path.exists(openhands_instructions_path):
with open(openhands_instructions_path, 'r') as f:
# Check for repository instructions in .openhands/microagents/repo.md
repo_instructions_path = os.path.join(repo_dir, '.openhands/microagents/repo.md')
if os.path.exists(repo_instructions_path):
with open(repo_instructions_path, 'r') as f:
repo_instruction = f.read()
# OUTPUT FILE

View File

@@ -402,10 +402,10 @@ async def resolve_issue(
logger.info(f'Base commit: {base_commit}')
if repo_instruction is None:
# Check for .openhands_instructions file in the workspace directory
openhands_instructions_path = os.path.join(repo_dir, '.openhands_instructions')
if os.path.exists(openhands_instructions_path):
with open(openhands_instructions_path, 'r') as f:
# Check for repository instructions in .openhands/microagents/repo.md
repo_instructions_path = os.path.join(repo_dir, '.openhands/microagents/repo.md')
if os.path.exists(repo_instructions_path):
with open(repo_instructions_path, 'r') as f:
repo_instruction = f.read()
# OUTPUT FILE

View File

@@ -225,13 +225,15 @@ class Runtime(FileEditRuntimeMixin):
dir_name = str(
Path(selected_repository.split('/')[1]) / custom_microagents_dir
)
# Legacy support for .openhands_instructions
obs = self.read(FileReadAction(path='.openhands_instructions'))
if isinstance(obs, ErrorObservation):
self.log('debug', 'openhands_instructions not present')
else:
if not isinstance(obs, ErrorObservation):
self.log('info', 'Found legacy .openhands_instructions file')
openhands_instructions = obs.content
self.log('info', f'openhands_instructions: {openhands_instructions}')
custom_microagents_content.append(openhands_instructions)
else:
self.log('debug', '.openhands_instructions not present')
files = self.list_files(dir_name)