MCPcopy Create free account
hub / github.com/CodeClash-ai/CodeClash / decide

Method decide

codeclash/arenas/scml/runtime/run_scml.py:285–321  ·  view source on GitHub ↗
(self, observation: dict[str, Any])

Source from the content-addressed store, hash-verified

283 self._start_worker()
284
285 def decide(self, observation: dict[str, Any]) -> dict[str, Any]:
286 if self.disabled:
287 return {}
288 event = str(observation.get("event", "unknown"))
289 if self.startup_error is not None:
290 self._record_error(event, self.startup_error)
291 if not self.disabled:
292 self.restart()
293 return {}
294 request_id = self._next_request_id
295 self._next_request_id += 1
296 self.command_queue.put({"request_id": request_id, "observation": observation})
297 try:
298 result = self.result_queue.get(timeout=self.timeout)
299 except queue.Empty:
300 self._record_error(event, f"decide exceeded {self.timeout}s timeout")
301 if not self.disabled:
302 self.restart()
303 return {}
304
305 if result.get("request_id") not in {request_id, None}:
306 self._record_error(event, "received stale policy result")
307 return {}
308 if "error" in result:
309 self._record_error(event, result["error"])
310 if result.get("request_id") is None and not self.disabled:
311 self.restart()
312 return {}
313 decision = result.get("decision")
314 if decision is None:
315 self.decisions += 1
316 return {}
317 if not isinstance(decision, dict):
318 self._record_error(event, "decide must return a dictionary or None", invalid=True)
319 return {}
320 self.decisions += 1
321 return decision
322
323
324def build_agent_class(player_name: str, path: str, *, decision_timeout: float, max_policy_errors: int):

Callers 5

policy_workerFunction · 0.45
proposeMethod · 0.45
respondMethod · 0.45
first_proposalsMethod · 0.45
counter_allMethod · 0.45

Calls 3

_record_errorMethod · 0.95
restartMethod · 0.95
getMethod · 0.80

Tested by

no test coverage detected