Repository navigation
fix(agent): flag invented amounts after a computation fails - #6818
Conversation
A run_python that failed on a missing pandas, then a table of invented dollar totals, shipped with no warning: table cells written as "$10,342.50" were never read as values, and the failed run said nothing about figures. Currency-marked cells are now judged like bare numbers, and a script or scratchpad query that fails before printing anything tells the model that nothing was computed. Failing shell commands, and scripts that printed results before crashing, still get no note.
|
Verdict: Approve with suggestions Two holes let a model show invented dollar figures with no warning: the figure check skipped table cells that start with a currency sign, and a script that crashed before printing anything didn't tell the model that nothing had been computed. This PR closes both, and the scope stays narrow. Shell commands and scripts that printed partial output still get no note, and amounts a script really printed still pass. One small gap remains: a negative amount written as Real-world evidenceN/A: no evidence bundle was produced for this run. The change is in the agent's internal grounding checks, with no CLI or API surface that this lane could exercise. The verdict rests on a static review and the PR's replayed-turn unit test. The PR's unchecked item, re-asking the orders.csv question on Gemma 4 E4B (NPU) in the desktop app, is still the real proof. It should be checked before or soon after merge, and 🔍 Technical detailsIssues 🟢 Negative currency amounts are still skipped ( This needs the capture-group indices in 🟢 String results only get the failure note, never the denial note ( Checked and fine
Strengths
|
amd#6831) After `run_python` failed on a missing pandas, Gemma 4 E4B on the NPU took the per-region `unit_price` sums from `analyze_data_file` and divided them itself: "North: 2322.16 / 141 = **16.40748**" (it is 16.4692), with East and West wrong too. No note appeared, because a plain decimal in prose was only checked beside a table or a dollar amount. Now, when a Python or query computation was asked for this turn and none succeeded, the answer's prose decimals are checked as well: a wrong quotient is named in the "not confirmed" note, while a correct division (South, 2429.44 / 125 = 19.43552) and numbers copied from tool output pass. Follows amd#6818. Eval category to watch: `gaia_honesty`. ## Test plan - [x] `pytest tests/unit/agents/test_grounding_unsourced_figures.py`: the exact Gemma answer is flagged for 16.40748, 18.08606 and 17.13675, not 19.43552 or the sums; the scripted-loop replay ships it with the note. Both failed before the fix. - [x] Same file: correct averages after the failed run, and the same answer after a successful run, get no note. - [x] `pytest tests/unit/agents tests/unit/test_file_tools.py` with Lemonade unreachable (one unrelated collection error: `amd-gaia` package metadata missing on this machine) - [ ] Replay in the app on Gemma NPU: average unit_price per region after a failed run_python
Asked for net revenue by region from a 500-row CSV, Gemma 4 E4B on the NPU ran
run_python, which failed onNo module named 'pandas'and printed nothing. It then answered with a confident table: North $10,342.50, West $10,678.98, and so on. The real totals are about four times that (North $45,043.62), and none of the answer's figures was in any tool output. Nothing warned the user, for two reasons:$10,342.50didn't count as a value and the whole table passed. Reading the CSV was not the hole: in a replay against a 500-row orders file, it didn't count as a source for these amounts. Now a currency sign in a cell is read like a bare number, so invented amounts get one correction and then the "not confirmed" note.run_python,execute_python_fileorquery_datacall that fails before printing anything is told plainly that nothing was computed: don't report figures, fix it and run it again, or tell the user what's needed. A failing shell command, and a script that printed results before it crashed, still get no note.Amounts a script did print still pass, in a table or in prose. This composes with #6771, which only changes the written-file check.
Eval categories to watch:
gaia_honesty, plusdata_analysisandfile_ops, where answers put computed amounts in tables.Not fixed here: the Python environment that
run_pythonuses has no pandas, though models reach for it all the time. That's why this run failed in the first place. Shipping pandas there, or saying in the tool description that it's missing, would prevent most of these failures. That needs its own change.🔍 Technical details
_PURE_VALUEingrounding.pynow accepts an optional$,US$,C$,A$,€,£or¥before the number._cell_value's existing rule still applies, so$5stays unjudged and$10,342.50is judged._with_computation_notekeepsCOMPUTATION_NOT_RUNfor denials. It addsCOMPUTATION_FAILEDwhen a script tool (SCRIPT_COMPUTATION_TOOLS, which leaves outrun_shell_command) fails and has nostdout,resultorrows.query_datareports errors as"Error: ..."strings, so the note is appended to the string.contentrow and a short paragraph indocs/sdk/core/agent-system.mdxdescribe both.Test plan
pytest tests/unit/agents/test_grounding_unsourced_figures.py: the NPU turn, replayed with a scripted model (summary, pandas-lessrun_pythonfailure, summary, read, invented table), now gets the failure note and the correction, and ships with the note naming10,342.50. 6 of the new tests failed against main before the fix.$table that a script printed all get no note.pytest tests/unit/agents tests/unit/test_file_tools.pywith Lemonade unreachable