Spaces:
Sleeping
Sleeping
| from proteus.game.agents import VanillaAgent | |
| from proteus.providers import FakeProvider | |
| from proteus.game.runtime import SessionRunner, append_trace, read_traces | |
| def _trace(seed): | |
| agent = VanillaAgent(FakeProvider(responses=["ACTION: up"], model_name="fake-1")) | |
| return SessionRunner( | |
| "template", agent, seed=seed, play_turns=4, use_probe=False, | |
| ).run() | |
| def test_append_then_read_roundtrips_one_trace(tmp_path): | |
| path = tmp_path / "runs" / "session.jsonl" | |
| written = append_trace(_trace(42), path) | |
| assert written.exists() | |
| traces = read_traces(path) | |
| assert len(traces) == 1 | |
| assert traces[0].scenario == "template" | |
| assert traces[0].model == "fake-1" | |
| def test_append_accumulates_multiple_sessions(tmp_path): | |
| path = tmp_path / "session.jsonl" | |
| append_trace(_trace(1), path) | |
| append_trace(_trace(2), path) | |
| traces = read_traces(path) | |
| assert len(traces) == 2 | |
| assert [t.seed for t in traces] == [1, 2] | |
| def test_read_ignores_blank_lines(tmp_path): | |
| path = tmp_path / "s.jsonl" | |
| append_trace(_trace(7), path) | |
| with path.open("a", encoding="utf-8") as f: | |
| f.write("\n") # trailing blank line | |
| assert len(read_traces(path)) == 1 | |
| def test_append_creates_parent_dirs(tmp_path): | |
| path = tmp_path / "deep" / "nested" / "s.jsonl" | |
| append_trace(_trace(3), path) | |
| assert path.exists() | |