Skip to content

Commit e28b3ef

Browse files
authored
Fix integration tests (All-Hands-AI#1764)
* refactor remind_iterations * regenerate tests * concatenate iteration message * add some helpers to the tests * regenerate tests * add to logs * regenerate tests * add debug info * fix exit_on_message * fix regen script * regenerate tests * Revert "Merge branch 'rb/test-regen' of ssh://github.com/opendevin/opendevin into rb/test-regen" This reverts commit b9cd1ac, reversing changes made to c888285. * remove prints * revert files * revert more * revert more * regenerate for the last time I hope * add back remind_iter * regenerate * add back remind_iter * regenerate * fix remind_iter * regenerate yet again * regen * remove comment * regen again
1 parent ee66a1d commit e28b3ef

34 files changed

+410
-1947
lines changed

opendevin/core/main.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def read_task_from_stdin() -> str:
2525
return sys.stdin.read()
2626

2727

28-
async def main(task_str: str = '') -> None:
28+
async def main(task_str: str = '', exit_on_message: bool = False) -> None:
2929
"""
3030
Main coroutine to run the agent controller with task input flexibility.
3131
It's only used when you launch opendevin backend directly via cmdline.
@@ -84,8 +84,10 @@ async def main(task_str: str = '') -> None:
8484
async def on_event(event: Event):
8585
if isinstance(event, AgentStateChangedObservation):
8686
if event.agent_state == AgentState.AWAITING_USER_INPUT:
87-
message = input('Request user input >> ')
88-
action = MessageAction(content=message)
87+
action = MessageAction(content='/exit')
88+
if not exit_on_message:
89+
message = input('Request user input >> ')
90+
action = MessageAction(content=message)
8991
await event_stream.add_event(action, EventSource.USER)
9092

9193
event_stream.subscribe(EventStreamSubscriber.MAIN, on_event)

opendevin/server/agent/agent.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ async def on_event(self, event: Event):
134134
Args:
135135
event: The agent event (Observation or Action).
136136
"""
137-
if event.source == 'agent' and not isinstance(event, (NullAction, NullObservation)):
137+
if event.source == 'agent' and not isinstance(
138+
event, (NullAction, NullObservation)
139+
):
138140
await self.send(event.to_dict())
139141
return
140142

tests/integration/conftest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ def mock_completion(*args, test_name, **kwargs):
7979
for message in messages:
8080
message_str += message['content']
8181
mock_response = get_mock_response(test_name, message_str)
82-
assert mock_response is not None, 'Mock response for prompt is not found'
82+
assert mock_response is not None, (
83+
'Mock response for prompt is not found:\n\n' + message_str
84+
)
8385
response = completion(**kwargs, mock_response=mock_response)
8486
return response
8587

tests/integration/mock/CodeActAgent/test_edits/prompt_002.log

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,19 +220,18 @@ Fix typos in bad.txt. Do not ask me for confirmation at any point.
220220

221221
----------
222222

223-
Let's start by opening the file `bad.txt` to see what's inside and identify the typos.
224-
223+
Sure! Let's first take a look at the content of the file `bad.txt` to identify the typos that need to be fixed. Let me display the content of the file:
225224
<execute_bash>
226-
open bad.txt
225+
cat bad.txt
227226
</execute_bash>
228227

229228
----------
230229

231230
OBSERVATION:
232-
[File: /workspace/bad.txt (4 lines total)]
233-
1:This is a stupid typoo.
234-
2:Really?
235-
3:No mor typos!
236-
4:Enjoy!
231+
This is a stupid typoo.
232+
Really?
233+
No mor typos!
234+
Enjoy!
235+
237236
ENVIRONMENT REMINDER: You have 9 turns left to complete the task.
238237
[Command -1 finished with exit code 0]]

tests/integration/mock/CodeActAgent/test_edits/prompt_003.log

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -220,61 +220,37 @@ Fix typos in bad.txt. Do not ask me for confirmation at any point.
220220

221221
----------
222222

223-
Let's start by opening the file `bad.txt` to see what's inside and identify the typos.
224-
223+
Sure! Let's first take a look at the content of the file `bad.txt` to identify the typos that need to be fixed. Let me display the content of the file:
225224
<execute_bash>
226-
open bad.txt
225+
cat bad.txt
227226
</execute_bash>
228227

229228
----------
230229

231230
OBSERVATION:
232-
[File: /workspace/bad.txt (4 lines total)]
233-
1:This is a stupid typoo.
234-
2:Really?
235-
3:No mor typos!
236-
4:Enjoy!
231+
This is a stupid typoo.
232+
Really?
233+
No mor typos!
234+
Enjoy!
235+
237236
ENVIRONMENT REMINDER: You have 9 turns left to complete the task.
238237
[Command -1 finished with exit code 0]]
239238

240239
----------
241240

242-
I see a few typos in the file `bad.txt`. Let's correct them:
243-
244-
1. "typoo" should be "typo".
245-
2. "mor" should be "more".
246-
247-
I will now edit the file to fix these typos.
248-
241+
I see the typos that need to be fixed in the file `bad.txt`. Let's correct them without asking for confirmation. Let me open the file for editing:
249242
<execute_bash>
250-
edit 1:1
251-
This is a stupid typo.
252-
end_of_edit
253-
edit 3:3
254-
No more typos!
255-
end_of_edit
243+
open bad.txt
256244
</execute_bash>
257245

258246
----------
259247

260248
OBSERVATION:
261-
> This is a stupid typo.
262-
> EOF
263-
[File: /workspace/bad.txt (4 lines total)]
264-
1:This is a stupid typo.
265-
2:Really?
266-
3:No mor typos!
249+
[File: /workspace/bad.txt (4 lines total)]
250+
1:This is a stupid typoo.
251+
2:Really?
252+
3:No mor typos!
267253
4:Enjoy!
268-
File updated. Please review the changes and make sure they are correct (correct indentation, no duplicate lines, etc). Edit the file again if necessary.edit 3:3 <<EOF
269-
> No more typos!
270-
> EOF
271254

272-
273-
[File: /workspace/bad.txt (4 lines total)]
274-
1:This is a stupid typo.
275-
2:Really?
276-
3:No more typos!
277-
4:Enjoy!
278-
File updated. Please review the changes and make sure they are correct (correct indentation, no duplicate lines, etc). Edit the file again if necessary.
279255
ENVIRONMENT REMINDER: You have 8 turns left to complete the task.
280256
[Command -1 finished with exit code 0]]

0 commit comments

Comments
 (0)