One function

enrich_stock in SeraphimSerapis/tool-eval-bench

The author described this change as fix(TC-52): derive stock previous_close from change for fixture coherence (#55). It counts as a record because the check below fails on the code as it stood at 857d78f33 and passes on c09d0a84c, with nothing else changed between the two runs.

Fix saved2026-08-05
Sharing licenceMIT · LICENSE
Change size+9 1

What the code was meant to do, written into the code itself as a docstring

Add realistic metadata to stock price responses.

The change

11 def enrich_stock(payload: dict[str, Any]) -> dict[str, Any]:
22 """Add realistic metadata to stock price responses."""
33 price = payload.get("price", 0)
4+ # Derive previous close from the declared change when present so the
5+ # fixture's change/change_percent/previous_close fields stay coherent
6+ # (change = price - previous_close). Fall back to the historical
7+ # price - 1.23 offset for fixtures that don't declare a change field.
8+ change = payload.get("change")
9+ previous_close = (
10+ round(price - float(change), 2) if change is not None else round(price - 1.23, 2)
11+ )
412 return {
513 **payload,
614 "timestamp": "2026-03-20T16:00:00Z",
1220 "day_low": round(price * 0.988, 2),
1321 "week_52_high": round(price * 1.25, 2),
1422 "week_52_low": round(price * 0.72, 2),
15- "previous_close": round(price - 1.23, 2),
23+ "previous_close": previous_close,
1624 "after_hours": None,
1725 "request_id": "req_sp_8c1d4e2a",
1826 }

The check that tells the two apart

failpass·tests/test_planning_scenarios.py::TestTC52EdgeCases::test_stock_fixture_integrity

Check file tests/test_planning_scenarios.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it857d78f3317df6652a579a82dce391e56e285e6f
Broken version dated2026-08-05
Moduletool_eval_bench.evals.noise
Units changedenrich_stock
Fingerprint6efa67e7d18540c6
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in SeraphimSerapis/tool-eval-bench