Spaces:
Runtime error
Runtime error
| """Golden: the same scripted FakeProvider produces an identical SessionTrace | |
| whether driven through SpectateSession (one advance per turn) or SessionRunner + | |
| VanillaAgent (batch). Pins the spectate path to the runner path.""" | |
| from __future__ import annotations | |
| import proteus.game.scenarios # noqa: F401 | |
| from proteus.game.agents.vanilla import VanillaAgent | |
| from proteus.game.engine.difficulty import Difficulty | |
| from proteus.providers.fake import FakeProvider | |
| from proteus.game.runtime.session import SessionRunner | |
| from proteus.game.runtime.spectate import SpectateSession | |
| RESPONSES = ["ACTION: up", "ACTION: up", "ACTION: left", | |
| "ACTION: stay", "ACTION: right", "ACTION: up"] | |
| def _agent(): | |
| return VanillaAgent(FakeProvider(responses=list(RESPONSES), model_name="demo")) | |
| def test_spectate_matches_session_runner(): | |
| runner = SessionRunner( | |
| "template", _agent(), difficulty=Difficulty.EASY, seed=42, | |
| play_turns=len(RESPONSES), use_probe=False, | |
| ) | |
| batch_trace = runner.run() | |
| sess = SpectateSession( | |
| "template", agent=_agent(), model_name="demo", | |
| difficulty=Difficulty.EASY, seed=42, play_turns=len(RESPONSES), use_probe=False, | |
| ) | |
| while sess.state()["outcome"] is None: | |
| sess.advance() | |
| watch_trace = sess.finish() | |
| assert watch_trace.model == batch_trace.model == "demo" | |
| assert watch_trace.model_dump() == batch_trace.model_dump() | |