Spaces:
Sleeping
Sleeping
yc1838 commited on
Commit ·
a2a0291
1
Parent(s): 0c9677b
test: verify fresh memory on cooldown retry
Browse files- tests/test_runner.py +24 -0
tests/test_runner.py
CHANGED
|
@@ -159,3 +159,27 @@ def test_runner_does_not_checkpoint_when_rate_limited_twice(monkeypatch, tmp_pat
|
|
| 159 |
assert graph.calls == 2
|
| 160 |
assert answers == [{"task_id": "task-rl", "submitted_answer": "AGENT ERROR: RATE LIMITED"}]
|
| 161 |
assert not (tmp_path / "task-rl.json").exists()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
assert graph.calls == 2
|
| 160 |
assert answers == [{"task_id": "task-rl", "submitted_answer": "AGENT ERROR: RATE LIMITED"}]
|
| 161 |
assert not (tmp_path / "task-rl.json").exists()
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
def test_runner_uses_fresh_ephemeral_memory_for_retry(monkeypatch, tmp_path: Path):
|
| 165 |
+
graph = _GraphFailsOnceWithCooldown()
|
| 166 |
+
events = []
|
| 167 |
+
|
| 168 |
+
class _FakeEphemeralMemory:
|
| 169 |
+
def __enter__(self):
|
| 170 |
+
events.append("enter")
|
| 171 |
+
|
| 172 |
+
def __exit__(self, exc_type, exc, tb):
|
| 173 |
+
events.append("exit")
|
| 174 |
+
|
| 175 |
+
monkeypatch.setattr("lilith_agent.memory.ephemeral_memory", lambda: _FakeEphemeralMemory())
|
| 176 |
+
monkeypatch.setattr("lilith_agent.runner._final_formatting_cleanup", lambda model, question, raw, llm_formatter_enabled=True: raw)
|
| 177 |
+
monkeypatch.setattr("lilith_agent.runner.time.sleep", lambda _: None)
|
| 178 |
+
|
| 179 |
+
run_agent_on_questions(
|
| 180 |
+
graph,
|
| 181 |
+
[{"task_id": "task-memory", "question": "What is isolated?"}],
|
| 182 |
+
tmp_path,
|
| 183 |
+
)
|
| 184 |
+
|
| 185 |
+
assert events == ["enter", "exit", "enter", "exit"]
|