Skip to content

Commit

Permalink
Merge pull request #79 from agentsea/dev
Browse files Browse the repository at this point in the history
Fix docker + qemu
  • Loading branch information
pbarker authored Jun 17, 2024
2 parents 6d010bd + a592d52 commit 6bcd581
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
9 changes: 5 additions & 4 deletions surfkit/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,8 @@ def list_types():


@app.command("find")
def find():
def find(help="Find an agent"):
"""Find an agent"""
list_types()


Expand Down Expand Up @@ -1657,9 +1658,9 @@ def solve(
vm = vms[0]

if vm.provider and vm.provider.type == "qemu":
if agent_runtime != "process":
if agent_runtime != "process" and agent_runtime != "docker":
raise ValueError(
"Qemu desktop can only be used with the agent 'process' runtime"
"Qemu desktop can only be used with the agent 'process' or 'docker' runtime"
)
_device = Desktop.from_vm(vm)
v1device = _device.to_v1()
Expand Down Expand Up @@ -1818,7 +1819,7 @@ def solve(
pass


@app.command("eval", help="Evaluate an agent on a benchmark")
# @app.command("eval", help="Evaluate an agent on a benchmark") # TODO
def eval(
benchmark: str = typer.Argument(
help="Benchmark name",
Expand Down
17 changes: 17 additions & 0 deletions surfkit/runtime/agent/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,23 @@ def solve_task(
raise ValueError(f"No instances found for name '{name}'")
instance = instances[0]

# TODO: This is a hack to make the qemu desktops work with docker agents, should likely be reworked
if task.task.device and task.task.device.type.lower() == "desktop":
cfg = task.task.device.config
if hasattr(cfg, "agentd_url"):
agentd_url: str = cfg.agentd_url # type: ignore
if agentd_url.startswith("http://localhost"):
agentd_url = agentd_url.replace(
"http://localhost", "http://host.docker.internal"
)
task.task.device.config.agentd_url = agentd_url # type: ignore
logging.debug(f"replaced agentd url: {task.task.device.config}")

elif agentd_url.startswith("localhost"):
agentd_url = agentd_url.replace("localhost", "host.docker.internal")
task.task.device.config.agentd_url = agentd_url # type: ignore
logging.debug(f"replaced agentd url: {task.task.device.config}")

print(f"Container '{name}' found.")
response = requests.post(
f"http://localhost:{instance.port}/v1/tasks",
Expand Down

0 comments on commit 6bcd581

Please sign in to comment.