MCPcopy Index your code
hub / github.com/CodeClash-ai/CodeClash / run

Method run

codeclash/agents/minisweagent.py:50–86  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

48 super().__init__(config, environment=environment, game_context=game_context)
49
50 def run(self):
51 model = get_model(config=self.config["config"]["model"])
52 self.agent = ClashAgent(
53 model=model,
54 env=self.environment,
55 logger=self.logger,
56 **self.config["config"]["agent"],
57 )
58 exit_status = None
59 exc_message = None
60 try:
61 result = self.agent.run(task="", **self.game_context.to_template_vars())
62 exit_status = result.get("exit_status", "")
63 except Exception as e:
64 exit_status = str(e)
65 exc_message = traceback.format_exc()
66 self.logger.critical(exc_message)
67 finally:
68 traj_path = (
69 self.game_context.log_local
70 / "players"
71 / self.name
72 / f"{self.name}_r{self.game_context.round}.traj.json"
73 )
74 self.agent.save(traj_path)
75 copy_to_container(
76 self.environment,
77 traj_path,
78 self.game_context.log_env / "edits" / traj_path.name,
79 )
80 self._metadata["agent_stats"][self.game_context.round] = {
81 "exit_status": exit_status,
82 "cost": self.agent.cost,
83 "api_calls": self.agent.n_calls,
84 }
85 if exit_status.lower().strip() not in ["", "submitted", "limitsexceeded"] and exc_message is not None:
86 raise RuntimeError(f"Agent {self.name} failed with exit status: {exit_status} and exception: {exc_message}")

Callers

nothing calls this directly

Calls 5

copy_to_containerFunction · 0.90
ClashAgentClass · 0.85
to_template_varsMethod · 0.80
getMethod · 0.80
saveMethod · 0.80

Tested by

no test coverage detected