Spaces:
Sleeping
Sleeping
File size: 1,885 Bytes
93cd78f 426093b 7345481 426093b ef18469 426093b ef18469 93cd78f ef18469 93cd78f ef18469 93cd78f ef18469 426093b ef18469 93cd78f ef18469 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | import proteus.game.scenarios # noqa: F401 (registers scenarios)
from proteus.game.scenarios.base import Scenario, get_scenario
def test_scenario_base_memory_brief_default_empty():
assert Scenario.memory_brief == ""
from proteus.game.agents import VanillaAgent
from proteus.game.engine.difficulty import Difficulty
from proteus.providers import FakeProvider
def _agent(action: str = "down", n: int = 20) -> VanillaAgent:
return VanillaAgent(FakeProvider([f"ACTION: {action}"] * n, model_name="demo"))
def test_generate_memory_is_deterministic_and_records_episode():
from proteus.game.runtime.memory_gen import generate_memory
ck = generate_memory(
"template", _agent(), difficulty=Difficulty.EASY, seed=42,
memory_turns=5, model_name="demo", clock=lambda: "FIXED",
)
assert ck.created_at == "FIXED"
assert ck.model == "demo"
assert ck.scenario == "template"
assert ck.difficulty == "easy"
assert 1 <= len(ck.memory_turns) <= 5
assert ck.memory_turns[0].action == "down"
assert ck.memory_turns[0].frame_ascii # a rendered frame was captured
assert ck.outcome in ("survived", "eliminated")
ck2 = generate_memory(
"template", _agent(), difficulty=Difficulty.EASY, seed=42,
memory_turns=5, model_name="demo", clock=lambda: "FIXED",
)
assert ck.model_dump() == ck2.model_dump()
def test_generate_memory_uses_memory_brief_as_prompt():
from proteus.game.runtime.memory_gen import generate_memory
agent = _agent()
generate_memory(
"template", agent, difficulty=Difficulty.EASY, seed=42,
memory_turns=2, model_name="demo", clock=lambda: "FIXED",
)
# The provider saw the transparent brief as the system message.
system_msg = agent._provider.calls[0][0]
assert system_msg["role"] == "system"
assert "PRACTICE" in system_msg["content"]
|