8000 Enh: Set timeout for post_startup_commands by klieret · Pull Request #973 · SWE-agent/SWE-agent · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Enh: Set timeout for post_startup_commands #973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8000
Merged
merged 1 commit into from
Feb 24, 2025
Merged
Changes from all commits
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
15 changes: 12 additions & 3 deletions sweagent/environment/swe_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ class EnvironmentConfig(BaseModel):
)
post_startup_commands: list[str] = []
"""Execute these commands before starting to run the agent but after all other setup steps.
They will be executed in the same shell as the agent."""
They will be executed in the same shell as the agent.
Note: Every command is passed as a string, not a list of arguments.
"""
post_startup_command_timeout: int = 500
"""Timeout for the post-startup commands.
NOTE: The timeout applies to every command in `post_startup_commands` separately.
"""

# pydantic config
model_config = ConfigDict(extra="forbid")
Expand All @@ -49,6 +55,7 @@ def __init__(
deployment: AbstractDeployment,
repo: Repo | RepoConfig | None,
post_startup_commands: list[str],
post_startup_command_timeout: int = 500,
hooks: list[EnvHook] | None = None,
name: str = "main",
):
Expand All @@ -66,7 +73,8 @@ def __init__(
self.deployment = deployment
self.repo = repo
self._post_startup_commands = post_startup_commands
self.logger = get_logger("swea-env", emoji="🌱")
self.post_startup_command_timeout = post_startup_command_timeout
self.logger = get_logger("swea-env", emoji="���")
self.name = name
self.clean_multi_line_functions = lambda x: x
self._chook = CombinedEnvHooks()
Expand All @@ -85,6 +93,7 @@ def from_config(cls, config: EnvironmentConfig) -> Self:
deployment=get_deployment(config.deployment),
repo=config.repo,
post_startup_commands=config.post_startup_commands,
post_startup_command_timeout=config.post_startup_command_timeout,
name=config.name,
)

Expand All @@ -102,7 +111,7 @@ def start(self) -> None:
self._init_deployment()
self.reset()
for command in self._post_startup_commands:
self.communicate(command, check="raise")
self.communicate(command, check="raise", timeout=self.post_startup_command_timeout)

def _copy_repo(self) -> None:
"""Clone/copy repository/codebase in container"""
Expand Down
0