MCPcopy Create free account
hub / github.com/MaxBittker/runebench / _build_opencode_config

Method _build_opencode_config

agents/opencode_adapter.py:163–210  ·  view source on GitHub ↗

Build opencode.json config with the appropriate provider and MCP servers.

(self)

Source from the content-addressed store, hash-verified

161 fm = trajectory.final_metrics
162 context.n_input_tokens = fm.total_prompt_tokens or 0
163 context.n_output_tokens = fm.total_completion_tokens or 0
164 context.n_cache_tokens = fm.total_cached_tokens or 0
165 context.cost_usd = fm.total_cost_usd
166
167 # OpenCode uses "google" as its provider name for Gemini models.
168 _PROVIDER_REMAP = {"gemini": "google"}
169
170 def _build_opencode_config(self) -> dict:
171 """Build opencode.json config with the appropriate provider and MCP servers."""
172 model_id = self.model_name or self._default_model
173 if "/" in model_id:
174 parts = model_id.split("/", 1)
175 provider_name = self._PROVIDER_REMAP.get(parts[0], parts[0])
176 model_suffix = parts[1]
177 else:
178 provider_name = "openrouter"
179 model_suffix = model_id
180
181 config: dict = {
182 "$schema": "https://opencode.ai/config.json",
183 "provider": {
184 provider_name: {
185 "options": {
186 "timeout": 180000, # 3 min hard cutoff to avoid hung API calls
187 },
188 "models": {
189 model_suffix: {"options": self._model_options} if self._model_options else {}
190 }
191 }
192 },
193 "model": f"{provider_name}/{model_suffix}",
194 "permission": {
195 "*": "allow",
196 },
197 }
198
199 if self.mcp_servers:
200 mcp = {}
201 for server in self.mcp_servers:
202 if server.transport == "stdio":
203 cmd_parts = [server.command] + (server.args or [])
204 mcp[server.name] = {
205 "type": "local",
206 "command": cmd_parts,
207 "enabled": True,
208 }
209 else:
210 mcp[server.name] = {
211 "type": "remote",
212 "url": server.url,
213 "enabled": True,

Callers 1

runMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected