Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions tests/integration/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
MessageEvent,
)
from openhands.sdk.tool import Tool
from openhands.tools.preset.default import get_default_tools
from tests.integration.early_stopper import EarlyStopperBase, EarlyStopResult


Expand Down Expand Up @@ -204,10 +205,25 @@ def instruction_message(self) -> Message:
return Message(role="user", content=[TextContent(text=self.instruction)])

@property
@abstractmethod
def enable_browser(self) -> bool:
"""Whether to enable browser tools. Override in subclasses that need browsing.

Returns:
False by default. Override to True for tests that require browser access.
"""
return False

@property
def tools(self) -> list[Tool]:
"""List of tools available to the agent."""
pass
"""List of tools available to the agent.

By default, uses the default preset tools from openhands.tools.preset.default.
This ensures integration tests validate the same agent configuration shipped
to production (GUI/CLI).

Override this property in subclasses that need custom tool configurations.
"""
return get_default_tools(enable_browser=self.enable_browser)

@property
def condenser(self) -> CondenserBase | None:
Expand Down
9 changes: 0 additions & 9 deletions tests/integration/tests/b05_do_not_create_redundant_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
from textwrap import dedent

from openhands.sdk import get_logger
from openhands.sdk.tool import Tool, register_tool
from openhands.tools.file_editor import FileEditorTool
from openhands.tools.terminal import TerminalTool
from tests.integration.base import BaseIntegrationTest, SkipTest, TestResult
from tests.integration.behavior_utils import (
get_conversation_summary,
Expand All @@ -32,12 +29,6 @@ class NoRedundantFilesTest(BaseIntegrationTest):

INSTRUCTION: str = INSTRUCTION

@property
def tools(self) -> list[Tool]:
register_tool("TerminalTool", TerminalTool)
register_tool("FileEditorTool", FileEditorTool)
return [Tool(name="TerminalTool"), Tool(name="FileEditorTool")]

def setup(self) -> None: # noqa: D401
"""Set up a realistic codebase by cloning the lerobot repo."""
try:
Expand Down
13 changes: 0 additions & 13 deletions tests/integration/tests/t01_fix_simple_typo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
import os

from openhands.sdk import get_logger
from openhands.sdk.tool import Tool, register_tool
from openhands.tools.file_editor import FileEditorTool
from openhands.tools.terminal import TerminalTool
from tests.integration.base import BaseIntegrationTest, TestResult


Expand Down Expand Up @@ -34,16 +31,6 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.document_path: str = os.path.join(self.workspace, "document.txt")

@property
def tools(self) -> list[Tool]:
"""List of tools available to the agent."""
register_tool("TerminalTool", TerminalTool)
register_tool("FileEditorTool", FileEditorTool)
return [
Tool(name="TerminalTool"),
Tool(name="FileEditorTool"),
]

def setup(self) -> None:
"""Create a text file with typos for the agent to fix."""
# Create the test file with typos
Expand Down
13 changes: 0 additions & 13 deletions tests/integration/tests/t02_add_bash_hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
import os

from openhands.sdk import get_logger
from openhands.sdk.tool import Tool, register_tool
from openhands.tools.file_editor import FileEditorTool
from openhands.tools.terminal import TerminalTool
from tests.integration.base import BaseIntegrationTest, TestResult


Expand All @@ -24,16 +21,6 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.script_path: str = os.path.join(self.workspace, "shell", "hello.sh")

@property
def tools(self) -> list[Tool]:
"""List of tools available to the agent."""
register_tool("TerminalTool", TerminalTool)
register_tool("FileEditorTool", FileEditorTool)
return [
Tool(name="TerminalTool"),
Tool(name="FileEditorTool"),
]

def setup(self) -> None:
"""Setup is not needed - agent will create directories as needed."""

Expand Down
13 changes: 0 additions & 13 deletions tests/integration/tests/t03_jupyter_write_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
import os

from openhands.sdk import get_logger
from openhands.sdk.tool import Tool, register_tool
from openhands.tools.file_editor import FileEditorTool
from openhands.tools.terminal import TerminalTool
from tests.integration.base import BaseIntegrationTest, TestResult


Expand All @@ -27,16 +24,6 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.file_path: str = os.path.join(self.workspace, "test.txt")

@property
def tools(self) -> list[Tool]:
"""List of tools available to the agent."""
register_tool("TerminalTool", TerminalTool)
register_tool("FileEditorTool", FileEditorTool)
return [
Tool(name="TerminalTool"),
Tool(name="FileEditorTool"),
]

def setup(self) -> None:
"""Setup is not needed - agent will create directories as needed."""

Expand Down
13 changes: 0 additions & 13 deletions tests/integration/tests/t04_git_staging.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
import subprocess

from openhands.sdk import get_logger
from openhands.sdk.tool import Tool, register_tool
from openhands.tools.file_editor import FileEditorTool
from openhands.tools.terminal import TerminalTool
from tests.integration.base import BaseIntegrationTest, TestResult


Expand All @@ -23,16 +20,6 @@ class GitStagingTest(BaseIntegrationTest):

INSTRUCTION: str = INSTRUCTION

@property
def tools(self) -> list[Tool]:
"""List of tools available to the agent."""
register_tool("TerminalTool", TerminalTool)
register_tool("FileEditorTool", FileEditorTool)
return [
Tool(name="TerminalTool"),
Tool(name="FileEditorTool"),
]

def setup(self) -> None:
"""Set up git repository with staged changes."""
# Initialize git repository
Expand Down
14 changes: 3 additions & 11 deletions tests/integration/tests/t05_simple_browsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

from openhands.sdk import get_logger
from openhands.sdk.conversation import get_agent_final_response
from openhands.sdk.tool import Tool, register_tool
from openhands.tools.file_editor import FileEditorTool
from openhands.tools.terminal import TerminalTool
from tests.integration.base import BaseIntegrationTest, TestResult


Expand Down Expand Up @@ -101,14 +98,9 @@ def __init__(self, *args, **kwargs):
self.server_process: subprocess.Popen[bytes] | None = None

@property
def tools(self) -> list[Tool]:
"""List of tools available to the agent."""
register_tool("TerminalTool", TerminalTool)
register_tool("FileEditorTool", FileEditorTool)
return [
Tool(name="TerminalTool"),
Tool(name="FileEditorTool"),
]
def enable_browser(self) -> bool:
"""Enable browser tools for this browsing test."""
return True

def setup(self) -> None:
"""Set up a local web server with the HTML file."""
Expand Down
14 changes: 3 additions & 11 deletions tests/integration/tests/t06_github_pr_browsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

from openhands.sdk import get_logger
from openhands.sdk.conversation import get_agent_final_response
from openhands.sdk.tool import Tool, register_tool
from openhands.tools.file_editor import FileEditorTool
from openhands.tools.terminal import TerminalTool
from tests.integration.base import BaseIntegrationTest, TestResult


Expand All @@ -23,14 +20,9 @@ class GitHubPRBrowsingTest(BaseIntegrationTest):
INSTRUCTION: str = INSTRUCTION

@property
def tools(self) -> list[Tool]:
"""List of tools available to the agent."""
register_tool("TerminalTool", TerminalTool)
register_tool("FileEditorTool", FileEditorTool)
return [
Tool(name="TerminalTool"),
Tool(name="FileEditorTool"),
]
def enable_browser(self) -> bool:
"""Enable browser tools for this browsing test."""
return True

def setup(self) -> None:
"""No special setup needed for GitHub PR browsing."""
Expand Down
13 changes: 0 additions & 13 deletions tests/integration/tests/t07_interactive_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
import os

from openhands.sdk import get_logger
from openhands.sdk.tool import Tool, register_tool
from openhands.tools.file_editor import FileEditorTool
from openhands.tools.terminal import TerminalTool
from tests.integration.base import BaseIntegrationTest, TestResult


Expand Down Expand Up @@ -40,16 +37,6 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.script_path: str = os.path.join(self.workspace, "python_script.py")

@property
def tools(self) -> list[Tool]:
"""List of tools available to the agent."""
register_tool("TerminalTool", TerminalTool)
register_tool("FileEditorTool", FileEditorTool)
return [
Tool(name="TerminalTool"),
Tool(name="FileEditorTool"),
]

def setup(self) -> None:
"""Set up the interactive Python script."""

Expand Down
13 changes: 0 additions & 13 deletions tests/integration/tests/t08_image_file_viewing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@

from openhands.sdk import get_logger
from openhands.sdk.conversation.response_utils import get_agent_final_response
from openhands.sdk.tool import Tool, register_tool
from openhands.tools.file_editor import FileEditorTool
from openhands.tools.terminal import TerminalTool
from tests.integration.base import BaseIntegrationTest, SkipTest, TestResult


Expand Down Expand Up @@ -38,16 +35,6 @@ def __init__(self, *args, **kwargs):
"Please use a model that supports image input."
)

