Skip to content
Draft
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
12 changes: 11 additions & 1 deletion src/openenv/core/harness/capture/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,17 @@ def check_upstream_response(payload: dict[str, Any]) -> Report:
"logprob_misalign",
f"{len(content)} logprobs vs {len(choice['token_ids'])} token ids",
)
token = (content[0] or {}).get("token", "")
if any(
not isinstance(entry, dict) or entry.get("logprob") is None
for entry in content
):
report.add(
FATAL,
"missing_sampled_logprob",
"At least one logprobs.content entry lacks a sampled token logprob.",
)
return report
token = content[0].get("token", "")
if not str(token).startswith("token_id:"):
# This says more than it looks like it says, and the mild reading of it is what makes the
# failure silent.
Expand Down
14 changes: 14 additions & 0 deletions tests/envs/test_harbor_capture_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,20 @@ def test_a_full_capture_engine_is_trainable(monkeypatch):
assert report.param_fixes == []


@pytest.mark.parametrize(
"logprob_entry", [{"logprob": None}, {}], ids=["null", "absent"]
)
def test_a_missing_sampled_logprob_prevents_training(monkeypatch, logprob_entry):
payload = reply(prompt_ids=[1, 2], token_ids=[7, 8], logprobs=[-0.1, -0.2])
payload["choices"][0]["logprobs"]["content"][1] = logprob_entry.copy()

report, _ = probe(monkeypatch, [payload])

assert report.reachable and not report.trainable
assert report.rollout_type == "eval"
assert any("missing_sampled_logprob" in finding for finding in report.findings)


def test_token_ids_returned_as_null_land_on_the_logprobs_level(monkeypatch):
"""The HF router's shape: it accepts `return_token_ids` and answers `token_ids: null`. The level
must come from what came back, not from the request having been accepted."""
Expand Down