mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
refactor: multiple code improvements (#2771)
This commit is contained in:
parent
869997b941
commit
c2f557edde
@ -77,7 +77,7 @@ git push origin my_branch
|
||||
|
||||
### 6. Open a Pull Request
|
||||
|
||||
* On Github, go to the page of your forked repository, and create a Pull Request:
|
||||
* On GitHub, go to the page of your forked repository, and create a Pull Request:
|
||||
- Click on `Branches`
|
||||
- Click on the `...` beside your branch and click on `New pull request`
|
||||
- Set `base repository` to `OpenDevin/OpenDevin`
|
||||
@ -96,7 +96,7 @@ As described [here](https://github.com/commitizen/conventional-commit-types/blob
|
||||
- `feat`: A new feature
|
||||
- `fix`: A bug fix
|
||||
- `docs`: Documentation only changes
|
||||
- `style`: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc)
|
||||
- `style`: Changes that do not affect the meaning of the code (white space, formatting, missing semicolons, etc.)
|
||||
- `refactor`: A code change that neither fixes a bug nor adds a feature
|
||||
- `perf`: A code change that improves performance
|
||||
- `test`: Adding missing tests or correcting existing tests
|
||||
|
||||
12
Makefile
12
Makefile
@ -9,7 +9,7 @@ FRONTEND_PORT = 3001
|
||||
DEFAULT_WORKSPACE_DIR = "./workspace"
|
||||
DEFAULT_MODEL = "gpt-4o"
|
||||
CONFIG_FILE = config.toml
|
||||
PRECOMMIT_CONFIG_PATH = "./dev_config/python/.pre-commit-config.yaml"
|
||||
PRE_COMMIT_CONFIG_PATH = "./dev_config/python/.pre-commit-config.yaml"
|
||||
PYTHON_VERSION = 3.11
|
||||
|
||||
# ANSI color codes
|
||||
@ -28,7 +28,7 @@ ifeq ($(INSTALL_DOCKER),)
|
||||
endif
|
||||
@$(MAKE) -s install-python-dependencies
|
||||
@$(MAKE) -s install-frontend-dependencies
|
||||
@$(MAKE) -s install-precommit-hooks
|
||||
@$(MAKE) -s install-pre-commit-hooks
|
||||
@$(MAKE) -s build-frontend
|
||||
@echo "$(GREEN)Build completed successfully.$(RESET)"
|
||||
|
||||
@ -169,15 +169,15 @@ install-frontend-dependencies:
|
||||
npm run make-i18n
|
||||
@echo "$(GREEN)Frontend dependencies installed successfully.$(RESET)"
|
||||
|
||||
install-precommit-hooks:
|
||||
install-pre-commit-hooks:
|
||||
@echo "$(YELLOW)Installing pre-commit hooks...$(RESET)"
|
||||
@git config --unset-all core.hooksPath || true
|
||||
@poetry run pre-commit install --config $(PRECOMMIT_CONFIG_PATH)
|
||||
@poetry run pre-commit install --config $(PRE_COMMIT_CONFIG_PATH)
|
||||
@echo "$(GREEN)Pre-commit hooks installed successfully.$(RESET)"
|
||||
|
||||
lint-backend:
|
||||
@echo "$(YELLOW)Running linters...$(RESET)"
|
||||
@poetry run pre-commit run --files opendevin/**/* agenthub/**/* evaluation/**/* --show-diff-on-failure --config $(PRECOMMIT_CONFIG_PATH)
|
||||
@poetry run pre-commit run --files opendevin/**/* agenthub/**/* evaluation/**/* --show-diff-on-failure --config $(PRE_COMMIT_CONFIG_PATH)
|
||||
|
||||
lint-frontend:
|
||||
@echo "$(YELLOW)Running linters for frontend...$(RESET)"
|
||||
@ -319,4 +319,4 @@ help:
|
||||
@echo " $(GREEN)help$(RESET) - Display this help message, providing information on available targets."
|
||||
|
||||
# Phony targets
|
||||
.PHONY: build check-dependencies check-python check-npm check-docker check-poetry pull-docker-image install-python-dependencies install-frontend-dependencies install-precommit-hooks lint start-backend start-frontend run run-wsl setup-config setup-config-prompts help
|
||||
.PHONY: build check-dependencies check-python check-npm check-docker check-poetry pull-docker-image install-python-dependencies install-frontend-dependencies install-pre-commit-hooks lint start-backend start-frontend run run-wsl setup-config setup-config-prompts help
|
||||
|
||||
@ -9,10 +9,9 @@ from opendevin.events.action import (
|
||||
|
||||
|
||||
class BrowsingResponseParser(ResponseParser):
|
||||
def __init__(
|
||||
self,
|
||||
):
|
||||
def __init__(self):
|
||||
# Need to pay attention to the item order in self.action_parsers
|
||||
super().__init__()
|
||||
self.action_parsers = [BrowsingActionParserMessage()]
|
||||
self.default_parser = BrowsingActionParserBrowseInteractive()
|
||||
|
||||
|
||||
@ -21,10 +21,9 @@ class CodeActResponseParser(ResponseParser):
|
||||
- AgentFinishAction() - end the interaction
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
):
|
||||
def __init__(self):
|
||||
# Need pay attention to the item order in self.action_parsers
|
||||
super().__init__()
|
||||
self.action_parsers = [
|
||||
CodeActActionParserFinish(),
|
||||
CodeActActionParserCmdRun(),
|
||||
@ -33,7 +32,7 @@ class CodeActResponseParser(ResponseParser):
|
||||
]
|
||||
self.default_parser = CodeActActionParserMessage()
|
||||
|
||||
def parse(self, response: str) -> Action:
|
||||
def parse(self, response) -> Action:
|
||||
action_str = self.parse_response(response)
|
||||
return self.parse_action(action_str)
|
||||
|
||||
|
||||
@ -136,8 +136,8 @@ class CodeActAgent(Agent):
|
||||
|
||||
sandbox_plugins: list[PluginRequirement] = [
|
||||
# NOTE: AgentSkillsRequirement need to go before JupyterRequirement, since
|
||||
# AgentSkillsRequirement provides a lot of Python functions
|
||||
# and it need to be initialized before Jupyter for Jupyter to use those functions.
|
||||
# AgentSkillsRequirement provides a lot of Python functions,
|
||||
# and it needs to be initialized before Jupyter for Jupyter to use those functions.
|
||||
AgentSkillsRequirement(),
|
||||
JupyterRequirement(),
|
||||
]
|
||||
|
||||
@ -2,6 +2,6 @@
|
||||
|
||||
This agent is an adaptation of the original [SWE Agent](https://swe-agent.com/) based on CodeAct using the `agentskills` library of OpenDevin.
|
||||
|
||||
Its intended use is **solving Github issues**.
|
||||
Its intended use is **solving GitHub issues**.
|
||||
|
||||
It removes web-browsing and Github capability from the original CodeAct agent to avoid confusion to the agent.
|
||||
It removes web-browsing and GitHub capability from the original CodeAct agent to avoid confusion to the agent.
|
||||
|
||||
@ -93,8 +93,8 @@ class CodeActSWEAgent(Agent):
|
||||
|
||||
sandbox_plugins: list[PluginRequirement] = [
|
||||
# NOTE: AgentSkillsRequirement need to go before JupyterRequirement, since
|
||||
# AgentSkillsRequirement provides a lot of Python functions
|
||||
# and it need to be initialized before Jupyter for Jupyter to use those functions.
|
||||
# AgentSkillsRequirement provides a lot of Python functions,
|
||||
# and it needs to be initialized before Jupyter for Jupyter to use those functions.
|
||||
AgentSkillsRequirement(),
|
||||
JupyterRequirement(),
|
||||
]
|
||||
|
||||
@ -17,10 +17,9 @@ class CodeActSWEResponseParser(ResponseParser):
|
||||
- AgentFinishAction() - end the interaction
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
):
|
||||
def __init__(self):
|
||||
# Need pay attention to the item order in self.action_parsers
|
||||
super().__init__()
|
||||
self.action_parsers = [
|
||||
CodeActSWEActionParserFinish(),
|
||||
CodeActSWEActionParserCmdRun(),
|
||||
|
||||
@ -7,10 +7,8 @@ from opendevin.events.serialization.action import action_from_dict
|
||||
|
||||
|
||||
class MonologueResponseParser(ResponseParser):
|
||||
def __init__(
|
||||
self,
|
||||
):
|
||||
pass
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
def parse(self, response: str) -> Action:
|
||||
action_str = self.parse_response(response)
|
||||
|
||||
@ -57,7 +57,7 @@ class ResponseParser(ABC):
|
||||
|
||||
class ActionParser(ABC):
|
||||
"""
|
||||
This abstract base class is an general interface for an action parser dedicated to
|
||||
This abstract base class is a general interface for an action parser dedicated to
|
||||
parsing the action from the action str from the LLM.
|
||||
"""
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ import traceback
|
||||
from typing import Optional, Type
|
||||
|
||||
from opendevin.controller.agent import Agent
|
||||
from opendevin.controller.state.state import TRAFFIC_CONTROL_STATE, State
|
||||
from opendevin.controller.state.state import State, TrafficControlState
|
||||
from opendevin.core.config import config
|
||||
from opendevin.core.exceptions import (
|
||||
LLMMalformedActionError,
|
||||
@ -108,7 +108,6 @@ class AgentController:
|
||||
self.state.iteration += 1
|
||||
|
||||
async def update_state_after_step(self):
|
||||
self.state.updated_info = []
|
||||
# update metrics especially for cost
|
||||
self.state.metrics = self.agent.llm.metrics
|
||||
|
||||
@ -129,7 +128,6 @@ class AgentController:
|
||||
if isinstance(action, NullAction) and isinstance(observation, NullObservation):
|
||||
return
|
||||
self.state.history.append((action, observation))
|
||||
self.state.updated_info.append((action, observation))
|
||||
|
||||
async def _start_step_loop(self):
|
||||
logger.info(f'[Agent Controller {self.id}] Starting step loop...')
|
||||
@ -204,10 +202,10 @@ class AgentController:
|
||||
if (
|
||||
self.state.agent_state == AgentState.PAUSED
|
||||
and new_state == AgentState.RUNNING
|
||||
and self.state.traffic_control_state == TRAFFIC_CONTROL_STATE.THROTTLING
|
||||
and self.state.traffic_control_state == TrafficControlState.THROTTLING
|
||||
):
|
||||
# user intends to interrupt traffic control and let the task resume temporarily
|
||||
self.state.traffic_control_state = TRAFFIC_CONTROL_STATE.PAUSED
|
||||
self.state.traffic_control_state = TrafficControlState.PAUSED
|
||||
|
||||
self.state.agent_state = new_state
|
||||
if new_state == AgentState.STOPPED or new_state == AgentState.ERROR:
|
||||
@ -312,13 +310,13 @@ class AgentController:
|
||||
)
|
||||
|
||||
if self.state.iteration >= self.state.max_iterations:
|
||||
if self.state.traffic_control_state == TRAFFIC_CONTROL_STATE.PAUSED:
|
||||
if self.state.traffic_control_state == TrafficControlState.PAUSED:
|
||||
logger.info(
|
||||
'Hitting traffic control, temporarily resume upon user request'
|
||||
)
|
||||
self.state.traffic_control_state = TRAFFIC_CONTROL_STATE.NORMAL
|
||||
self.state.traffic_control_state = TrafficControlState.NORMAL
|
||||
else:
|
||||
self.state.traffic_control_state = TRAFFIC_CONTROL_STATE.THROTTLING
|
||||
self.state.traffic_control_state = TrafficControlState.THROTTLING
|
||||
await self.report_error(
|
||||
f'Agent reached maximum number of iterations, task paused. {TRAFFIC_CONTROL_REMINDER}'
|
||||
)
|
||||
@ -327,13 +325,13 @@ class AgentController:
|
||||
elif self.max_budget_per_task is not None:
|
||||
current_cost = self.state.metrics.accumulated_cost
|
||||
if current_cost > self.max_budget_per_task:
|
||||
if self.state.traffic_control_state == TRAFFIC_CONTROL_STATE.PAUSED:
|
||||
if self.state.traffic_control_state == TrafficControlState.PAUSED:
|
||||
logger.info(
|
||||
'Hitting traffic control, temporarily resume upon user request'
|
||||
)
|
||||
self.state.traffic_control_state = TRAFFIC_CONTROL_STATE.NORMAL
|
||||
self.state.traffic_control_state = TrafficControlState.NORMAL
|
||||
else:
|
||||
self.state.traffic_control_state = TRAFFIC_CONTROL_STATE.THROTTLING
|
||||
self.state.traffic_control_state = TrafficControlState.THROTTLING
|
||||
await self.report_error(
|
||||
f'Task budget exceeded. Current cost: {current_cost:.2f}, Max budget: {self.max_budget_per_task:.2f}, task paused. {TRAFFIC_CONTROL_REMINDER}'
|
||||
)
|
||||
|
||||
@ -18,7 +18,7 @@ from opendevin.events.observation import (
|
||||
from opendevin.storage import get_file_store
|
||||
|
||||
|
||||
class TRAFFIC_CONTROL_STATE(str, Enum):
|
||||
class TrafficControlState(str, Enum):
|
||||
# default state, no rate limiting
|
||||
NORMAL = 'normal'
|
||||
|
||||
@ -44,13 +44,12 @@ class State:
|
||||
max_iterations: int = 100
|
||||
background_commands_obs: list[CmdOutputObservation] = field(default_factory=list)
|
||||
history: list[tuple[Action, Observation]] = field(default_factory=list)
|
||||
updated_info: list[tuple[Action, Observation]] = field(default_factory=list)
|
||||
inputs: dict = field(default_factory=dict)
|
||||
outputs: dict = field(default_factory=dict)
|
||||
last_error: str | None = None
|
||||
agent_state: AgentState = AgentState.LOADING
|
||||
resume_state: AgentState | None = None
|
||||
traffic_control_state: TRAFFIC_CONTROL_STATE = TRAFFIC_CONTROL_STATE.NORMAL
|
||||
traffic_control_state: TrafficControlState = TrafficControlState.NORMAL
|
||||
metrics: Metrics = Metrics()
|
||||
# root agent has level 0, and every delegate increases the level by one
|
||||
delegate_level: int = 0
|
||||
|
||||
@ -29,7 +29,7 @@ class Task:
|
||||
parent: 'Task',
|
||||
goal: str,
|
||||
state: str = OPEN_STATE,
|
||||
subtasks: list = [], # noqa: B006
|
||||
subtasks=None, # noqa: B006
|
||||
):
|
||||
"""Initializes a new instance of the Task class.
|
||||
|
||||
@ -39,6 +39,8 @@ class Task:
|
||||
state: The initial state of the task.
|
||||
subtasks: A list of subtasks associated with this task.
|
||||
"""
|
||||
if subtasks is None:
|
||||
subtasks = []
|
||||
if parent.id:
|
||||
self.id = parent.id + '.' + str(len(parent.subtasks))
|
||||
else:
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
class Metrics:
|
||||
"""
|
||||
Metrics class can record various metrics during running and evaluation.
|
||||
Currently we define the following metrics:
|
||||
Currently, we define the following metrics:
|
||||
accumulated_cost: the total cost (USD $) of the current LLM.
|
||||
"""
|
||||
|
||||
|
||||
@ -13,29 +13,29 @@ class Event:
|
||||
@property
|
||||
def message(self) -> str | None:
|
||||
if hasattr(self, '_message'):
|
||||
return self._message # type: ignore [attr-defined]
|
||||
return self._message # type: ignore[attr-defined]
|
||||
return ''
|
||||
|
||||
@property
|
||||
def id(self) -> int | None:
|
||||
if hasattr(self, '_id'):
|
||||
return self._id # type: ignore [attr-defined]
|
||||
return self._id # type: ignore[attr-defined]
|
||||
return -1
|
||||
|
||||
@property
|
||||
def timestamp(self) -> datetime.datetime | None:
|
||||
if hasattr(self, '_timestamp'):
|
||||
return self._timestamp # type: ignore [attr-defined]
|
||||
return self._timestamp # type: ignore[attr-defined]
|
||||
return None
|
||||
|
||||
@property
|
||||
def source(self) -> EventSource | None:
|
||||
if hasattr(self, '_source'):
|
||||
return self._source # type: ignore [attr-defined]
|
||||
return self._source # type: ignore[attr-defined]
|
||||
return None
|
||||
|
||||
@property
|
||||
def cause(self) -> int | None:
|
||||
if hasattr(self, '_cause'):
|
||||
return self._cause # type: ignore [attr-defined]
|
||||
return self._cause # type: ignore[attr-defined]
|
||||
return None
|
||||
|
||||
@ -97,10 +97,10 @@ class EventStream:
|
||||
async def add_event(self, event: Event, source: EventSource):
|
||||
logger.debug(f'Adding event {event} from {source}')
|
||||
async with self._lock:
|
||||
event._id = self._cur_id # type: ignore [attr-defined]
|
||||
event._id = self._cur_id # type: ignore[attr-defined]
|
||||
self._cur_id += 1
|
||||
event._timestamp = datetime.now() # type: ignore [attr-defined]
|
||||
event._source = source # type: ignore [attr-defined]
|
||||
event._timestamp = datetime.now() # type: ignore[attr-defined]
|
||||
event._source = source # type: ignore[attr-defined]
|
||||
data = event_to_dict(event)
|
||||
if event.id is not None:
|
||||
self._file_store.write(
|
||||
|
||||
@ -177,7 +177,7 @@ class LLM:
|
||||
f'{retry_state.outcome.exception()}. Attempt #{retry_state.attempt_number} | You can customize these settings in the configuration.',
|
||||
exc_info=False,
|
||||
)
|
||||
return True
|
||||
return None
|
||||
|
||||
@retry(
|
||||
reraise=True,
|
||||
@ -276,7 +276,7 @@ class LLM:
|
||||
Add the current cost into total cost in metrics.
|
||||
|
||||
Args:
|
||||
response (list): A response from a model invocation.
|
||||
response: A response from a model invocation.
|
||||
|
||||
Returns:
|
||||
number: The cost of the response.
|
||||
|
||||
@ -39,7 +39,7 @@ def attempt_on_error(retry_state):
|
||||
f'{retry_state.outcome.exception()}. Attempt #{retry_state.attempt_number} | You can customize these settings in the configuration.',
|
||||
exc_info=False,
|
||||
)
|
||||
return True
|
||||
return None
|
||||
|
||||
|
||||
@retry(
|
||||
|
||||
@ -5,7 +5,7 @@ This folder implements a skill/tool set `agentskills` for OpenDevin.
|
||||
It is intended to be used by the agent **inside sandbox**.
|
||||
The skill set will be exposed as a `pip` package that can be installed as a plugin inside the sandbox.
|
||||
|
||||
The skill set can contains a bunch of wrapped tools for agent ([many examples here](https://github.com/OpenDevin/OpenDevin/pull/1914)), for example:
|
||||
The skill set can contain a bunch of wrapped tools for agent ([many examples here](https://github.com/OpenDevin/OpenDevin/pull/1914)), for example:
|
||||
- Audio/Video to text (these are a temporary solution, and we should switch to multimodal models when they are sufficiently cheap
|
||||
- PDF to text
|
||||
- etc.
|
||||
|
||||
@ -10,7 +10,7 @@ class AgentSkillsRequirement(PluginRequirement):
|
||||
name: str = 'agent_skills'
|
||||
host_src: str = os.path.dirname(
|
||||
os.path.abspath(__file__)
|
||||
) # The directory of this file (opendevin/runtime/plugins/jupyter)
|
||||
) # The directory of this file (opendevin/runtime/plugins/agent_skills)
|
||||
sandbox_dest: str = '/opendevin/plugins/agent_skills'
|
||||
bash_script_path: str = 'setup.sh'
|
||||
documentation: str = DOCUMENTATION
|
||||
|
||||
@ -167,7 +167,7 @@ def _lint_file(file_path: str) -> tuple[Optional[str], Optional[int]]:
|
||||
return None, None
|
||||
|
||||
|
||||
def _print_window(file_path, targeted_line, WINDOW, return_str=False):
|
||||
def _print_window(file_path, targeted_line, window, return_str=False):
|
||||
global CURRENT_LINE
|
||||
_check_current_file(file_path)
|
||||
with open(file_path) as file:
|
||||
@ -182,7 +182,7 @@ def _print_window(file_path, targeted_line, WINDOW, return_str=False):
|
||||
|
||||
# cover edge cases
|
||||
CURRENT_LINE = _clamp(targeted_line, 1, total_lines)
|
||||
half_window = max(1, WINDOW // 2)
|
||||
half_window = max(1, window // 2)
|
||||
|
||||
# Ensure at least one line above and below the targeted line
|
||||
start = max(1, CURRENT_LINE - half_window)
|
||||
@ -190,9 +190,9 @@ def _print_window(file_path, targeted_line, WINDOW, return_str=False):
|
||||
|
||||
# Adjust start and end to ensure at least one line above and below
|
||||
if start == 1:
|
||||
end = min(total_lines, start + WINDOW - 1)
|
||||
end = min(total_lines, start + window - 1)
|
||||
if end == total_lines:
|
||||
start = max(1, end - WINDOW + 1)
|
||||
start = max(1, end - window + 1)
|
||||
|
||||
output = ''
|
||||
|
||||
@ -214,10 +214,10 @@ def _print_window(file_path, targeted_line, WINDOW, return_str=False):
|
||||
print(output)
|
||||
|
||||
|
||||
def _cur_file_header(CURRENT_FILE, total_lines) -> str:
|
||||
if not CURRENT_FILE:
|
||||
def _cur_file_header(current_file, total_lines) -> str:
|
||||
if not current_file:
|
||||
return ''
|
||||
return f'[File: {os.path.abspath(CURRENT_FILE)} ({total_lines} lines total)]\n'
|
||||
return f'[File: {os.path.abspath(current_file)} ({total_lines} lines total)]\n'
|
||||
|
||||
|
||||
@update_pwd_decorator
|
||||
@ -230,7 +230,7 @@ def open_file(
|
||||
to view the file if you want to see more.
|
||||
|
||||
Args:
|
||||
path: str: The path to the file to open, preferredly absolute path.
|
||||
path: str: The path to the file to open, preferred absolute path.
|
||||
line_number: int | None = 1: The line number to move to. Defaults to 1.
|
||||
context_lines: int | None = 100: Only shows this number of lines in the context window (usually from line 1), with line_number as the center (if possible). Defaults to 100.
|
||||
"""
|
||||
|
||||
@ -44,6 +44,10 @@ class PluginMixin:
|
||||
|
||||
# clean-up ~/.bashrc and touch ~/.bashrc
|
||||
exit_code, output = self.execute('rm -f ~/.bashrc && touch ~/.bashrc')
|
||||
if exit_code != 0:
|
||||
logger.warning(
|
||||
f'Failed to clean-up ~/.bashrc with exit code {exit_code} and output: {output}'
|
||||
)
|
||||
|
||||
for requirement in requirements:
|
||||
# source bashrc file when plugin loads
|
||||
|
||||
@ -253,7 +253,6 @@ async def websocket_endpoint(websocket: WebSocket):
|
||||
"""
|
||||
await websocket.accept()
|
||||
|
||||
session = None
|
||||
if websocket.query_params.get('token'):
|
||||
token = websocket.query_params.get('token')
|
||||
sid = get_sid_from_token(token)
|
||||
|
||||
@ -3,4 +3,4 @@ from .session import Session
|
||||
|
||||
session_manager = SessionManager()
|
||||
|
||||
__all__ = ['Session', 'SessionManager', 'session_manager', 'message_stack']
|
||||
__all__ = ['Session', 'SessionManager', 'session_manager']
|
||||
|
||||
@ -75,7 +75,7 @@ class AgentSession:
|
||||
"""Creates an AgentController instance.
|
||||
|
||||
Args:
|
||||
start_event: The start event data (optional).
|
||||
start_event: The start event data.
|
||||
"""
|
||||
if self.controller is not None:
|
||||
raise Exception('Controller already created')
|
||||
|
||||
@ -51,7 +51,7 @@ of agents with real LLMs are stored under `mock/AgentName/TestName` folders.
|
||||
|
||||
## Run Integration Tests
|
||||
|
||||
Take a look at `run-integration-tests.yml` (in the `.github` folder) to learn
|
||||
Take a look at `ghcr.yml` (in the `.github/workflow` folder) to learn
|
||||
how integration tests are launched in a CI environment. You can also simply run:
|
||||
|
||||
```bash
|
||||
|
||||
@ -70,7 +70,7 @@ def get_mock_response(test_name: str, messages: str, id: int) -> str:
|
||||
folders under mock folder. If prompt_{id}.log matches,
|
||||
then the mock response we're looking for is at response_{id}.log.
|
||||
|
||||
Note: we filter out all non alpha-numerical characters, otherwise we would
|
||||
Note: we filter out all non-alphanumerical characters, otherwise we would
|
||||
see surprising mismatches caused by linters and minor discrepancies between
|
||||
different platforms.
|
||||
|
||||
@ -81,7 +81,6 @@ def get_mock_response(test_name: str, messages: str, id: int) -> str:
|
||||
we start from the end of the file, but again, that is unnecessary and only
|
||||
makes test code harder to understand.
|
||||
"""
|
||||
mock_dir = os.path.join(script_dir, 'mock', os.environ.get('AGENT'), test_name)
|
||||
prompt = filter_out_symbols(messages)
|
||||
mock_dir = os.path.join(script_dir, 'mock', os.environ.get('AGENT'), test_name)
|
||||
prompt_file_path = os.path.join(mock_dir, f'prompt_{"{0:03}".format(id)}.log')
|
||||
|
||||
@ -30,7 +30,7 @@ open_file(path: str, line_number: int | None = 1, context_lines: int | None = 10
|
||||
It only shows the first 100 lines by default! Max `context_lines` supported is 2000, use `scroll up/down`
|
||||
to view the file if you want to see more.
|
||||
Args:
|
||||
path: str: The path to the file to open, preferredly absolute path.
|
||||
path: str: The path to the file to open, preferred absolute path.
|
||||
line_number: int | None = 1: The line number to move to. Defaults to 1.
|
||||
context_lines: int | None = 100: Only shows this number of lines in the context window (usually from line 1), with line_number as the center (if possible). Defaults to 100.
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ open_file(path: str, line_number: int | None = 1, context_lines: int | None = 10
|
||||
It only shows the first 100 lines by default! Max `context_lines` supported is 2000, use `scroll up/down`
|
||||
to view the file if you want to see more.
|
||||
Args:
|
||||
path: str: The path to the file to open, preferredly absolute path.
|
||||
path: str: The path to the file to open, preferred absolute path.
|
||||
line_number: int | None = 1: The line number to move to. Defaults to 1.
|
||||
context_lines: int | None = 100: Only shows this number of lines in the context window (usually from line 1), with line_number as the center (if possible). Defaults to 100.
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ open_file(path: str, line_number: int | None = 1, context_lines: int | None = 10
|
||||
It only shows the first 100 lines by default! Max `context_lines` supported is 2000, use `scroll up/down`
|
||||
to view the file if you want to see more.
|
||||
Args:
|
||||
path: str: The path to the file to open, preferredly absolute path.
|
||||
path: str: The path to the file to open, preferred absolute path.
|
||||
line_number: int | None = 1: The line number to move to. Defaults to 1.
|
||||
context_lines: int | None = 100: Only shows this number of lines in the context window (usually from line 1), with line_number as the center (if possible). Defaults to 100.
|
||||
|
||||
@ -386,4 +386,4 @@ NOW, LET'S START!
|
||||
|
||||
Fix typos in bad.txt. Do not ask me for confirmation at any point.
|
||||
|
||||
ENVIRONMENT REMINDER: You have 9 turns left to complete the task.
|
||||
ENVIRONMENT REMINDER: You have 9 turns left to complete the task.
|
||||
@ -30,7 +30,7 @@ open_file(path: str, line_number: int | None = 1, context_lines: int | None = 10
|
||||
It only shows the first 100 lines by default! Max `context_lines` supported is 2000, use `scroll up/down`
|
||||
to view the file if you want to see more.
|
||||
Args:
|
||||
path: str: The path to the file to open, preferredly absolute path.
|
||||
path: str: The path to the file to open, preferred absolute path.
|
||||
line_number: int | None = 1: The line number to move to. Defaults to 1.
|
||||
context_lines: int | None = 100: Only shows this number of lines in the context window (usually from line 1), with line_number as the center (if possible). Defaults to 100.
|
||||
|
||||
@ -403,4 +403,4 @@ OBSERVATION:
|
||||
4|Enjoy!
|
||||
|
||||
|
||||
ENVIRONMENT REMINDER: You have 8 turns left to complete the task.
|
||||
ENVIRONMENT REMINDER: You have 8 turns left to complete the task.
|
||||
@ -30,7 +30,7 @@ open_file(path: str, line_number: int | None = 1, context_lines: int | None = 10
|
||||
It only shows the first 100 lines by default! Max `context_lines` supported is 2000, use `scroll up/down`
|
||||
to view the file if you want to see more.
|
||||
Args:
|
||||
path: str: The path to the file to open, preferredly absolute path.
|
||||
path: str: The path to the file to open, preferred absolute path.
|
||||
line_number: int | None = 1: The line number to move to. Defaults to 1.
|
||||
context_lines: int | None = 100: Only shows this number of lines in the context window (usually from line 1), with line_number as the center (if possible). Defaults to 100.
|
||||
|
||||
@ -425,4 +425,4 @@ OBSERVATION:
|
||||
[File updated. Please review the changes and make sure they are correct (correct indentation, no duplicate lines, etc). Edit the file again if necessary.]
|
||||
|
||||
|
||||
ENVIRONMENT REMINDER: You have 7 turns left to complete the task.
|
||||
ENVIRONMENT REMINDER: You have 7 turns left to complete the task.
|
||||
@ -30,7 +30,7 @@ open_file(path: str, line_number: int | None = 1, context_lines: int | None = 10
|
||||
It only shows the first 100 lines by default! Max `context_lines` supported is 2000, use `scroll up/down`
|
||||
to view the file if you want to see more.
|
||||
Args:
|
||||
path: str: The path to the file to open, preferredly absolute path.
|
||||
path: str: The path to the file to open, preferred absolute path.
|
||||
line_number: int | None = 1: The line number to move to. Defaults to 1.
|
||||
context_lines: int | None = 100: Only shows this number of lines in the context window (usually from line 1), with line_number as the center (if possible). Defaults to 100.
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ open_file(path: str, line_number: int | None = 1, context_lines: int | None = 10
|
||||
It only shows the first 100 lines by default! Max `context_lines` supported is 2000, use `scroll up/down`
|
||||
to view the file if you want to see more.
|
||||
Args:
|
||||
path: str: The path to the file to open, preferredly absolute path.
|
||||
path: str: The path to the file to open, preferred absolute path.
|
||||
line_number: int | None = 1: The line number to move to. Defaults to 1.
|
||||
context_lines: int | None = 100: Only shows this number of lines in the context window (usually from line 1), with line_number as the center (if possible). Defaults to 100.
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ open_file(path: str, line_number: int | None = 1, context_lines: int | None = 10
|
||||
It only shows the first 100 lines by default! Max `context_lines` supported is 2000, use `scroll up/down`
|
||||
to view the file if you want to see more.
|
||||
Args:
|
||||
path: str: The path to the file to open, preferredly absolute path.
|
||||
path: str: The path to the file to open, preferred absolute path.
|
||||
line_number: int | None = 1: The line number to move to. Defaults to 1.
|
||||
context_lines: int | None = 100: Only shows this number of lines in the context window (usually from line 1), with line_number as the center (if possible). Defaults to 100.
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ open_file(path: str, line_number: int | None = 1, context_lines: int | None = 10
|
||||
It only shows the first 100 lines by default! Max `context_lines` supported is 2000, use `scroll up/down`
|
||||
to view the file if you want to see more.
|
||||
Args:
|
||||
path: str: The path to the file to open, preferredly absolute path.
|
||||
path: str: The path to the file to open, preferred absolute path.
|
||||
line_number: int | None = 1: The line number to move to. Defaults to 1.
|
||||
context_lines: int | None = 100: Only shows this number of lines in the context window (usually from line 1), with line_number as the center (if possible). Defaults to 100.
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ open_file(path: str, line_number: int | None = 1, context_lines: int | None = 10
|
||||
It only shows the first 100 lines by default! Max `context_lines` supported is 2000, use `scroll up/down`
|
||||
to view the file if you want to see more.
|
||||
Args:
|
||||
path: str: The path to the file to open, preferredly absolute path.
|
||||
path: str: The path to the file to open, preferred absolute path.
|
||||
line_number: int | None = 1: The line number to move to. Defaults to 1.
|
||||
context_lines: int | None = 100: Only shows this number of lines in the context window (usually from line 1), with line_number as the center (if possible). Defaults to 100.
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ open_file(path: str, line_number: int | None = 1, context_lines: int | None = 10
|
||||
It only shows the first 100 lines by default! Max `context_lines` supported is 2000, use `scroll up/down`
|
||||
to view the file if you want to see more.
|
||||
Args:
|
||||
path: str: The path to the file to open, preferredly absolute path.
|
||||
path: str: The path to the file to open, preferred absolute path.
|
||||
line_number: int | None = 1: The line number to move to. Defaults to 1.
|
||||
context_lines: int | None = 100: Only shows this number of lines in the context window (usually from line 1), with line_number as the center (if possible). Defaults to 100.
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ open_file(path: str, line_number: int | None = 1, context_lines: int | None = 10
|
||||
It only shows the first 100 lines by default! Max `context_lines` supported is 2000, use `scroll up/down`
|
||||
to view the file if you want to see more.
|
||||
Args:
|
||||
path: str: The path to the file to open, preferredly absolute path.
|
||||
path: str: The path to the file to open, preferred absolute path.
|
||||
line_number: int | None = 1: The line number to move to. Defaults to 1.
|
||||
context_lines: int | None = 100: Only shows this number of lines in the context window (usually from line 1), with line_number as the center (if possible). Defaults to 100.
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ open_file(path: str, line_number: int | None = 1, context_lines: int | None = 10
|
||||
It only shows the first 100 lines by default! Max `context_lines` supported is 2000, use `scroll up/down`
|
||||
to view the file if you want to see more.
|
||||
Args:
|
||||
path: str: The path to the file to open, preferredly absolute path.
|
||||
path: str: The path to the file to open, preferred absolute path.
|
||||
line_number: int | None = 1: The line number to move to. Defaults to 1.
|
||||
context_lines: int | None = 100: Only shows this number of lines in the context window (usually from line 1), with line_number as the center (if possible). Defaults to 100.
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ open_file(path: str, line_number: int | None = 1, context_lines: int | None = 10
|
||||
It only shows the first 100 lines by default! Max `context_lines` supported is 2000, use `scroll up/down`
|
||||
to view the file if you want to see more.
|
||||
Args:
|
||||
path: str: The path to the file to open, preferredly absolute path.
|
||||
path: str: The path to the file to open, preferred absolute path.
|
||||
line_number: int | None = 1: The line number to move to. Defaults to 1.
|
||||
context_lines: int | None = 100: Only shows this number of lines in the context window (usually from line 1), with line_number as the center (if possible). Defaults to 100.
|
||||
|
||||
@ -594,11 +594,11 @@ open_file('bad.txt')
|
||||
----------
|
||||
|
||||
OBSERVATION:
|
||||
[File: /workspace/bad.txt (4 lines total)]
|
||||
1|This is a stupid typoo.
|
||||
2|Really?
|
||||
3|No mor typos!
|
||||
4|Enjoy!
|
||||
[File: /workspace/bad.txt (4 lines total)]
|
||||
1|This is a stupid typoo.
|
||||
2|Really?
|
||||
3|No mor typos!
|
||||
4|Enjoy!
|
||||
|
||||
|
||||
ENVIRONMENT REMINDER: You have 8 turns left to complete the task.
|
||||
|
||||
@ -18,7 +18,7 @@ open_file(path: str, line_number: int | None = 1, context_lines: int | None = 10
|
||||
It only shows the first 100 lines by default! Max `context_lines` supported is 2000, use `scroll up/down`
|
||||
to view the file if you want to see more.
|
||||
Args:
|
||||
path: str: The path to the file to open, preferredly absolute path.
|
||||
path: str: The path to the file to open, preferred absolute path.
|
||||
line_number: int | None = 1: The line number to move to. Defaults to 1.
|
||||
context_lines: int | None = 100: Only shows this number of lines in the context window (usually from line 1), with line_number as the center (if possible). Defaults to 100.
|
||||
|
||||
@ -594,11 +594,11 @@ open_file('bad.txt')
|
||||
----------
|
||||
|
||||
OBSERVATION:
|
||||
[File: /workspace/bad.txt (4 lines total)]
|
||||
1|This is a stupid typoo.
|
||||
2|Really?
|
||||
3|No mor typos!
|
||||
4|Enjoy!
|
||||
[File: /workspace/bad.txt (4 lines total)]
|
||||
1|This is a stupid typoo.
|
||||
2|Really?
|
||||
3|No mor typos!
|
||||
4|Enjoy!
|
||||
|
||||
|
||||
----------
|
||||
@ -617,18 +617,18 @@ edit_file('bad.txt', 'No mor typos!', 'No more typos!')
|
||||
----------
|
||||
|
||||
OBSERVATION:
|
||||
[File: /workspace/bad.txt (4 lines total after edit)]
|
||||
1|This is a stupid typo.
|
||||
2|Really?
|
||||
3|No mor typos!
|
||||
4|Enjoy!
|
||||
[File updated. Please review the changes and make sure they are correct (correct indentation, no duplicate lines, etc). Edit the file again if necessary.]
|
||||
[File: /workspace/bad.txt (4 lines total after edit)]
|
||||
1|This is a stupid typo.
|
||||
2|Really?
|
||||
3|No more typos!
|
||||
4|Enjoy!
|
||||
[File updated. Please review the changes and make sure they are correct (correct indentation, no duplicate lines, etc). Edit the file again if necessary.]
|
||||
[File: /workspace/bad.txt (4 lines total after edit)]
|
||||
1|This is a stupid typo.
|
||||
2|Really?
|
||||
3|No mor typos!
|
||||
4|Enjoy!
|
||||
[File updated. Please review the changes and make sure they are correct (correct indentation, no duplicate lines, etc). Edit the file again if necessary.]
|
||||
[File: /workspace/bad.txt (4 lines total after edit)]
|
||||
1|This is a stupid typo.
|
||||
2|Really?
|
||||
3|No more typos!
|
||||
4|Enjoy!
|
||||
[File updated. Please review the changes and make sure they are correct (correct indentation, no duplicate lines, etc). Edit the file again if necessary.]
|
||||
|
||||
|
||||
ENVIRONMENT REMINDER: You have 7 turns left to complete the task.
|
||||
|
||||
@ -18,7 +18,7 @@ open_file(path: str, line_number: int | None = 1, context_lines: int | None = 10
|
||||
It only shows the first 100 lines by default! Max `context_lines` supported is 2000, use `scroll up/down`
|
||||
to view the file if you want to see more.
|
||||
Args:
|
||||
path: str: The path to the file to open, preferredly absolute path.
|
||||
path: str: The path to the file to open, preferred absolute path.
|
||||
line_number: int | None = 1: The line number to move to. Defaults to 1.
|
||||
context_lines: int | None = 100: Only shows this number of lines in the context window (usually from line 1), with line_number as the center (if possible). Defaults to 100.
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ open_file(path: str, line_number: int | None = 1, context_lines: int | None = 10
|
||||
It only shows the first 100 lines by default! Max `context_lines` supported is 2000, use `scroll up/down`
|
||||
to view the file if you want to see more.
|
||||
Args:
|
||||
path: str: The path to the file to open, preferredly absolute path.
|
||||
path: str: The path to the file to open, preferred absolute path.
|
||||
line_number: int | None = 1: The line number to move to. Defaults to 1.
|
||||
context_lines: int | None = 100: Only shows this number of lines in the context window (usually from line 1), with line_number as the center (if possible). Defaults to 100.
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ open_file(path: str, line_number: int | None = 1, context_lines: int | None = 10
|
||||
It only shows the first 100 lines by default! Max `context_lines` supported is 2000, use `scroll up/down`
|
||||
to view the file if you want to see more.
|
||||
Args:
|
||||
path: str: The path to the file to open, preferredly absolute path.
|
||||
path: str: The path to the file to open, preferred absolute path.
|
||||
line_number: int | None = 1: The line number to move to. Defaults to 1.
|
||||
context_lines: int | None = 100: Only shows this number of lines in the context window (usually from line 1), with line_number as the center (if possible). Defaults to 100.
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ open_file(path: str, line_number: int | None = 1, context_lines: int | None = 10
|
||||
It only shows the first 100 lines by default! Max `context_lines` supported is 2000, use `scroll up/down`
|
||||
to view the file if you want to see more.
|
||||
Args:
|
||||
path: str: The path to the file to open, preferredly absolute path.
|
||||
path: str: The path to the file to open, preferred absolute path.
|
||||
line_number: int | None = 1: The line number to move to. Defaults to 1.
|
||||
context_lines: int | None = 100: Only shows this number of lines in the context window (usually from line 1), with line_number as the center (if possible). Defaults to 100.
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ open_file(path: str, line_number: int | None = 1, context_lines: int | None = 10
|
||||
It only shows the first 100 lines by default! Max `context_lines` supported is 2000, use `scroll up/down`
|
||||
to view the file if you want to see more.
|
||||
Args:
|
||||
path: str: The path to the file to open, preferredly absolute path.
|
||||
path: str: The path to the file to open, preferred absolute path.
|
||||
line_number: int | None = 1: The line number to move to. Defaults to 1.
|
||||
context_lines: int | None = 100: Only shows this number of lines in the context window (usually from line 1), with line_number as the center (if possible). Defaults to 100.
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ open_file(path: str, line_number: int | None = 1, context_lines: int | None = 10
|
||||
It only shows the first 100 lines by default! Max `context_lines` supported is 2000, use `scroll up/down`
|
||||
to view the file if you want to see more.
|
||||
Args:
|
||||
path: str: The path to the file to open, preferredly absolute path.
|
||||
path: str: The path to the file to open, preferred absolute path.
|
||||
line_number: int | None = 1: The line number to move to. Defaults to 1.
|
||||
context_lines: int | None = 100: Only shows this number of lines in the context window (usually from line 1), with line_number as the center (if possible). Defaults to 100.
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ open_file(path: str, line_number: int | None = 1, context_lines: int | None = 10
|
||||
It only shows the first 100 lines by default! Max `context_lines` supported is 2000, use `scroll up/down`
|
||||
to view the file if you want to see more.
|
||||
Args:
|
||||
path: str: The path to the file to open, preferredly absolute path.
|
||||
path: str: The path to the file to open, preferred absolute path.
|
||||
line_number: int | None = 1: The line number to move to. Defaults to 1.
|
||||
context_lines: int | None = 100: Only shows this number of lines in the context window (usually from line 1), with line_number as the center (if possible). Defaults to 100.
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ open_file(path: str, line_number: int | None = 1, context_lines: int | None = 10
|
||||
It only shows the first 100 lines by default! Max `context_lines` supported is 2000, use `scroll up/down`
|
||||
to view the file if you want to see more.
|
||||
Args:
|
||||
path: str: The path to the file to open, preferredly absolute path.
|
||||
path: str: The path to the file to open, preferred absolute path.
|
||||
line_number: int | None = 1: The line number to move to. Defaults to 1.
|
||||
context_lines: int | None = 100: Only shows this number of lines in the context window (usually from line 1), with line_number as the center (if possible). Defaults to 100.
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ open_file(path: str, line_number: int | None = 1, context_lines: int | None = 10
|
||||
It only shows the first 100 lines by default! Max `context_lines` supported is 2000, use `scroll up/down`
|
||||
to view the file if you want to see more.
|
||||
Args:
|
||||
path: str: The path to the file to open, preferredly absolute path.
|
||||
path: str: The path to the file to open, preferred absolute path.
|
||||
line_number: int | None = 1: The line number to move to. Defaults to 1.
|
||||
context_lines: int | None = 100: Only shows this number of lines in the context window (usually from line 1), with line_number as the center (if possible). Defaults to 100.
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ open_file(path: str, line_number: int | None = 1, context_lines: int | None = 10
|
||||
It only shows the first 100 lines by default! Max `context_lines` supported is 2000, use `scroll up/down`
|
||||
to view the file if you want to see more.
|
||||
Args:
|
||||
path: str: The path to the file to open, preferredly absolute path.
|
||||
path: str: The path to the file to open, preferred absolute path.
|
||||
line_number: int | None = 1: The line number to move to. Defaults to 1.
|
||||
context_lines: int | None = 100: Only shows this number of lines in the context window (usually from line 1), with line_number as the center (if possible). Defaults to 100.
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user