Skip to content

Commit

Permalink
Make SWE Bench specific instructions conditional based on environment…
Browse files Browse the repository at this point in the history
… variable

1. Added SWE_BENCH_RUN environment variable in run_infer.py
2. Modified codeact_agent.py to only show SWE Bench specific instructions when SWE_BENCH_RUN is true
  • Loading branch information
AlexCuadron committed Nov 7, 2024
1 parent b05b47f commit aaba2d4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
3 changes: 3 additions & 0 deletions evaluation/swe_bench/run_infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import tempfile
from typing import Any

# Set environment variable to indicate SWE Bench context
os.environ['SWE_BENCH_RUN'] = 'true'

import pandas as pd
import toml
from datasets import load_dataset
Expand Down
16 changes: 11 additions & 5 deletions openhands/agenthub/codeact_agent/codeact_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,12 +513,18 @@ def _get_messages(self, state: State) -> list[Message]:
'\n\nENVIRONMENT REMINDER:\n'
f'- You have {state.max_iterations - state.iteration} turns left to complete the task\n'
'- When finished reply with <finish></finish>\n'
'\n<IMPORTANT>\n'
'- You MUST generate only one action per turn!\n'
'- A patch is a set of changes to the source code of the codebase that you are given\n'
'- You MUST generate a patch that attempts to fix the issue described in the <pr_description>\n'
'</IMPORTANT>\n'
)

# Add SWE Bench specific instructions only when running in that context
if os.environ.get('SWE_BENCH_RUN', 'false').lower() == 'true':
reminder_text += (
'\n<IMPORTANT>\n'
'- You MUST generate only one action per turn!\n'
'- A patch is a set of changes to the source code of the codebase that you are given\n'
'- You MUST generate a patch that attempts to fix the issue described in the <pr_description>\n'
'</IMPORTANT>\n'
)

latest_user_message.content.append(TextContent(text=reminder_text))

return messages

0 comments on commit aaba2d4

Please sign in to comment.