mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
* finish is working * start reworking main_goal * remove main_goal from microagents * remove main_goal from other agents * fix issues * revert codeact line * make plan a subclass of task * fix frontend for new plan setup * lint * fix type * more lint * fix build issues * fix codeact mgs * fix edge case in regen script * fix task validation errors * regenerate integration tests * fix up tests * fix sweagent * revert codeact prompt * update integration tests * update integration tests * handle loading state * Update agenthub/codeact_agent/codeact_agent.py Co-authored-by: Engel Nyst <enyst@users.noreply.github.com> * Update opendevin/controller/agent_controller.py Co-authored-by: Engel Nyst <enyst@users.noreply.github.com> * Update agenthub/codeact_agent/codeact_agent.py Co-authored-by: Engel Nyst <enyst@users.noreply.github.com> * Update opendevin/controller/state/plan.py Co-authored-by: Engel Nyst <enyst@users.noreply.github.com> * update docs * regenerate tests * remove none from state type * revert test files * update integration tests * rename plan to root_task * revert plugin perms * regen integration tests * tweak integration script * prettier * fix test * set workspace up for regeneration * regenerate tests * Change directory of copy * Updated tests * Disable PlannerAgent test * Fix listen * Updated prompts * Disable planner again * Make codecov more lenient * Update agenthub/README.md * Update opendevin/server/README.md * re-enable planner tests * finish top level tasks * regen planner * fix root task factory --------- Co-authored-by: Engel Nyst <enyst@users.noreply.github.com> Co-authored-by: Xingyao Wang <xingyao6@illinois.edu> Co-authored-by: Graham Neubig <neubig@gmail.com> Co-authored-by: Boxuan Li <liboxuan@connect.hku.hk>
76 lines
2.6 KiB
Python
76 lines
2.6 KiB
Python
import json
|
|
import os
|
|
from unittest.mock import MagicMock
|
|
|
|
import yaml
|
|
|
|
from agenthub.micro.registry import all_microagents
|
|
from opendevin.controller.agent import Agent
|
|
from opendevin.controller.state.state import State
|
|
from opendevin.events.action import MessageAction
|
|
from opendevin.events.observation import NullObservation
|
|
|
|
|
|
def test_all_agents_are_loaded():
|
|
full_path = os.path.join('agenthub', 'micro')
|
|
agent_names = set()
|
|
for root, _, files in os.walk(full_path):
|
|
for file in files:
|
|
if file == 'agent.yaml':
|
|
file_path = os.path.join(root, file)
|
|
with open(file_path, 'r') as yaml_file:
|
|
data = yaml.safe_load(yaml_file)
|
|
agent_names.add(data['name'])
|
|
assert agent_names == set(all_microagents.keys())
|
|
|
|
|
|
def test_coder_agent_with_summary():
|
|
"""
|
|
Coder agent should render code summary as part of prompt
|
|
"""
|
|
mock_llm = MagicMock()
|
|
content = json.dumps({'action': 'finish', 'args': {}})
|
|
mock_llm.completion.return_value = {'choices': [{'message': {'content': content}}]}
|
|
|
|
coder_agent = Agent.get_cls('CoderAgent')(llm=mock_llm)
|
|
assert coder_agent is not None
|
|
|
|
task = 'This is a dummy task'
|
|
history = [(MessageAction(content=task), NullObservation(''))]
|
|
history[0][0]._source = 'user'
|
|
summary = 'This is a dummy summary about this repo'
|
|
state = State(history=history, inputs={'summary': summary})
|
|
coder_agent.step(state)
|
|
|
|
mock_llm.completion.assert_called_once()
|
|
_, kwargs = mock_llm.completion.call_args
|
|
prompt = kwargs['messages'][0]['content']
|
|
assert task in prompt
|
|
assert "Here's a summary of the codebase, as it relates to this task" in prompt
|
|
assert summary in prompt
|
|
|
|
|
|
def test_coder_agent_without_summary():
|
|
"""
|
|
When there's no codebase_summary available, there shouldn't be any prompt
|
|
about 'code summary'
|
|
"""
|
|
mock_llm = MagicMock()
|
|
content = json.dumps({'action': 'finish', 'args': {}})
|
|
mock_llm.completion.return_value = {'choices': [{'message': {'content': content}}]}
|
|
|
|
coder_agent = Agent.get_cls('CoderAgent')(llm=mock_llm)
|
|
assert coder_agent is not None
|
|
|
|
task = 'This is a dummy task'
|
|
history = [(MessageAction(content=task), NullObservation(''))]
|
|
history[0][0]._source = 'user'
|
|
state = State(history=history)
|
|
coder_agent.step(state)
|
|
|
|
mock_llm.completion.assert_called_once()
|
|
_, kwargs = mock_llm.completion.call_args
|
|
prompt = kwargs['messages'][0]['content']
|
|
assert task in prompt
|
|
assert "Here's a summary of the codebase, as it relates to this task" not in prompt
|