Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/openenv/harbor/atif.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@


def load_atif(trial_dir: str | Path) -> dict[str, Any] | None:
"""Read `agent/trajectory.json` from a Harbor trial dir. None if the agent emitted none."""
"""Read the ATIF object from a Harbor trial dir, if available."""
path = Path(trial_dir) / "agent" / "trajectory.json"
if not path.is_file():
return None
try:
return json.loads(path.read_text())
trace = json.loads(path.read_text())
except Exception: # noqa: BLE001 - a malformed trace must not break a good rollout
return None
return trace if isinstance(trace, dict) else None


def _pi_session_as_atif(trial_dir: Path) -> dict[str, Any] | None:
Expand Down
12 changes: 12 additions & 0 deletions tests/envs/test_harbor_reconcile.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,18 @@ def test_pi_rollout_ended_by_the_proxy_budget_stop_reconciles(tmp_path):
assert "proxy_budget_stops" in codes(report)


@pytest.mark.parametrize("content", ["[]", '"pending"', "false", "1", "null"])
def test_non_object_atif_uses_the_pi_session(tmp_path, content):
agent_dir = tmp_path / "agent"
agent_dir.mkdir()
(agent_dir / "trajectory.json").write_text(content)

native = pi_session(tmp_path, [(None, 10), (None, 20)])

report = reconcile(document([10, 20]), native)
assert report.ok, report.findings


def test_pi_zero_token_reply_that_is_not_a_budget_stop_still_fails(tmp_path):
doc = document([10, 20])
doc["budget_stop_count"] = 1
Expand Down