MCPcopy Index your code
hub / github.com/IBM/AssetOpsBench / OpenCodeAgentRunner

Class OpenCodeAgentRunner

src/agent/opencode_agent/runner.py:567–720  ·  view source on GitHub ↗

Agent runner that delegates the agentic loop to ``opencode run``.

Source from the content-addressed store, hash-verified

565
566
567class OpenCodeAgentRunner(AgentRunner):
568 """Agent runner that delegates the agentic loop to ``opencode run``."""
569
570 def __init__(
571 self,
572 llm=None,
573 server_paths: dict[str, Path | str] | None = None,
574 model: str = _DEFAULT_MODEL,
575 max_steps: int = 30,
576 agent_name: str = _DEFAULT_AGENT_NAME,
577 opencode_bin: str = "opencode",
578 attach: str | None = None,
579 timeout_s: float | None = 900,
580 thinking: bool = False,
581 variant: str | None = None,
582 allow_bash: bool = False,
583 allow_edit: bool = False,
584 allow_web: bool = False,
585 allow_files: bool = False,
586 workspace_dir: Path | str | None = None,
587 dangerously_skip_permissions: bool = True,
588 ) -> None:
589 super().__init__(llm, server_paths)
590 self._model_id = model
591 self._max_steps = max_steps
592 self._agent_name = agent_name
593 self._opencode_bin = opencode_bin
594 self._attach = attach
595 self._timeout_s = timeout_s
596 self._thinking = thinking
597 self._variant = variant
598 self._dangerously_skip_permissions = dangerously_skip_permissions
599 self._run_dir = _resolve_run_dir(
600 workspace_dir=workspace_dir,
601 allow_bash=allow_bash,
602 allow_edit=allow_edit,
603 allow_files=allow_files,
604 )
605 self._config, self._env_overrides, self._opencode_model = (
606 _build_opencode_config(
607 model=model,
608 agent_name=agent_name,
609 max_steps=max_steps,
610 server_paths=self._server_paths,
611 allow_bash=allow_bash,
612 allow_edit=allow_edit,
613 allow_web=allow_web,
614 allow_files=allow_files,
615 )
616 )
617
618 async def run(self, question: str) -> AgentResult:
619 """Run OpenCode for *question* and return a benchmark result."""
620 with agent_run_span(
621 "opencode-agent", model=self._model_id, question=question
622 ) as span:
623 run_started = time.perf_counter()
624 started_at = _dt.datetime.now(_dt.UTC).isoformat()

Callers 3

_runFunction · 0.90
test_runner_defaultsFunction · 0.90

Calls

no outgoing calls

Tested by 2

test_runner_defaultsFunction · 0.72