irregular6612 Claude Sonnet 4.6 commited on
Commit
11cd1de
·
1 Parent(s): d36047a

feat(discovery): source available actions from scenario.action_set (interact reaches the agent)

Browse files
proteus/game/runtime/_session_core.py CHANGED
@@ -155,7 +155,7 @@ def build_observation(
155
  parts.append("Now:")
156
  parts.append(render_ascii(scenario, game))
157
  parts.append(legend_text(legend))
158
- parts.append(f"Available actions: [{', '.join(_ACTIONS)}]")
159
  return "\n".join(parts)
160
 
161
 
 
155
  parts.append("Now:")
156
  parts.append(render_ascii(scenario, game))
157
  parts.append(legend_text(legend))
158
+ parts.append(f"Available actions: [{', '.join(scenario.action_set)}]")
159
  return "\n".join(parts)
160
 
161
 
proteus/game/runtime/interactive.py CHANGED
@@ -74,7 +74,7 @@ class InteractiveSession:
74
  "play_turns": self._play_turns,
75
  "grid": core.grid_to_list(self._game.current_grid()),
76
  "legend": {str(k): v for k, v in self._scenario.legend().items()},
77
- "actions": list(core._ACTIONS),
78
  "outcome": None,
79
  "cut_frames": self._cut_grids if played == 0 else None,
80
  "review": None,
@@ -103,9 +103,9 @@ class InteractiveSession:
103
  def step(self, action: str, probe_answer: str = "") -> dict:
104
  if self._is_done():
105
  raise core.SessionFinishedError("session already finished")
106
- if action not in core._ACTIONS:
107
  raise ValueError(
108
- f"invalid action {action!r}; choose one of {core._ACTIONS}"
109
  )
110
  turn_idx = len(self._turns) + 1
111
  observation = core.build_observation(
 
74
  "play_turns": self._play_turns,
75
  "grid": core.grid_to_list(self._game.current_grid()),
76
  "legend": {str(k): v for k, v in self._scenario.legend().items()},
77
+ "actions": list(self._scenario.action_set),
78
  "outcome": None,
79
  "cut_frames": self._cut_grids if played == 0 else None,
80
  "review": None,
 
103
  def step(self, action: str, probe_answer: str = "") -> dict:
104
  if self._is_done():
105
  raise core.SessionFinishedError("session already finished")
106
+ if action not in self._scenario.action_set:
107
  raise ValueError(
108
+ f"invalid action {action!r}; choose one of {self._scenario.action_set}"
109
  )
110
  turn_idx = len(self._turns) + 1
111
  observation = core.build_observation(
proteus/game/runtime/session.py CHANGED
@@ -92,7 +92,7 @@ class SessionRunner:
92
  probe_thinking_tokens=probe.thinking_tokens,
93
  )
94
 
95
- result = self._agent.act(observation, list(core._ACTIONS), system_prompt)
96
  turns.append(core.make_turn_trace(
97
  scenario, game,
98
  turn_idx=turn_idx,
 
92
  probe_thinking_tokens=probe.thinking_tokens,
93
  )
94
 
95
+ result = self._agent.act(observation, list(scenario.action_set), system_prompt)
96
  turns.append(core.make_turn_trace(
97
  scenario, game,
98
  turn_idx=turn_idx,
tests/runtime/test_errand_discovery.py CHANGED
@@ -64,3 +64,21 @@ def test_make_turn_trace_no_self_report_is_none():
64
  tt = core.make_turn_trace(scen, game, turn_idx=1, observation="o",
65
  action="stay", raw_text="ACTION: stay")
66
  assert tt.self_belief is None and tt.self_correct is None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  tt = core.make_turn_trace(scen, game, turn_idx=1, observation="o",
65
  action="stay", raw_text="ACTION: stay")
66
  assert tt.self_belief is None and tt.self_correct is None
67
+
68
+
69
+ def test_observation_lists_scenario_action_set():
70
+ scen, game = _errand()
71
+ obs = core.build_observation(scen, game, cut_frames=[], turn_idx=1)
72
+ assert "interact" in obs # errand_runner exposes interact in Available actions
73
+ # template stays at the 5 movement actions (regression)
74
+ t = get_scenario("template")()
75
+ tgame = MotiveGridGame(t, random.Random(0), Difficulty.EASY, max_steps=10)
76
+ tobs = core.build_observation(t, tgame, cut_frames=[], turn_idx=1)
77
+ assert "interact" not in tobs
78
+
79
+
80
+ def test_interactive_accepts_interact_for_errand():
81
+ from proteus.game.runtime.interactive import InteractiveSession
82
+ s = InteractiveSession("errand_runner", seed=7, play_turns=5, use_default_memory=False)
83
+ assert "interact" in s.state()["actions"]
84
+ s.step("interact") # must not raise "invalid action"