Skip to content

feat(verifiers): user_satisfaction_grading, the run graded from the user's side - #935

Open
anisha2102 wants to merge 2 commits into
mainfrom
anisha/user-satisfaction-grading
Open

anisha2102 wants to merge 2 commits into
mainfrom
anisha/user-satisfaction-grading

Conversation

@anisha2102

@anisha2102 anisha2102 commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

What and why

rate_user_satisfaction asks 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 adds user_satisfaction_grading, a step that grades the assistant the way its user would, from what the user saw, and keeps a log of it.

  • What the judge reads: the run as user_sim_judge reads it (the persona rebuilt and checked against prompt_sha256, and every check-in's user_sim_read input and answer), the rating step's lines, what the user read after the last check-in, and the run step's system_prompt. The last one means what the assistant could have known follows what it was told.
  • One call per run: the answer starts with two checklists. The first lists every action the assistant reported, with whether it needed an OK and had one. The second lists every question or request to the user, with whether the assistant could have handled it.
  • The incidents: each one goes at the check-in where the user could first see it, under one of six dimensions checked in order: 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.
  • The score: a 1-5 score computed from the log. Each incident costs by severity, a repeat of the same thing costs more, one put right costs half, and the end outcome costs extra. So weights can change without judging again. The grade's score is that as 0-1, and its rows weigh 0.
  • Recorded only: it never fails the task (fail_task_on_error defaults to false) and decides no verdict. Its load check makes it depend on the run's user_sim_judge, so a run the user sim spoiled is never graded, and on rate_user_satisfaction. The whole log is stored at log_object_url.

It reuses what's already here:

  • user_sim_judge's run loader and helpers;
  • model_call and judge_usage for the call and its record (judge_calls on the grade);
  • rubrics_verifier's failed-call record;
  • the verifier base for the grade, its entry and object-store writes;
  • rate_user_satisfaction.run_step_of and plays_built_in_user_sim for the load check.

user_sim_judge and 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.
  • The step type in registry.py and in episode/rules.py (UNAFFECTED).
  • A "Grading from the user's side" section in agent/user_sim.md.
  • Tests.

How it was tested

  • New tests: tst/unit/task_step/verifiers/test_user_satisfaction_grading.py, 13 tests. They cover:
    • the log and its score: a checklist adding an unapproved purchase the incidents missed, the severity rules, repeats, fixes, "could know" with and without the assistant's instructions, and the judge's ids kept across an added incident;
    • the prompt;
    • the step on a real always_on run (test_user_sim_judge's rig) through LiteLLM's mock;
    • a non-JSON answer asked again, a refused setting dropped, and a judge that never answers (a failed grade, never a failed task);
    • the skips, the load check, registration and the settings round trip.
  • Repo checks: make lint and the plugin-api check (no break) pass. After the final changes, tst/unit/task_step and tst/unit/task pass: 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.
  • Offline, on saved runs of four always-on tasks:
    • one call per run was stable across 3 repeats: 16 of 17 runs within 0.5 on the 1-5 scale, with repeats ranking the runs 0.98-0.99 alike;
    • on 37 rated runs it ranked the runs like the user sim's own rating (rank correlation 0.89, and 0.82 on the 20 runs not used to tune the prompt);
    • replaying 106 stored judge answers through this module gives the prototype's logs and scores exactly.
  • Live: 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.
    • All 8 completed, with scores within 0.15 of the offline ones and every quote found in its check-in. Each run cost $0.09-0.20.
    • It caught temperature=0, which LiteLLM refuses for Claude Opus. The step now sends no temperature, as rubrics_verifier's judge doesn't, and drops a setting a model refuses.

🤖 Generated with Claude Code

Confidence Score: 4/5 · The PR still needs the earlier answer-checking issue fixed before merging.RetriggerView in GreptileConfidence Score: 4/5

The PR still needs the earlier answer-checking issue fixed before merging.

FindingsFix All in CursorFindings

  1. P1 Incomplete answers get perfect grades ▶
Fix with agent prompt
### Issue 1
src/agent_env/task_step/task_steps/verifiers/user_satisfaction_grading.py:310-313
`_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.

Summary

Adds user_satisfaction_grading to record what went wrong from the user's side and compute a score from that log.

  • A user-side grade records what went wrong during a run.

Reviews (2) · Last reviewed commit: "fix(verifiers): user_satisfaction_gradin..." · Reviewed by Greptile

…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>
@anisha2102
anisha2102 requested a review from a team as a code owner November 26, 2026 02:35
Comment on lines +308 to +310
got = core.parse(reply.content)
if got is not None:
return got, None

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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.

Fix in Cursor Fix in Claude Code Fix in Codex

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 sarah-chitty-1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. 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, as UserSimJudge does. Without it, openenv/reward.py treats 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). Today entry["score"] holds the 1–5 number and overwrites the grade's 0–1 score in verifications[vid], so recorded_scores reports 4.85 next to 0.9 for the same run.
  2. A malformed answer can still score 5/5. answer_problems checks that the lists exist, but not the items in them. An incident with "severity": "Severe", a string turn, or an unknown dimension is dropped into problems, and the run scores 5.0. A wrong-type field (a list text, an int repeat_of) gets past the check, then crashes apply_run after the call is paid for. Please validate against RUN_SCHEMA with jsonschema (already a dependency), check every turn is a real check-in, and ask again on any error, so a score never comes from an answer with dropped incidents. Also add "strict": True to the response format, as rubrics_verifier does.
  3. The checklists don't always force the incident. In _check_actions, if the judge filed two overstepped incidents at the check-in with the purchase, the severe bump can land on the free one (could_know=False) while collapsed keeps the cheap knowable one. The unapproved purchase then costs 0.15. _check_asks can also lower a judge's major incident to minor. A test for each would help.
  4. A spoiled run can still be graded. verify never reads the user sim judge's user_sim_error. With no user_sim_judge in the task, its gate off, or an undecided verdict, the step grades the run anyway. Please skip unless the run's user_sim_judge entry has user_sim_error == "no", and require the judge step at load (today task_problems only checks the dependency when the step exists).

Reuse instead of copies

  • _ask re-implements rubrics_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 effort and max_thinking_tokens.

    Either subclass RubricsVerifierTaskStep with a whole-run output format spec (as UserSimJudge and TRAJECTORY_MISTAKES do), or move that call and its correction loop into a public judge_utils helper and use it here. Then _ask, core.parse and RESPONSE_FORMAT can go.

  • _find_run and the skip checks at the top of verify copy UserSimJudge's. One public "load the user sim run, or say why to skip" helper in user_sim_judge, used by both steps, would replace them. It would also replace the eight private imports (_load, _read_run, _cost, _usage, …).

  • _seeded duplicates task.substitute_seed_in_steps; _store_log duplicates 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 (like mistake_severity_weights), or record them in the entry.
  • Section letters: KNOWN_SECTIONS = "ACT" copies the user sim's section letters. Read them from user_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 collapsed can take the wrong incident's repeat_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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants