AgentnessBench / tests /runtime /test_spectate_equivalence.py
irregular6612's picture
refactor(scenario): delete predator_evade; template is the canonical scenario
93cd78f
Raw
History Blame Contribute Delete
1.42 kB
"""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()