Repository navigation
feat(verifiers): user_satisfaction_grading, the run graded from the user's side - #935
anisha2102 wants to merge 2 commits into
Conversation
…ser's side A recorded-only step that grades the assistant the way its user would, from what the user saw: one judge call reads the run as user_sim_judge does, the rating's lines and the run step's system prompt, lists every action and every ask the assistant made, and logs each incident at the check-in where the user could first see it. Its 1-5 score is computed from that log. It never fails the task and decides no verdict; it runs after the user sim judge and the rating. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| got = core.parse(reply.content) | ||
| if got is not None: | ||
| return got, None |
There was a problem hiding this comment.
Incomplete answers get perfect grades
_ask accepts any JSON object without checking RUN_SCHEMA. If the judge returns {} or omits end, the step stops retrying and can award 5/5: missing incidents and outcomes cost nothing, and the missing outcome is only logged as a problem.
Validate the required fields and their types before accepting the answer. Retry invalid answers and fail the grade if none is usable.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agent_env/task_step/task_steps/verifiers/user_satisfaction_grading.py
Line: 308-310
Comment:
**Incomplete answers get perfect grades**
`_ask` accepts any JSON object without checking `RUN_SCHEMA`. If the judge returns `{}` or omits `end`, the step stops retrying and can award 5/5: missing incidents and outcomes cost nothing, and the missing outcome is only logged as a problem.
Validate the required fields and their types before accepting the answer. Retry invalid answers and fail the grade if none is usable.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.There was a problem hiding this comment.
Fixed in 3241d63: user_satisfaction_grading_core.answer_problems checks the answer has every part of RUN_SCHEMA as a list of objects, and an end whose outcome is one of OUTCOMES. _ask asks again for an answer that fails it, and after MAX_ATTEMPTS the grade fails with no score, as for a non-JSON answer. So {} or a missing end never scores 5. Tests: test_an_answer_that_isn_t_a_whole_log_is_named, and the retry test now gets {} before a whole log.
…swer, never charges a free incident, and logs the final read - An answer missing a part of RUN_SCHEMA or an end outcome isn't a log: it's asked again, and fails the grade after MAX_ATTEMPTS, rather than scoring the missing parts as nothing wrong (answer_problems). - Merging a check-in's incidents in one dimension keeps the worst one the assistant could have known about, with its own could_know, so a free incident never makes a knowable one cost more. No stored log's score changes. - What the user read after the last check-in is one more check-in (with_final_read), so an incident or a fix there has a check-in and its quote is checked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sarah-chitty-1
left a comment
There was a problem hiding this comment.
Nice idea, and the split into a pure scoring core plus a step file matches how user_sim_judge is built. Before it lands in the shared framework, there are four bugs to fix and some restructuring so it reuses the framework's judge code instead of copying it.
Bugs
- Is this meant to count toward the task's score, or be recorded only? The PR (and #54) say recorded only. My understanding was that it should feed into the score, so worth a double check. Either way, two fixes:
- If recorded only, set
can_be_reward = False, asUserSimJudgedoes. Without it,openenv/reward.pytreats this step as a reward candidate. In a task with one real scorer, it then refuses with "name the one that is its reward". - If it should count, feed it into the task's aggregate step rather than making it a second main score. #54 would then need its "read by no aggregate" rule removed.
- Both ways: rename the 1–5 key (e.g.
score_1_5). Todayentry["score"]holds the 1–5 number and overwrites the grade's 0–1scoreinverifications[vid], sorecorded_scoresreports 4.85 next to 0.9 for the same run.
- If recorded only, set
- A malformed answer can still score 5/5.
answer_problemschecks that the lists exist, but not the items in them. An incident with"severity": "Severe", a stringturn, or an unknown dimension is dropped intoproblems, and the run scores 5.0. A wrong-type field (a listtext, an intrepeat_of) gets past the check, then crashesapply_runafter the call is paid for. Please validate againstRUN_SCHEMAwithjsonschema(already a dependency), check everyturnis a real check-in, and ask again on any error, so a score never comes from an answer with dropped incidents. Also add"strict": Trueto the response format, asrubrics_verifierdoes. - The checklists don't always force the incident. In
_check_actions, if the judge filed twooversteppedincidents at the check-in with the purchase, the severe bump can land on the free one (could_know=False) whilecollapsedkeeps the cheap knowable one. The unapproved purchase then costs 0.15._check_askscan also lower a judge's major incident to minor. A test for each would help. - A spoiled run can still be graded.
verifynever reads the user sim judge'suser_sim_error. With nouser_sim_judgein the task, its gate off, or an undecided verdict, the step grades the run anyway. Please skip unless the run'suser_sim_judgeentry hasuser_sim_error == "no", and require the judge step at load (todaytask_problemsonly checks the dependency when the step exists).
Reuse instead of copies
-
_askre-implementsrubrics_verifier's direct call, its retry loop and the call record. It's weaker:- it re-sends the same prompt without saying what was wrong;
- it retries setup errors three times;
- it ignores the judge's
effortandmax_thinking_tokens.
Either subclass
RubricsVerifierTaskStepwith a whole-run output format spec (asUserSimJudgeandTRAJECTORY_MISTAKESdo), or move that call and its correction loop into a publicjudge_utilshelper and use it here. Then_ask,core.parseandRESPONSE_FORMATcan go. -
_find_runand the skip checks at the top ofverifycopyUserSimJudge's. One public "load the user sim run, or say why to skip" helper inuser_sim_judge, used by both steps, would replace them. It would also replace the eight private imports (_load,_read_run,_cost,_usage, …). -
_seededduplicatestask.substitute_seed_in_steps;_store_logduplicates the base class's object-store handling.
Smaller
- Weights: the scoring weights (
COST,REPEAT_STEP,RECOVERED,CAP,OUTCOME_COST) are hard-coded with no version recorded. Make them a step setting (likemistake_severity_weights), or record them in the entry. - Section letters:
KNOWN_SECTIONS = "ACT"copies the user sim's section letters. Read them fromuser_sim_versions.SECTIONS. RESULT:lines: the prompt's rule about "RESULT: DONE" lines is one harness's convention. Make it a setting, or drop it from the shared prompt.- Repeats: a repeat across dimensions isn't enforced, and
collapsedcan take the wrong incident'srepeat_of. - One call per run: a long multi-day run can hit the 16k output cap. A truncated answer then fails twice more at full price.
- Tests: please add tests for bugs 1–4 and a truncated answer.
What and why
rate_user_satisfactionasks the user sim for one 1-5 rating once the run is over. That says how the run felt, but not what went wrong, when or how often, and two runs that both get a 1 look the same. This addsuser_satisfaction_grading, a step that grades the assistant the way its user would, from what the user saw, and keeps a log of it.user_sim_judgereads it (the persona rebuilt and checked againstprompt_sha256, and every check-in'suser_sim_readinput and answer), the rating step's lines, what the user read after the last check-in, and the run step'ssystem_prompt. The last one means what the assistant could have known follows what it was told.overstepped,put_it_on_me,ignored_me,got_it_wrong,left_hanging,too_much. Then comes the end outcome. The code holds the incidents to the two checklists, so an unapproved purchase or a needless hand-back can't be skipped.fail_task_on_errordefaults to false) and decides no verdict. Its load check makes it depend on the run'suser_sim_judge, so a run the user sim spoiled is never graded, and onrate_user_satisfaction. The whole log is stored atlog_object_url.It reuses what's already here:
user_sim_judge's run loader and helpers;model_callandjudge_usagefor the call and its record (judge_callson the grade);rubrics_verifier's failed-call record;rate_user_satisfaction.run_step_ofandplays_built_in_user_simfor the load check.user_sim_judgeand its prompt are unchanged.Files:
verifiers/user_satisfaction_grading_core.py: the prompt, the answer's schema, the log, the checklists and the score. No model call and no I/O.verifiers/user_satisfaction_grading.py: the step.registry.pyand inepisode/rules.py(UNAFFECTED).agent/user_sim.md.How it was tested
tst/unit/task_step/verifiers/test_user_satisfaction_grading.py, 13 tests. They cover:always_onrun (test_user_sim_judge's rig) through LiteLLM's mock;make lintand theplugin-apicheck (no break) pass. After the final changes,tst/unit/task_stepandtst/unit/taskpass: 5,102 tests. Earlier, before the rename and the two final fixes, the full unit suite had 19,770 passing and 6 failing, none of them in code this change touches: 4 pass when run alone, and 2 need a writable/app.agent-env task run --start-step <this step> --context-json <saved context>on 8 saved runs of three tasks, with local stores, the local runner and a real Opus judge.temperature=0, which LiteLLM refuses for Claude Opus. The step now sends no temperature, asrubrics_verifier's judge doesn't, and drops a setting a model refuses.🤖 Generated with Claude Code
The PR still needs the earlier answer-checking issue fixed before merging.
Fix with agent prompt
Summary
Adds
user_satisfaction_gradingto record what went wrong from the user's side and compute a score from that log.Reviews (2) · Last reviewed commit: "fix(verifiers): user_satisfaction_gradin..." · Reviewed by Greptile