-
Notifications
You must be signed in to change notification settings - Fork 559
Refactor V1 timeout handling #1543
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
base: main
Are you sure you want to change the base?
Changes from 3 commits
87149fb
be71389
37953fc
b5fe675
72f59c6
81a4506
adde70a
8ab88fd
181e9ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| import asyncio | ||
| import json | ||
| from collections.abc import Awaitable, Callable, Iterator, Mapping, Sequence | ||
| from typing import Protocol, cast | ||
|
|
@@ -51,6 +50,7 @@ def system_prompt(allow_go_back: bool = True) -> str: | |
|
|
||
|
|
||
| SYSTEM_PROMPT = system_prompt() | ||
| WIKISPEEDIA_TASK_TIMEOUT_SECONDS = 1200.0 | ||
|
|
||
|
|
||
| class WikispeediaTasksetConfig(vf.TasksetConfig): | ||
|
|
@@ -73,7 +73,6 @@ class WikispeediaHarnessConfig(vf.HarnessConfig): | |
| fn="run_langchain_deep_agents_wikispeedia_program" | ||
| ) | ||
| max_turns: int = 50 | ||
| timeout_seconds: float = 1200.0 | ||
|
cursor[bot] marked this conversation as resolved.
|
||
|
|
||
|
|
||
| class WikispeediaTaskset(vf.Taskset[WikispeediaTasksetConfig]): | ||
|
|
@@ -444,7 +443,6 @@ async def go_back() -> str: | |
|
|
||
| def make_langchain_deep_agents_program( | ||
| max_turns: int, | ||
| timeout_seconds: float, | ||
| ) -> Callable[[vf.Task, vf.State], Awaitable[vf.State]]: | ||
| async def run_langchain_deep_agents_wikispeedia_program( | ||
| task: vf.Task, state: vf.State | ||
|
|
@@ -488,19 +486,14 @@ async def run_langchain_deep_agents_wikispeedia_program( | |
| invoke_config = ( | ||
| {"recursion_limit": recursion_limit} if recursion_limit > 0 else None | ||
| ) | ||
| invoke = agent.ainvoke( | ||
| {"messages": [{"role": "user", "content": prompt}]}, | ||
| config=invoke_config, | ||
| ) | ||
| try: | ||
| result = await asyncio.wait_for(invoke, timeout=timeout_seconds) | ||
| except (TimeoutError, GraphRecursionError) as exc: | ||
| state["agent_timeout"] = True | ||
| state.stop( | ||
| "agent_timeout" | ||
| if isinstance(exc, TimeoutError) | ||
| else "agent_recursion_limit" | ||
| result = await agent.ainvoke( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When the Wikispeedia agent exceeds the new Useful? React with 👍 / 👎. |
||
| {"messages": [{"role": "user", "content": prompt}]}, | ||
| config=invoke_config, | ||
| ) | ||
| except GraphRecursionError: | ||
| state["agent_timeout"] = True | ||
| state.stop("agent_recursion_limit") | ||
| state.setdefault("agent_completion", []) | ||
| return state | ||
|
|
||
|
|
@@ -520,7 +513,6 @@ async def run_langchain_deep_agents_wikispeedia_program( | |
| ) -> vf.State: | ||
| return await make_langchain_deep_agents_program( | ||
| max_turns=harness.config.max_turns, | ||
| timeout_seconds=harness.config.timeout_seconds, | ||
| )(task, state) | ||
|
|
||
|
|
||
|
|
@@ -585,7 +577,9 @@ class WikispeediaEnvConfig(vf.EnvConfig): | |
|
|
||
|
|
||
| def load_environment(config: WikispeediaEnvConfig) -> vf.Env: | ||
| return vf.Env( | ||
| env = vf.Env( | ||
| taskset=vf.load_taskset(config=config.taskset), | ||
| harness=vf.load_harness(config=config.harness), | ||
| ) | ||
| env.task_timeout_seconds = WIKISPEEDIA_TASK_TIMEOUT_SECONDS | ||
| return env | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,6 @@ | |
| MINI_SWE_AGENT_DEFAULT_PACKAGE = "mini-swe-agent@2.2.8" | ||
| MINI_SWE_AGENT_DEFAULT_CONFIG_SPEC = "mini" | ||
| MINI_SWE_AGENT_DEFAULT_MODEL_CLASS = "litellm" | ||
| MINI_SWE_AGENT_DEFAULT_ENVIRONMENT_TIMEOUT = 120 | ||
|
|
||
|
|
||
| def build_mini_swe_agent_install_script( | ||
|
|
@@ -60,7 +59,6 @@ class MiniSWEAgentProgramConfig(vf.ProgramConfig): | |
| package: str = MINI_SWE_AGENT_DEFAULT_PACKAGE | ||
| config_spec: str = MINI_SWE_AGENT_DEFAULT_CONFIG_SPEC | ||
| model_class: str = MINI_SWE_AGENT_DEFAULT_MODEL_CLASS | ||
| environment_timeout: int = MINI_SWE_AGENT_DEFAULT_ENVIRONMENT_TIMEOUT | ||
| parallel_tool_calls: bool = True | ||
| extra_config_specs: list[str] | None = None | ||
| sandbox: vf.SandboxConfig | None = vf.SandboxConfig() | ||
|
|
@@ -101,8 +99,6 @@ def resolve(self) -> vf.ProgramConfig: | |
| "-c", | ||
| "agent.cost_limit=0", | ||
| "-c", | ||
| f"environment.timeout={self.environment_timeout}", | ||
| "-c", | ||
| f"model.model_class={shlex.quote(self.model_class)}", | ||
| "-c", | ||
| "model.cost_tracking=ignore_errors", | ||
|
|
@@ -139,7 +135,7 @@ def resolve(self) -> vf.ProgramConfig: | |
| CONFIG_ARGS+=(-c "agent.system_template=$(cat {system_prompt_path})") | ||
| fi | ||
| cd "$MINI_SWE_AGENT_WORKDIR" | ||
| timeout --kill-after=30s "${{AGENT_TIMEOUT_SECONDS:-3600}}" {shlex.quote(DEFAULT_MINI_BINARY)} \\ | ||
|
cursor[bot] marked this conversation as resolved.
|
||
| {shlex.quote(DEFAULT_MINI_BINARY)} \\ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
With the default v1 environment settings, Useful? React with 👍 / 👎.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no |
||
| --model "$OPENAI_MODEL" \\ | ||
| --task "$MINI_SWE_AGENT_TASK" \\ | ||
| --output {shlex.quote(self.trajectory_path)} \\ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.