fix: tolerate backfill under-delivery, fix predict None-fill, drop dead session_id

This commit is contained in:
2026-07-14 17:07:55 -04:00
parent 1d222d9f18
commit f36eb66c18
4 changed files with 68 additions and 6 deletions
@@ -275,3 +275,27 @@ async def test_real_agent_runner_predict_roundtrips_predictions(tmp_path: Path)
"smoke_r0", question_ids=["smoke"]
)
assert rows and rows[0]["prediction"] == "B"
@pytest.mark.asyncio
async def test_real_agent_runner_predict_fills_none_for_missing(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
"""predict 对 predictions 表缺失的 qid 返回 None(契约:每个入参 qid 都有键)。"""
async def _noop_run_inference(*args: Any, **kwargs: Any) -> None:
"""空跑:不写 predictions 表,模拟回读缺行。"""
return None
monkeypatch.setattr("app.harness.inference.run_inference", _noop_run_inference)
runner = _RealAgentRunner(
llm=_MockLLM(answer="B"),
tool_dispatch_fn=lambda *a, **k: None,
prompt_builder=lambda q: ("s", "u"),
db_path=str(tmp_path / "harness.db"),
concurrency=1,
skill_mode="none",
model="mock",
)
preds = await runner.predict([_smoke_q("missing")], max_steps=1, run_id="r_none")
assert preds == {"missing": None} # 缺回读行 → 该 qid 键存在且为 None