mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-08 22:38:05 -05:00
fix(backend) changes to improve Command-R+ behavior, plus file i/o error improvements. (#1347)
* Some improvements to prompts, some better exception handling for various file IO errors, added timeout and max return token configurations for the LLM api. * More monologue prompt improvements * Dynamically set username provided in prompt. * Remove absolute paths from llm prompts, fetch working directory from sandbox when resolving paths in fileio operations, add customizable timeout for bash commands, mention said timeout in llm prompt. * Switched ssh_box to disabling tty echo and removed the logic attempting to delete it from the response afterwards, fixed get_working_directory for ssh_box. * Update prompts in integration tests to match monologue agent changes. * Minor tweaks to make merge easier. * Another minor prompt tweak, better invalid json handling. * Fix lint error * More catch-up to fix lint errors introduced by merge. --------- Co-authored-by: Jim Su <jimsu@protonmail.com> Co-authored-by: Robert Brennan <accounts@rbren.io>
This commit is contained in:
@@ -1,24 +1,26 @@
|
||||
from opendevin import config
|
||||
from opendevin.schema import ConfigType
|
||||
from opendevin.action import fileop
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from opendevin import config
|
||||
from opendevin.schema.config import ConfigType
|
||||
from opendevin.action import fileop
|
||||
|
||||
|
||||
def test_resolve_path():
|
||||
assert fileop.resolve_path('test.txt') == Path(config.get(ConfigType.WORKSPACE_BASE)) / 'test.txt'
|
||||
assert fileop.resolve_path('subdir/test.txt') == Path(config.get(ConfigType.WORKSPACE_BASE)) / 'subdir' / 'test.txt'
|
||||
assert fileop.resolve_path(Path(fileop.SANDBOX_PATH_PREFIX) / 'test.txt') == \
|
||||
Path(config.get(ConfigType.WORKSPACE_BASE)) / 'test.txt'
|
||||
assert fileop.resolve_path(Path(fileop.SANDBOX_PATH_PREFIX) / 'subdir' / 'test.txt') == \
|
||||
assert fileop.resolve_path('test.txt', '/workspace') == Path(config.get(ConfigType.WORKSPACE_BASE)) / 'test.txt'
|
||||
assert fileop.resolve_path('subdir/test.txt', '/workspace') == \
|
||||
Path(config.get(ConfigType.WORKSPACE_BASE)) / 'subdir' / 'test.txt'
|
||||
assert fileop.resolve_path(Path(fileop.SANDBOX_PATH_PREFIX) / 'subdir' / '..' / 'test.txt') == \
|
||||
assert fileop.resolve_path(Path(fileop.SANDBOX_PATH_PREFIX) / 'test.txt', '/workspace') == \
|
||||
Path(config.get(ConfigType.WORKSPACE_BASE)) / 'test.txt'
|
||||
assert fileop.resolve_path(Path(fileop.SANDBOX_PATH_PREFIX) / 'subdir' / 'test.txt',
|
||||
'/workspace') == Path(config.get(ConfigType.WORKSPACE_BASE)) / 'subdir' / 'test.txt'
|
||||
assert fileop.resolve_path(Path(fileop.SANDBOX_PATH_PREFIX) / 'subdir' / '..' / 'test.txt',
|
||||
'/workspace') == Path(config.get(ConfigType.WORKSPACE_BASE)) / 'test.txt'
|
||||
with pytest.raises(PermissionError):
|
||||
fileop.resolve_path(Path(fileop.SANDBOX_PATH_PREFIX) / '..' / 'test.txt')
|
||||
fileop.resolve_path(Path(fileop.SANDBOX_PATH_PREFIX) / '..' / 'test.txt', '/workspace')
|
||||
with pytest.raises(PermissionError):
|
||||
fileop.resolve_path(Path('..') / 'test.txt')
|
||||
fileop.resolve_path(Path('..') / 'test.txt', '/workspace')
|
||||
with pytest.raises(PermissionError):
|
||||
fileop.resolve_path(Path('/') / 'test.txt')
|
||||
fileop.resolve_path(Path('/') / 'test.txt', '/workspace')
|
||||
assert fileop.resolve_path('test.txt', '/workspace/test') == \
|
||||
Path(config.get(ConfigType.WORKSPACE_BASE)) / 'test' / 'test.txt'
|
||||
|
||||
Reference in New Issue
Block a user