Skip to content
Open
Show file tree
Hide file tree
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
13 changes: 9 additions & 4 deletions evalbench/generators/models/agy_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ def _verify_runtime(self, configured_servers: list):

env = self._merged_env()
cmd = self._base_agy_command(
self.agy_bin, "ping", model=self.model
self.agy_bin, "ping", model=self.model, add_dirs=[self.fake_home]

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if wee need to pass the add_dirs here.

)
try:
subprocess.run(
Expand Down Expand Up @@ -833,7 +833,7 @@ def _merged_env(self, extra: dict | None = None) -> dict:
def _base_agy_command(
cli: str, prompt: str, resume: bool = False, model: str = None,
output_format: str = None, log_file: str = None,
timeout: str = None,
timeout: str = None, add_dirs: list[str] | str | None = None,
) -> list:
"""Builds the non-interactive ``agy -p`` argv shared by the eval
turn path and the setup-time MCP probe.
Expand All @@ -854,6 +854,11 @@ def _base_agy_command(
defaults to agy's internal default (5 minutes).
"""
command = [cli, "-p", prompt, "--dangerously-skip-permissions"]
if add_dirs:
if isinstance(add_dirs, str):
add_dirs = [add_dirs]
for d in add_dirs:
command += ["--add-dir", d]
if model:
command += ["--model", model]
if output_format:
Expand Down Expand Up @@ -895,15 +900,15 @@ def _execute_cli_command(

def _run_agy_cli(self, cli_cmd: CLICommand):
env = self._merged_env(cli_cmd.env)
cwd = cli_cmd.cwd if cli_cmd.cwd else self.fake_home
# The executable is always this session's sandbox binary, regardless of
# the label carried on cli_cmd.cli (the evaluator passes agent_version,
# "agy", which is not a path).
command = self._base_agy_command(
self.agy_bin, cli_cmd.prompt, cli_cmd.resume, self.model,
output_format="stream-json", log_file=self.cli_log_path,
timeout=self.timeout,
timeout=self.timeout, add_dirs=[cwd],
)
cwd = cli_cmd.cwd if cli_cmd.cwd else self.fake_home
result = self._execute_cli_command(command, env=env, cwd=cwd)

# Parse whenever agy emitted a stream, even on a non-zero exit: a
Expand Down
11 changes: 7 additions & 4 deletions evalbench/test/agy_cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,16 @@ def test_ensure_agy_installed_raises_when_binary_absent_after_install(

def test_run_command_argv_shape(mock_run, sandbox):
"""``_run_agy_cli`` must build ``agy -p <prompt>
--dangerously-skip-permissions --output-format stream-json``."""
--dangerously-skip-permissions --add-dir <cwd> --output-format stream-json``."""
generator = AgyCliGenerator({})
cmd = CLICommand(cli="agy", prompt="hello world")
generator._run_agy_cli(cmd)

sent_argv = mock_run.call_args[0][0]
assert sent_argv == [
generator.agy_bin, "-p", "hello world",
"--dangerously-skip-permissions", "--output-format", "stream-json",
"--dangerously-skip-permissions", "--add-dir", generator.fake_home,
"--output-format", "stream-json",
"--log-file", generator.cli_log_path,
]

Expand All @@ -286,7 +287,8 @@ def test_run_command_argv_shape_with_continue(mock_run, sandbox):
sent_argv = mock_run.call_args[0][0]
assert sent_argv == [
generator.agy_bin, "-p", "next turn",
"--dangerously-skip-permissions", "--output-format", "stream-json",
"--dangerously-skip-permissions", "--add-dir", generator.fake_home,
"--output-format", "stream-json",
"--log-file", generator.cli_log_path, "--continue",
]

Expand Down Expand Up @@ -321,7 +323,8 @@ def test_run_command_argv_shape_with_timeout(mock_run, sandbox):
sent_argv = mock_run.call_args[0][0]
assert sent_argv == [
generator.agy_bin, "-p", "hello world",
"--dangerously-skip-permissions", "--output-format", "stream-json",
"--dangerously-skip-permissions", "--add-dir", generator.fake_home,
"--output-format", "stream-json",
"--log-file", generator.cli_log_path, "--print-timeout", "20m",
]

Expand Down
Loading