@property
def tools(self) -> list[Tool]:
"""List of tools available to the agent."""
register_tool("TerminalTool", TerminalTool)
register_tool("FileEditorTool", FileEditorTool)
return [
Tool(name="TerminalTool"),
Tool(name="FileEditorTool"),
]

def setup(self) -> None:
"""Download the OpenHands logo for the agent to analyze."""
try:
Expand Down
18 changes: 10 additions & 8 deletions tests/integration/utils/behavior_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
from typing import Any

from openhands.sdk import get_logger
from openhands.sdk.tool import Tool, register_tool
from openhands.tools.file_editor import FileEditorTool
from openhands.tools.terminal import TerminalTool
from openhands.sdk.tool import Tool
from openhands.tools.preset.default import get_default_tools
from tests.integration.base import BaseIntegrationTest, SkipTest
from tests.integration.early_stopper import EarlyStopperBase

Expand Down Expand Up @@ -83,11 +82,14 @@ def clone_pinned_software_agent_repo(workspace: str) -> Path:
return repo_dir


def default_behavior_tools() -> list[Tool]:
"""Register and return the default tools for behavior tests."""
register_tool("TerminalTool", TerminalTool)
register_tool("FileEditorTool", FileEditorTool)
return [Tool(name="TerminalTool"), Tool(name="FileEditorTool")]
def default_behavior_tools(enable_browser: bool = False) -> list[Tool]:
"""Return the default tools for behavior tests using the default preset.

Args:
enable_browser: Whether to include browser tools. Defaults to False
for behavior tests since they typically don't need browsing.
"""
return get_default_tools(enable_browser=enable_browser)


ENVIRONMENT_TIPS_BODY = """\
Expand Down
Loading