yxc20098 commited on
Commit
18612b1
·
1 Parent(s): 2e5c9a4

S8: capture_actor tool schema + dispatch; wildcard count 21->22

Browse files
Files changed (2) hide show
  1. openra_bench/agent.py +23 -0
  2. tests/test_tools.py +1 -1
openra_bench/agent.py CHANGED
@@ -128,6 +128,24 @@ _TOOL_SCHEMAS: dict[str, dict] = {
128
  },
129
  },
130
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  "set_stance": {
132
  "type": "function",
133
  "function": {
@@ -399,6 +417,11 @@ def _to_commands(tool_calls: list[dict], Command: Any) -> list:
399
  cmds.append(
400
  Command.enter_transport(ids, str(args["target_id"]))
401
  )
 
 
 
 
 
402
  elif name == "observe":
403
  cmds.append(Command.observe())
404
  elif name == "surrender":
 
128
  },
129
  },
130
  },
131
+ "capture_actor": {
132
+ "type": "function",
133
+ "function": {
134
+ "name": "capture_actor",
135
+ "description": "Order engineer unit(s) (by id, in unit_ids) "
136
+ "to walk to and capture an enemy building (target_id). The "
137
+ "engineer is consumed; on success the building changes to "
138
+ "your ownership.",
139
+ "parameters": {
140
+ "type": "object",
141
+ "properties": {
142
+ "unit_ids": {"type": "array", "items": {"type": "integer"}},
143
+ "target_id": {"type": "integer"},
144
+ },
145
+ "required": ["unit_ids", "target_id"],
146
+ },
147
+ },
148
+ },
149
  "set_stance": {
150
  "type": "function",
151
  "function": {
 
417
  cmds.append(
418
  Command.enter_transport(ids, str(args["target_id"]))
419
  )
420
+ elif name == "capture_actor":
421
+ ids = [str(i) for i in args["unit_ids"]]
422
+ cmds.append(
423
+ Command.capture_actor(ids, str(args["target_id"]))
424
+ )
425
  elif name == "observe":
426
  cmds.append(Command.observe())
427
  elif name == "surrender":
tests/test_tools.py CHANGED
@@ -38,7 +38,7 @@ def test_explicit_allowlist_is_exactly_honored():
38
  def test_wildcard_exposes_everything():
39
  assert _names(["*"]) == set(_TOOL_SCHEMAS)
40
  assert _names(["all"]) == set(_TOOL_SCHEMAS)
41
- assert len(_names(["*"])) == 21
42
 
43
 
44
  def test_unknown_tool_names_are_ignored_not_errors():
 
38
  def test_wildcard_exposes_everything():
39
  assert _names(["*"]) == set(_TOOL_SCHEMAS)
40
  assert _names(["all"]) == set(_TOOL_SCHEMAS)
41
+ assert len(_names(["*"])) == 22
42
 
43
 
44
  def test_unknown_tool_names_are_ignored_not_errors():