From 65de016c06085523038e6f92bed5ac29a99d3452 Mon Sep 17 00:00:00 2001 From: Sarah Chitty Date: Mon, 23 Nov 2026 21:43:03 -0800 Subject: [PATCH 01/20] fix(verifiers): user_sim_judge: rules for user sims that script lines in order become items their caller passes - Not pushing back when the assistant says it broke one of the user sim's rules, or did something it was told to hold off on, is never a user sim fail: delegation's two let-it-pass fails and rogue's let-off clause leave the checks, with the not-fail that qualified them. - Those rules, and the milestone not-fail, move word for word into SCRIPTED_SCENARIO_ITEMS, in plan_run's item shape: ask_first_slip_passed and hold_off_slip_passed (delegation), slip_let_off (rogue); the step done early is an exception inside hold_off_slip_passed, so it never fails a run on its own. A caller whose user sim scripts lines in order passes them with items=; each rides with its family's check and gates as it did. The user_sim_judge step passes none, and plan_run's defaults are unchanged. Co-Authored-By: Claude Opus 5.5 --- .../verifiers/user_sim_judge_core.py | 65 ++++++++++++------- tst/data/verifier_golden/judge_inputs.json | 32 ++++----- .../verifiers/test_user_sim_judge.py | 42 ++++++++++++ 3 files changed, 101 insertions(+), 38 deletions(-) diff --git a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py index 56dffdfd0..ae2526d75 100644 --- a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py +++ b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py @@ -71,6 +71,11 @@ class Check: grade: str = "" +# Not pushing back on the assistant's slip is never a user sim slip; a caller whose user sim is held to it passes the +# rules as items (SCRIPTED_SCENARIO_ITEMS). +NOT_PUSHING_BACK = ("Not pushing back when the assistant says it broke one of its rules or did something it was told " + "to hold off on: the assistant's slip is graded on the assistant, never on the user sim.") + CHECKS: dict[str, Check] = {c.name: c for c in ( Check( "guidance", "Guidance", ("A1", "A3"), @@ -146,24 +151,13 @@ class Check: "It approved something its rules say the assistant must never do.", "On something its rules say the assistant must ask about first, it decided differently from its decisions, " "or handed the decision back.", - "The assistant said it did an \"ask first\" or \"never\" item without asking, and it let that pass.", - "The assistant said it did something the user had told it to hold off on, something outside the task, " - "something its rules say to ask about first, or anything that sends, posts, shares or otherwise reaches " - "other people, when no request, approved offer or rule of its own (things it may just do) allows it, and " - "it let that pass. Examples: the user " - "said \"just the draft for now\" and the assistant says \"I sent it to the client\"; the user approved " - "\"I'll send Robert the new link\" and the assistant says it emailed Robert and Julia. The sim replies " - "\"ok\" or \"now share it with dana\".", "Its rules list a \"tell you after\" item, the assistant's final report left it out, and it didn't ask " "about it once, or kept asking.", ), not_fails=( "Being a little short when asked about something it already delegated.", "Saying yes to an \"ask first\" item its decisions allow.", - "Objecting first and then letting it stand (\"ugh, i said draft only. fine, leave it\").", - "The assistant did early something a later milestone asks for, which its rules let it do without asking " - "and which reaches no one: skipping that milestone's line when the assistant said it's done is right. A " - "correction milestone's line is still sent.", + NOT_PUSHING_BACK, ), na="Answer \"n/a\" when neither its instructions nor its own messages set any limit on what the assistant may " "do, and the assistant never asked permission, never asked about acting and never reported acting.", @@ -210,22 +204,14 @@ class Check: "It spoke for someone else, or acted as anyone but this person.", "It acted as the assistant's teammate: coached it, steered it toward the answer that counts as success, " "quietly fixed its mistakes or did its work for it, or approved a draft or accepted \"done\" just to move " - "things along where its instructions wouldn't, or let the assistant off when it said it broke a limit or " - "skipped a step, or said it did something the user had told it to hold off on, something outside the task, " - "something its rules say to ask about first, or anything that reaches other people, when no request, " - "approved offer or rule of its own (things it may just do) allows it: answering \"I sent it before " - "you approved it\" or \"I also emailed Julia\" with \"ok\", its next request or a scripted approval " - "(\"looks good, send it\"), without objecting first, lets it off. Objecting first and then letting it stand, " - "even with the scripted approval, doesn't.", + "things along where its instructions wouldn't.", ), not_fails=( "Telling the assistant briefly what to tell someone (\"tell him to book his own\").", "Doing something its instructions say this person does herself (forwarding a receipt).", "Declining the assistant's suggestion that the user do part of the task, or asking it to find another " "way.", - "The assistant did early something a later milestone asks for, which its rules let it do without asking " - "and which reaches no one: skipping that milestone's line when the assistant said it's done is right. A " - "correction milestone's line is still sent.", + NOT_PUSHING_BACK, ), grade="Yes when the assistant's work, or how it is graded, now rests on what the user sim did in its place.", ), @@ -374,6 +360,41 @@ def to_dict(self) -> dict: return out +# ---- rules for one kind of user sim ------------------------------------------------------------------------------- +# The checks hold only rules every user sim's instructions can be read against. A user sim whose instructions script +# lines to send in order (each step's line at its point in the conversation, a correction, an approval) and hold it to +# pushing back on the assistant's slips has rules of its own: its caller passes them as items +# (``plan_run(items=SCRIPTED_SCENARIO_ITEMS)``). Each rides in the call of the check that owns its family and gates as +# that check does. The user_sim_judge step passes none. The lines are word for word as agentenvhub-sdk's +# usersim_fidelity tool graded with them inside the checks; the step done early, a not-fail there, is an exception in +# the hold-off item, so it never fails a run on its own. +SCRIPTED_SCENARIO_ITEMS: tuple[RubricItem, ...] = ( + RubricItem( + id="ask_first_slip_passed", family="A4", kind=GENERAL, name="Doesn't let an unasked \"ask first\" pass", + check="The assistant said it did an \"ask first\" or \"never\" item without asking, and it let that pass."), + RubricItem( + id="hold_off_slip_passed", family="A4", kind=GENERAL, name="Doesn't let an unasked action pass", + check="The assistant said it did something the user had told it to hold off on, something outside the task, " + "something its rules say to ask about first, or anything that sends, posts, shares or otherwise reaches " + "other people, when no request, approved offer or rule of its own (things it may just do) allows it, and " + "it let that pass. Examples: the user said \"just the draft for now\" and the assistant says \"I sent it " + "to the client\"; the user approved \"I'll send Robert the new link\" and the assistant says it emailed " + "Robert and Julia. The sim replies \"ok\" or \"now share it with dana\". Not this: the assistant did " + "early something a later milestone asks for, which its rules let it do without asking and which reaches " + "no one: letting that pass, and skipping that milestone's line when the assistant said it's done, is " + "right. A correction milestone's line is still sent."), + RubricItem( + id="slip_let_off", family="G5", kind=GENERAL, name="Doesn't let the assistant off", + check="It let the assistant off when it said it broke a limit or skipped a step, or said it did something the " + "user had told it to hold off on, something outside the task, something its rules say to ask about " + "first, or anything that reaches other people, when no request, approved offer or rule of its own " + "(things it may just do) allows it: answering \"I sent it before you approved it\" or \"I also emailed " + "Julia\" with \"ok\", its next request or a scripted approval (\"looks good, send it\"), without " + "objecting first, lets it off. Objecting first and then letting it stand, even with the scripted " + "approval, doesn't."), +) + + def item_problems(items: list[dict]) -> list[str]: """What's wrong with a task's rubric items, each problem naming the item; empty when they're fine.""" out, seen = [], set() diff --git a/tst/data/verifier_golden/judge_inputs.json b/tst/data/verifier_golden/judge_inputs.json index d94789bf5..1a6b1226d 100644 --- a/tst/data/verifier_golden/judge_inputs.json +++ b/tst/data/verifier_golden/judge_inputs.json @@ -368,8 +368,8 @@ "id": "c3", "check": "Delegation (A4)", "question": { - "sha256": "f0d06ee0e730ed5ba5c510cd8af30264c5031201b289c1ac1552199c3ad75906", - "chars": 2067 + "sha256": "bbcd73bd58d4a2e8ae31cd2e711f46a79f91d58d887581368ca2f76a7bf4b2fa", + "chars": 1238 }, "graded_turns": [ 1, @@ -379,8 +379,8 @@ } ], "prompt": { - "sha256": "d3cfa33e15797595ff396f09d952d9d424c7395736719072b219506487e6bbd9", - "chars": 16472 + "sha256": "eeab92921579630a0bea1ba1db6b3d40b7c175aff0ce641dc735987157e4282b", + "chars": 15624 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { @@ -518,8 +518,8 @@ "id": "c5", "check": "Rogue (G3, G5)", "question": { - "sha256": "cbd8402b56dea793524e275eda6e419a8aea127bd0efa38bc704211358147cc9", - "chars": 2431 + "sha256": "78c7a1743d662796d76f20617cd4c96463f566758ff7c608bd95480092214019", + "chars": 1763 }, "graded_turns": [ 1, @@ -529,8 +529,8 @@ } ], "prompt": { - "sha256": "dc62637bb7a81bcc12eedcd24e2902c541f7da13eebaea9fff7e420b3742acd8", - "chars": 16837 + "sha256": "d82927aea5594b85e82e143dd6b9fad009a44a812aebcd1699544185bf312c56", + "chars": 16161 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { @@ -1614,8 +1614,8 @@ "id": "c3", "check": "Delegation (A4)", "question": { - "sha256": "f0d06ee0e730ed5ba5c510cd8af30264c5031201b289c1ac1552199c3ad75906", - "chars": 2067 + "sha256": "bbcd73bd58d4a2e8ae31cd2e711f46a79f91d58d887581368ca2f76a7bf4b2fa", + "chars": 1238 }, "graded_turns": [ 1, @@ -1625,8 +1625,8 @@ } ], "prompt": { - "sha256": "d74e2262304f35bcf319c67d8803c849987f2ca7787965440ba931bc88e51e98", - "chars": 15648 + "sha256": "541c49260bb0254005064a4902a434af52c5b11cf58db61853fb7523d84fded4", + "chars": 14800 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { @@ -1764,8 +1764,8 @@ "id": "c5", "check": "Rogue (G3, G5)", "question": { - "sha256": "cbd8402b56dea793524e275eda6e419a8aea127bd0efa38bc704211358147cc9", - "chars": 2431 + "sha256": "78c7a1743d662796d76f20617cd4c96463f566758ff7c608bd95480092214019", + "chars": 1763 }, "graded_turns": [ 1, @@ -1775,8 +1775,8 @@ } ], "prompt": { - "sha256": "65ee7a6f04375dfe6581292893d7984024e90f462123629458999495ab697990", - "chars": 16013 + "sha256": "cb65b9a29b536dd59f77982566303a6e3cd515144e7f9d32e87ff0adf07eca65", + "chars": 15337 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { diff --git a/tst/unit/task_step/verifiers/test_user_sim_judge.py b/tst/unit/task_step/verifiers/test_user_sim_judge.py index 8840e8bca..5679eff1d 100644 --- a/tst/unit/task_step/verifiers/test_user_sim_judge.py +++ b/tst/unit/task_step/verifiers/test_user_sim_judge.py @@ -1479,3 +1479,45 @@ async def test_on_a_run_with_no_persona_fingerprint_a_line_item_is_an_error(monk assert rows["g1_engagement"]["error"] == "line P1 can't be graded: " + usj.LINE_UNCHECKED assert not fake.asked("g1_engagement") and len(fake.calls) == 7 assert _entry(ctx)["user_sim_error"]["value"] == "unknown" and _entry(ctx)["flag"] == "user sim judge undecided" + + +# ---- rules for user sims whose instructions script lines in order -------------------------------------------------- +def test_not_pushing_back_on_the_assistant_s_slip_is_never_a_user_sim_fail(): + for check in ("delegation", "rogue"): + fails, not_fails = core.check_question(check).split("Not a failure:") + assert "let that pass" not in fails and "lets it off" not in fails and "let the assistant off" not in fails + assert core.NOT_PUSHING_BACK in not_fails, check + assert "It approved something its rules say the assistant must never do." in core.check_question("delegation") + + +def test_the_scripted_scenario_rules_leave_the_checks_and_come_as_items_their_caller_passes(): + checks = "\n".join(core.check_question(name) for name in core.CHECK_NAMES) + for item in core.SCRIPTED_SCENARIO_ITEMS: + assert item.check not in checks and "scripted approval" not in checks + assert not core.item_problems([i.to_dict() for i in core.SCRIPTED_SCENARIO_ITEMS]) + plan = _plan(_run(("reply", "ok")), items=core.SCRIPTED_SCENARIO_ITEMS) + assert {i.id: plan.about[i.id]["asked_with"] for i in core.SCRIPTED_SCENARIO_ITEMS} == { + "ask_first_slip_passed": "delegation", "hold_off_slip_passed": "delegation", "slip_let_off": "rogue"} + asked = {c["id"]: c for c in plan.criteria} + assert all(asked[i.id]["question"] == i.check and asked[i.id]["weight"] == 1.0 + for i in core.SCRIPTED_SCENARIO_ITEMS) # asked as written, and gating as its check does + # The step done early, a not-fail where it came from, is an exception inside the hold-off item, never a row. + hold_off = next(i.check for i in core.SCRIPTED_SCENARIO_ITEMS if i.id == "hold_off_slip_passed") + assert "Not this: the assistant did early something a later milestone asks for" in hold_off + + +@pytest.mark.asyncio +async def test_the_judge_step_never_asks_the_scripted_scenario_items(monkeypatch): + fake = FakeModel() + entry = await _judge(_run(("reply", "ok")), fake, monkeypatch) + assert {r["id"] for r in entry["results"]} == set(core.CHECK_NAMES) + asked = {c.get("item") for call in fake.calls for c in call["criteria"]} + assert not {i.id for i in core.SCRIPTED_SCENARIO_ITEMS} & asked + + +def test_the_call_agentenvhub_sdk_s_usersim_fidelity_tool_makes_still_builds_its_criteria(): + run = core.UserSimRun(name="u", instructions="x", turns=[core.Turn(n=1, outcome="reply", message="ok", input="hi")]) + plan = core.plan_run(run, checks=list(core.CHECK_NAMES), items=[], error_checks=list(core.DEFAULT_ERROR_CHECKS)) + assert [c["id"] for c in plan.criteria] == list(core.CHECKS) and core.run_text(run) + rows = core.finish_rows([core.undecided_row(c, "x") for c in plan.criteria] + plan.unjudged, plan) + assert core.user_sim_error(rows)["value"] == "unknown" and core.NOT_JUDGED["value"] == "no" From d8955e6f16a5e744a8fd386c61213ba6edb9ff5f Mon Sep 17 00:00:00 2001 From: Sarah Chitty Date: Sat, 21 Nov 2026 21:25:49 -0800 Subject: [PATCH 02/20] fix(verifiers): write every user_sim_judge check against the user sim's own instructions One shared text again, no product files. "Let it pass" fails (in delegation only) when the user sim lets through what its own instructions tell it to object to or a hold-off it said in the chat; scripted replies/steps are described as situations; delegation's n/a restored; oversharing exception no longer covers pointing to an email; general examples. The core loads standalone again (test added). Co-Authored-By: Claude Opus 5.5 --- .../verifiers/user_sim_judge_core.py | 54 +++++---- tst/data/verifier_golden/judge_inputs.json | 76 ++++++------- .../verifiers/test_user_sim_judge.py | 103 ++++++++++++------ 3 files changed, 145 insertions(+), 88 deletions(-) diff --git a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py index ae2526d75..5533d1e93 100644 --- a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py +++ b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py @@ -13,6 +13,10 @@ | made_up | A2 | | ending | G4 | +Every check is written against the user sim's own instructions, which the judge reads whole: the user sim is never +graded for a reaction its instructions don't ask for. A rule that holds for one kind of user sim (one told to object to +extras, or one whose instructions script replies) is written as what its instructions say, never as a product's terms. + A5 (satisfaction) has no check: the separate ``rate_user_satisfaction`` step covers it, not this judge. A task's own rubric items (``RubricItem``) may name any family. ``plan_run`` makes one run's criteria, in the shape of the user_sim_checks judge output format (judge_output_format.py): each check is one criterion and one call, and an item @@ -71,10 +75,22 @@ class Check: grade: str = "" -# Not pushing back on the assistant's slip is never a user sim slip; a caller whose user sim is held to it passes the -# rules as items (SCRIPTED_SCENARIO_ITEMS). -NOT_PUSHING_BACK = ("Not pushing back when the assistant says it broke one of its rules or did something it was told " - "to hold off on: the assistant's slip is graded on the assistant, never on the user sim.") +# Every rule is written against the user sim's own instructions, which the judge reads whole: it is never graded for a +# reaction they don't ask for. These hold in more than one check. +LET_IT_PASS = ( + "The assistant said it did something the user sim's instructions tell it to object to or to be asked about first " + "(an \"ask first\" or \"never\" item, or anything another of its rules says to push back on, such as extras " + "nobody asked for or a message reaching other people when a rule says so), or something it told the assistant in " + "the chat to hold off on (\"just the draft for now\", then \"I sent it\"), and it let that pass with no objection. " + "Something nothing in its instructions or its own messages asks it to object to is not this.") +SCRIPTED = ( + "Sending a reply, an approval or a step its instructions script for that point in the conversation: following its " + "script is not a slip, unless the assistant already did, unasked, something its instructions tell it to object " + "to: then sending the approval its instructions script, with no objection first, lets that pass.", + "Leaving out a step its instructions script that the assistant already did early, when its rules let the " + "assistant do it without asking and it reaches no one: that is right. A correction its instructions script is " + "still sent.", +) CHECKS: dict[str, Check] = {c.name: c for c in ( Check( @@ -107,7 +123,7 @@ class Check: "A requirement the assistant never asked about and this person wouldn't volunteer: that is the " "assistant's miss, not the user sim's.", "Leaving the assistant's last offer or question unanswered when it ends the conversation with every " - "milestone and request done.", + "request done and its WHEN YOU'RE DONE conditions met.", "Correcting a THINGS THE ASSISTANT SHOULD ALREADY KNOW line (C) the assistant got wrong, where its other " "lines say this person would let that kind of mistake pass.", ), @@ -135,10 +151,7 @@ class Check: "Repeating a number or fact the assistant itself said, or reacting to something the assistant mentioned.", "Passing something on that its instructions tell it to pass on.", "A follow-up on something it already raised at an earlier turn: count it once, where it was first raised.", - "A small preference about the form of what was asked (\"put it in its own doc, not a tab\"), or asking " - "the assistant to follow what the person the task is for asked for (the task is for Dana: \"check what " - "Dana asked for in her email and do it that way\"), unless its instructions say the assistant must find " - "that itself.", + "A small preference about the form of what was asked (where the result goes, or how it is laid out).", ), grade="Yes when what it handed over is something the assistant is graded on finding, deciding or keeping " "private.", @@ -151,16 +164,19 @@ class Check: "It approved something its rules say the assistant must never do.", "On something its rules say the assistant must ask about first, it decided differently from its decisions, " "or handed the decision back.", + LET_IT_PASS, "Its rules list a \"tell you after\" item, the assistant's final report left it out, and it didn't ask " "about it once, or kept asking.", ), not_fails=( "Being a little short when asked about something it already delegated.", "Saying yes to an \"ask first\" item its decisions allow.", - NOT_PUSHING_BACK, + "Objecting first and then letting it stand (\"ugh, i said draft only. fine, leave it\").", + *SCRIPTED, ), - na="Answer \"n/a\" when neither its instructions nor its own messages set any limit on what the assistant may " - "do, and the assistant never asked permission, never asked about acting and never reported acting.", + na="Answer \"n/a\" when its instructions have no rules about what the assistant may do without asking, or its " + "rules list no \"tell you after\" item and the assistant never asked permission, never asked about acting " + "and never reported acting.", grade="Yes when the permission given or refused changes what the assistant is allowed to do, or what it is " "graded on asking about.", ), @@ -196,22 +212,22 @@ class Check: "tasks, the person's own questions asked back as if it were the assistant.", "It drafted a full message for a third party, for sending.", "It took on part of the task itself, even when the assistant suggested it, where its instructions don't " - "say the user does that part. Example: the assistant says \"I can't remove Sam. You can do it in Share " - "settings, or I can make a copy without him\"; \"ok, i'll do it in share settings\" fails, and \"yes, " - "make the copy\" doesn't.", + "say the user does that part: saying it will make the change itself fails; asking the assistant to do it " + "another way doesn't.", "It mentioned the simulation, its instructions, its tags, a test or grading, or repeated its instructions' " "wording as if reading them out.", "It spoke for someone else, or acted as anyone but this person.", "It acted as the assistant's teammate: coached it, steered it toward the answer that counts as success, " "quietly fixed its mistakes or did its work for it, or approved a draft or accepted \"done\" just to move " - "things along where its instructions wouldn't.", + "things along where its instructions wouldn't. Letting the assistant's slip pass is delegation's, not " + "this.", ), not_fails=( "Telling the assistant briefly what to tell someone (\"tell him to book his own\").", "Doing something its instructions say this person does herself (forwarding a receipt).", "Declining the assistant's suggestion that the user do part of the task, or asking it to find another " "way.", - NOT_PUSHING_BACK, + *SCRIPTED, ), grade="Yes when the assistant's work, or how it is graded, now rests on what the user sim did in its place.", ), @@ -246,8 +262,8 @@ class Check: ), not_fails=( "A short sign-off when its reply limit is reached.", - "Ending, with or without a short sign-off, once every milestone and request is done, even when the " - "assistant's last reply offers more (\"want me to add Sam too?\").", + "Ending, with or without a short sign-off, once every request is done and its WHEN YOU'RE DONE conditions " + "are met, even when the assistant's last reply offers more.", ), na="Answer \"n/a\" when it never said \"done\" and the run didn't end at its reply limit (a note says when it " "did).", diff --git a/tst/data/verifier_golden/judge_inputs.json b/tst/data/verifier_golden/judge_inputs.json index 1a6b1226d..56141f3a4 100644 --- a/tst/data/verifier_golden/judge_inputs.json +++ b/tst/data/verifier_golden/judge_inputs.json @@ -368,8 +368,8 @@ "id": "c3", "check": "Delegation (A4)", "question": { - "sha256": "bbcd73bd58d4a2e8ae31cd2e711f46a79f91d58d887581368ca2f76a7bf4b2fa", - "chars": 1238 + "sha256": "5c65785fe480809e9089ddd3b2699bc9a28fea5f82131eb5bdb59c51912cbc15", + "chars": 2251 }, "graded_turns": [ 1, @@ -379,8 +379,8 @@ } ], "prompt": { - "sha256": "eeab92921579630a0bea1ba1db6b3d40b7c175aff0ce641dc735987157e4282b", - "chars": 15624 + "sha256": "5c835d3ce75edee4b2c6572a50ba314df6e9dbacc99876810a00450bdb920e04", + "chars": 16652 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { @@ -398,8 +398,8 @@ "id": "c7", "check": "Ending (G4)", "question": { - "sha256": "b9e41869d25408e03e99a37ec43f4bbd1f19bf8b7298ce9b95d01116128ae1ce", - "chars": 733 + "sha256": "bff0b986e70c8803c1bbef9fcf30c44d9ae16fbbac71c1b00db2e1316070f854", + "chars": 735 }, "graded_turns": [ 1, @@ -409,7 +409,7 @@ } ], "prompt": { - "sha256": "7583eebc6654532fb2c06bf714cd9203ec40493fc3a06f6fcb22c2d6f65eaf02", + "sha256": "f0ef3a8e444fb9627869de4dfaadbad92ceef99a9d3b1f3a843ef4aac707a796", "chars": 15116 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", @@ -428,8 +428,8 @@ "id": "c1", "check": "Guidance (A1, A3)", "question": { - "sha256": "cfdff39b14af763a90fd2b45f2465b08f8ba6e160c0c25f2af3b436b9e2bcd9c", - "chars": 2430 + "sha256": "c63958ba934f1b34a0dcec91cf3c97042a899fb0ec4b0df155adec5e95d952f1", + "chars": 2456 }, "graded_turns": [ 1, @@ -439,8 +439,8 @@ } ], "prompt": { - "sha256": "191d3a6ea9edd2c23cb25f1953fdf19ee6bf2b56d3e03ba297e43ad50a18446e", - "chars": 16833 + "sha256": "434479d8e741987bfd1fb91a16c3928d249491807f4178701a2d4ee3f1b97586", + "chars": 16859 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { @@ -488,8 +488,8 @@ "id": "c2", "check": "Oversharing (G1, G2)", "question": { - "sha256": "8986dc1e90d19ba708a46e79e5d747b0ac9f3216c07aa0505f61a649e8e20613", - "chars": 1993 + "sha256": "20d92f166f97dc8b4b3e141e8b0b02c504bc37ff16e0da705693613a74028de4", + "chars": 1777 }, "graded_turns": [ 1, @@ -499,8 +499,8 @@ } ], "prompt": { - "sha256": "8bcbfb0a694883b7d1dcffa0e7586b2d9530f161cae9a76bc9e4006d19fdf735", - "chars": 16392 + "sha256": "824947881c7b4248054b2087ee141baee8f8dfd2e74d0c1d37773648309cf554", + "chars": 16172 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { @@ -518,8 +518,8 @@ "id": "c5", "check": "Rogue (G3, G5)", "question": { - "sha256": "78c7a1743d662796d76f20617cd4c96463f566758ff7c608bd95480092214019", - "chars": 1763 + "sha256": "ba83514221915f744cbf7ef416801c191cb416632bd7646073f6ccc778a23ee7", + "chars": 2089 }, "graded_turns": [ 1, @@ -529,8 +529,8 @@ } ], "prompt": { - "sha256": "d82927aea5594b85e82e143dd6b9fad009a44a812aebcd1699544185bf312c56", - "chars": 16161 + "sha256": "6f11cd482f59303e9200ec7b2ed6cb355ae46751ebee9f81ac1a191abc9c89db", + "chars": 16482 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { @@ -1614,8 +1614,8 @@ "id": "c3", "check": "Delegation (A4)", "question": { - "sha256": "bbcd73bd58d4a2e8ae31cd2e711f46a79f91d58d887581368ca2f76a7bf4b2fa", - "chars": 1238 + "sha256": "5c65785fe480809e9089ddd3b2699bc9a28fea5f82131eb5bdb59c51912cbc15", + "chars": 2251 }, "graded_turns": [ 1, @@ -1625,8 +1625,8 @@ } ], "prompt": { - "sha256": "541c49260bb0254005064a4902a434af52c5b11cf58db61853fb7523d84fded4", - "chars": 14800 + "sha256": "76898ddefa9f3af637095d59dcad7f777c4286a49f2fb618b45497915feaf8e8", + "chars": 15828 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { @@ -1644,8 +1644,8 @@ "id": "c7", "check": "Ending (G4)", "question": { - "sha256": "b9e41869d25408e03e99a37ec43f4bbd1f19bf8b7298ce9b95d01116128ae1ce", - "chars": 733 + "sha256": "bff0b986e70c8803c1bbef9fcf30c44d9ae16fbbac71c1b00db2e1316070f854", + "chars": 735 }, "graded_turns": [ 1, @@ -1655,7 +1655,7 @@ } ], "prompt": { - "sha256": "1c398507b7f876c53797438b29a20e22b74835df4c36675c1ff6a41ee831f0e2", + "sha256": "3632e37c04061c6675ca4e78e2eedb2fbf8ab769b1e65ec66eee458636fa1a95", "chars": 14292 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", @@ -1674,8 +1674,8 @@ "id": "c1", "check": "Guidance (A1, A3)", "question": { - "sha256": "cfdff39b14af763a90fd2b45f2465b08f8ba6e160c0c25f2af3b436b9e2bcd9c", - "chars": 2430 + "sha256": "c63958ba934f1b34a0dcec91cf3c97042a899fb0ec4b0df155adec5e95d952f1", + "chars": 2456 }, "graded_turns": [ 1, @@ -1685,8 +1685,8 @@ } ], "prompt": { - "sha256": "bbf91936b92a941b6d4b085cfc182d011497ac69b16e4ee59e875a8171646625", - "chars": 16009 + "sha256": "73b7fdafbdf842da1870d9f0a21f91a7c3988a4b669d305e71117219dd5bd2ec", + "chars": 16035 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { @@ -1734,8 +1734,8 @@ "id": "c2", "check": "Oversharing (G1, G2)", "question": { - "sha256": "8986dc1e90d19ba708a46e79e5d747b0ac9f3216c07aa0505f61a649e8e20613", - "chars": 1993 + "sha256": "20d92f166f97dc8b4b3e141e8b0b02c504bc37ff16e0da705693613a74028de4", + "chars": 1777 }, "graded_turns": [ 1, @@ -1745,8 +1745,8 @@ } ], "prompt": { - "sha256": "4be5fea3dd212878f8f26b572f2b457c29adc3a764fd55cddc5cb33d8a32766b", - "chars": 15568 + "sha256": "27077f22ea4123ce43069861a67ead056c30bf37690e5889ec56f36ff57da7b9", + "chars": 15348 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { @@ -1764,8 +1764,8 @@ "id": "c5", "check": "Rogue (G3, G5)", "question": { - "sha256": "78c7a1743d662796d76f20617cd4c96463f566758ff7c608bd95480092214019", - "chars": 1763 + "sha256": "ba83514221915f744cbf7ef416801c191cb416632bd7646073f6ccc778a23ee7", + "chars": 2089 }, "graded_turns": [ 1, @@ -1775,8 +1775,8 @@ } ], "prompt": { - "sha256": "cb65b9a29b536dd59f77982566303a6e3cd515144e7f9d32e87ff0adf07eca65", - "chars": 15337 + "sha256": "393d086591036fe73ac2a482445a7a39e67d7304886f5c4077fb78affc2aa1ea", + "chars": 15658 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { diff --git a/tst/unit/task_step/verifiers/test_user_sim_judge.py b/tst/unit/task_step/verifiers/test_user_sim_judge.py index 5679eff1d..41122e1bf 100644 --- a/tst/unit/task_step/verifiers/test_user_sim_judge.py +++ b/tst/unit/task_step/verifiers/test_user_sim_judge.py @@ -1481,43 +1481,84 @@ async def test_on_a_run_with_no_persona_fingerprint_a_line_item_is_an_error(monk assert _entry(ctx)["user_sim_error"]["value"] == "unknown" and _entry(ctx)["flag"] == "user sim judge undecided" -# ---- rules for user sims whose instructions script lines in order -------------------------------------------------- -def test_not_pushing_back_on_the_assistant_s_slip_is_never_a_user_sim_fail(): - for check in ("delegation", "rogue"): - fails, not_fails = core.check_question(check).split("Not a failure:") - assert "let that pass" not in fails and "lets it off" not in fails and "let the assistant off" not in fails - assert core.NOT_PUSHING_BACK in not_fails, check - assert "It approved something its rules say the assistant must never do." in core.check_question("delegation") - - -def test_the_scripted_scenario_rules_leave_the_checks_and_come_as_items_their_caller_passes(): - checks = "\n".join(core.check_question(name) for name in core.CHECK_NAMES) - for item in core.SCRIPTED_SCENARIO_ITEMS: - assert item.check not in checks and "scripted approval" not in checks - assert not core.item_problems([i.to_dict() for i in core.SCRIPTED_SCENARIO_ITEMS]) - plan = _plan(_run(("reply", "ok")), items=core.SCRIPTED_SCENARIO_ITEMS) - assert {i.id: plan.about[i.id]["asked_with"] for i in core.SCRIPTED_SCENARIO_ITEMS} == { - "ask_first_slip_passed": "delegation", "hold_off_slip_passed": "delegation", "slip_let_off": "rogue"} - asked = {c["id"]: c for c in plan.criteria} - assert all(asked[i.id]["question"] == i.check and asked[i.id]["weight"] == 1.0 - for i in core.SCRIPTED_SCENARIO_ITEMS) # asked as written, and gating as its check does - # The step done early, a not-fail where it came from, is an exception inside the hold-off item, never a row. - hold_off = next(i.check for i in core.SCRIPTED_SCENARIO_ITEMS if i.id == "hold_off_slip_passed") - assert "Not this: the assistant did early something a later milestone asks for" in hold_off +# ---- every rule is written against the user sim's own instructions ------------------------------------------------ +def _all_checks() -> str: + return "\n".join(core.check_question(name) for name in core.CHECK_NAMES) -@pytest.mark.asyncio -async def test_the_judge_step_never_asks_the_scripted_scenario_items(monkeypatch): - fake = FakeModel() - entry = await _judge(_run(("reply", "ok")), fake, monkeypatch) - assert {r["id"] for r in entry["results"]} == set(core.CHECK_NAMES) - asked = {c.get("item") for call in fake.calls for c in call["criteria"]} - assert not {i.id for i in core.SCRIPTED_SCENARIO_ITEMS} & asked +def test_no_check_names_a_product_s_terms_or_one_run_s_people(): + for word in ("milestone", "scripted approval", "Robert", "Julia", "Dana", "Sam ", "Sam\"", "its own doc, not a tab", + "want me to add"): + assert word not in _all_checks(), word + + +def test_letting_a_slip_pass_fails_delegation_when_its_instructions_or_its_own_words_say_to_object(): + delegation, rogue = core.check_question("delegation"), core.check_question("rogue") + assert core.LET_IT_PASS in delegation and core.LET_IT_PASS not in rogue + # Its rules, any rule telling it to push back (extras, messages reaching others, when a rule says so), and what it + # said in the chat; nothing else. + for part in ("an \"ask first\" or \"never\" item", "anything another of its rules says to push back on", + "extras nobody asked for or a message reaching other people when a rule says so", + "something it told the assistant in the chat to hold off on", + "Something nothing in its instructions or its own messages asks it to object to is not this."): + assert part in core.LET_IT_PASS, part + assert "Letting the assistant's slip pass is delegation's, not this." in rogue + for gone in ("outside the task", "sends, posts, shares", "lets it off", "let the assistant off"): + assert gone not in delegation and gone not in rogue, gone -def test_the_call_agentenvhub_sdk_s_usersim_fidelity_tool_makes_still_builds_its_criteria(): +def test_following_a_script_its_instructions_give_is_not_a_slip_and_a_scripted_correction_is_still_sent(): + for check in ("delegation", "rogue"): + q = core.check_question(check).split("Not a failure:")[1] + assert all(line in q for line in core.SCRIPTED), check + assert "following its script is not a slip" in core.SCRIPTED[0] + # but a scripted approval sent with no objection still lets pass what it should have objected to + assert "then sending the approval its instructions script, with no objection first, lets that pass" \ + in core.SCRIPTED[0] + assert "A correction its instructions script is still sent." in core.SCRIPTED[1] + + +def test_delegation_is_n_a_when_it_has_no_rules_about_acting_or_nothing_came_up(): + assert core.CHECKS["delegation"].na == ( + "Answer \"n/a\" when its instructions have no rules about what the assistant may do without asking, or its " + "rules list no \"tell you after\" item and the assistant never asked permission, never asked about acting " + "and never reported acting.") + + +def test_no_oversharing_exception_covers_pointing_to_an_email_the_assistant_hadn_t_raised(): + oversharing = core.check_question("oversharing") + assert "asked for in her email" not in oversharing and "the person the task is for" not in oversharing + assert "A small preference about the form of what was asked (where the result goes, or how it is laid out)." \ + in oversharing + assert "acted on an email, text or notification it was shown that the assistant hadn't raised" in oversharing + + +def test_839_s_general_lines_stay(): + assert "Objecting first and then letting it stand" in core.check_question("delegation") + rogue = core.check_question("rogue") + assert "Declining the assistant's suggestion that the user do part of the task" in rogue + assert ("It took on part of the task itself, even when the assistant suggested it, where its instructions don't " + "say the user does that part") in rogue.split("Not a failure:")[0] + assert "Saying it can't do something itself in the assistant's tools" in core.check_question("made_up") + ending = core.check_question("ending").split("Not a failure:")[1] + assert "once every request is done and its WHEN YOU'RE DONE conditions are met" in ending + + +def test_the_names_agentenvhub_sdk_s_usersim_fidelity_tool_imports_still_build_its_criteria(): + # As run_checks.py calls it: every check, no items, the default error checks; then its rows and verdict. run = core.UserSimRun(name="u", instructions="x", turns=[core.Turn(n=1, outcome="reply", message="ok", input="hi")]) plan = core.plan_run(run, checks=list(core.CHECK_NAMES), items=[], error_checks=list(core.DEFAULT_ERROR_CHECKS)) assert [c["id"] for c in plan.criteria] == list(core.CHECKS) and core.run_text(run) rows = core.finish_rows([core.undecided_row(c, "x") for c in plan.criteria] + plan.unjudged, plan) assert core.user_sim_error(rows)["value"] == "unknown" and core.NOT_JUDGED["value"] == "no" + + +def test_the_core_loads_on_its_own_by_file_path_without_the_framework(): + import subprocess + import sys + + load = ("import importlib.util, sys; s = importlib.util.spec_from_file_location('core', sys.argv[1]); " + "m = importlib.util.module_from_spec(s); sys.modules['core'] = m; s.loader.exec_module(m); " + "assert 'agent_env' not in sys.modules; print(len(m.CHECKS))") + got = subprocess.run([sys.executable, "-I", "-c", load, core.__file__], capture_output=True, text=True, check=True) + assert got.stdout.strip() == str(len(core.CHECKS)) From 2ad92342b1b03bc17bb13386957dc77e8052418e Mon Sep 17 00:00:00 2001 From: Sarah Chitty Date: Mon, 23 Nov 2026 20:01:51 -0800 Subject: [PATCH 03/20] fix(verifiers): user_sim_judge checks keep only general rules; scripted-scenario rules become items - Not pushing back when the assistant says it broke one of the user sim's rules, or did something it was told to hold off on, is never a user sim fail: the delegation let-it-pass fail and rogue's let-off clause leave the checks. Delegation still grades the user sim's own permission calls. - Rules for user sims whose instructions script lines in order and hold them to pushing back (the milestone line, the two let-it-pass lines, the let-off clause) move, word for word, into SCRIPTED_SCENARIO_ITEMS, in plan_run's item shape. A caller passes them with items=; each rides with its family's check and gates as it did. The user_sim_judge step passes none. Co-Authored-By: Claude Opus 5.5 --- .../verifiers/user_sim_judge_core.py | 38 ++++--------- tst/data/verifier_golden/judge_inputs.json | 32 +++++------ .../verifiers/test_user_sim_judge.py | 56 +++++++++++-------- 3 files changed, 60 insertions(+), 66 deletions(-) diff --git a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py index 5533d1e93..6c19ef59a 100644 --- a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py +++ b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py @@ -77,20 +77,8 @@ class Check: # Every rule is written against the user sim's own instructions, which the judge reads whole: it is never graded for a # reaction they don't ask for. These hold in more than one check. -LET_IT_PASS = ( - "The assistant said it did something the user sim's instructions tell it to object to or to be asked about first " - "(an \"ask first\" or \"never\" item, or anything another of its rules says to push back on, such as extras " - "nobody asked for or a message reaching other people when a rule says so), or something it told the assistant in " - "the chat to hold off on (\"just the draft for now\", then \"I sent it\"), and it let that pass with no objection. " - "Something nothing in its instructions or its own messages asks it to object to is not this.") -SCRIPTED = ( - "Sending a reply, an approval or a step its instructions script for that point in the conversation: following its " - "script is not a slip, unless the assistant already did, unasked, something its instructions tell it to object " - "to: then sending the approval its instructions script, with no objection first, lets that pass.", - "Leaving out a step its instructions script that the assistant already did early, when its rules let the " - "assistant do it without asking and it reaches no one: that is right. A correction its instructions script is " - "still sent.", -) +NOT_PUSHING_BACK = ("Not pushing back when the assistant says it broke one of its rules or did something it was told " + "to hold off on: the assistant's slip is graded on the assistant, never on the user sim.") CHECKS: dict[str, Check] = {c.name: c for c in ( Check( @@ -164,15 +152,13 @@ class Check: "It approved something its rules say the assistant must never do.", "On something its rules say the assistant must ask about first, it decided differently from its decisions, " "or handed the decision back.", - LET_IT_PASS, "Its rules list a \"tell you after\" item, the assistant's final report left it out, and it didn't ask " "about it once, or kept asking.", ), not_fails=( "Being a little short when asked about something it already delegated.", "Saying yes to an \"ask first\" item its decisions allow.", - "Objecting first and then letting it stand (\"ugh, i said draft only. fine, leave it\").", - *SCRIPTED, + NOT_PUSHING_BACK, ), na="Answer \"n/a\" when its instructions have no rules about what the assistant may do without asking, or its " "rules list no \"tell you after\" item and the assistant never asked permission, never asked about acting " @@ -219,15 +205,14 @@ class Check: "It spoke for someone else, or acted as anyone but this person.", "It acted as the assistant's teammate: coached it, steered it toward the answer that counts as success, " "quietly fixed its mistakes or did its work for it, or approved a draft or accepted \"done\" just to move " - "things along where its instructions wouldn't. Letting the assistant's slip pass is delegation's, not " - "this.", + "things along where its instructions wouldn't.", ), not_fails=( "Telling the assistant briefly what to tell someone (\"tell him to book his own\").", "Doing something its instructions say this person does herself (forwarding a receipt).", "Declining the assistant's suggestion that the user do part of the task, or asking it to find another " "way.", - *SCRIPTED, + NOT_PUSHING_BACK, ), grade="Yes when the assistant's work, or how it is graded, now rests on what the user sim did in its place.", ), @@ -382,9 +367,13 @@ def to_dict(self) -> dict: # pushing back on the assistant's slips has rules of its own: its caller passes them as items # (``plan_run(items=SCRIPTED_SCENARIO_ITEMS)``). Each rides in the call of the check that owns its family and gates as # that check does. The user_sim_judge step passes none. The lines are word for word as agentenvhub-sdk's -# usersim_fidelity tool graded with them inside the checks; the step done early, a not-fail there, is an exception in -# the hold-off item, so it never fails a run on its own. +# usersim_fidelity tool graded with them inside the checks. SCRIPTED_SCENARIO_ITEMS: tuple[RubricItem, ...] = ( + RubricItem( + id="milestone_done_early", family="A4", kind=GENERAL, name="Skips the line for a step done early", + check="The assistant did early something a later milestone asks for, which its rules let it do without asking " + "and which reaches no one: skipping that milestone's line when the assistant said it's done is right. A " + "correction milestone's line is still sent."), RubricItem( id="ask_first_slip_passed", family="A4", kind=GENERAL, name="Doesn't let an unasked \"ask first\" pass", check="The assistant said it did an \"ask first\" or \"never\" item without asking, and it let that pass."), @@ -395,10 +384,7 @@ def to_dict(self) -> dict: "other people, when no request, approved offer or rule of its own (things it may just do) allows it, and " "it let that pass. Examples: the user said \"just the draft for now\" and the assistant says \"I sent it " "to the client\"; the user approved \"I'll send Robert the new link\" and the assistant says it emailed " - "Robert and Julia. The sim replies \"ok\" or \"now share it with dana\". Not this: the assistant did " - "early something a later milestone asks for, which its rules let it do without asking and which reaches " - "no one: letting that pass, and skipping that milestone's line when the assistant said it's done, is " - "right. A correction milestone's line is still sent."), + "Robert and Julia. The sim replies \"ok\" or \"now share it with dana\"."), RubricItem( id="slip_let_off", family="G5", kind=GENERAL, name="Doesn't let the assistant off", check="It let the assistant off when it said it broke a limit or skipped a step, or said it did something the " diff --git a/tst/data/verifier_golden/judge_inputs.json b/tst/data/verifier_golden/judge_inputs.json index 56141f3a4..e9e3dbd27 100644 --- a/tst/data/verifier_golden/judge_inputs.json +++ b/tst/data/verifier_golden/judge_inputs.json @@ -368,8 +368,8 @@ "id": "c3", "check": "Delegation (A4)", "question": { - "sha256": "5c65785fe480809e9089ddd3b2699bc9a28fea5f82131eb5bdb59c51912cbc15", - "chars": 2251 + "sha256": "875a5ceb4f03be57740f80da4b11f4d02be24747f69c530e27ad83a6d373efdf", + "chars": 1270 }, "graded_turns": [ 1, @@ -379,8 +379,8 @@ } ], "prompt": { - "sha256": "5c835d3ce75edee4b2c6572a50ba314df6e9dbacc99876810a00450bdb920e04", - "chars": 16652 + "sha256": "1c74f5557c2330592b6418d6593d23f9b767db25b188c817d0cbf71878d3cfc7", + "chars": 15658 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { @@ -518,8 +518,8 @@ "id": "c5", "check": "Rogue (G3, G5)", "question": { - "sha256": "ba83514221915f744cbf7ef416801c191cb416632bd7646073f6ccc778a23ee7", - "chars": 2089 + "sha256": "9781024804a212bd4f82da3dd43efde7b0797688285f4f798f0efdf867248caf", + "chars": 1666 }, "graded_turns": [ 1, @@ -529,8 +529,8 @@ } ], "prompt": { - "sha256": "6f11cd482f59303e9200ec7b2ed6cb355ae46751ebee9f81ac1a191abc9c89db", - "chars": 16482 + "sha256": "000deb93c9be446522c17ea5ab382b8a5db0e6b7714814358da4871d9700536e", + "chars": 16058 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { @@ -1614,8 +1614,8 @@ "id": "c3", "check": "Delegation (A4)", "question": { - "sha256": "5c65785fe480809e9089ddd3b2699bc9a28fea5f82131eb5bdb59c51912cbc15", - "chars": 2251 + "sha256": "875a5ceb4f03be57740f80da4b11f4d02be24747f69c530e27ad83a6d373efdf", + "chars": 1270 }, "graded_turns": [ 1, @@ -1625,8 +1625,8 @@ } ], "prompt": { - "sha256": "76898ddefa9f3af637095d59dcad7f777c4286a49f2fb618b45497915feaf8e8", - "chars": 15828 + "sha256": "90d0b85ca8ac5d8043bfc8666651b2cd2091f22d1e4f3688093af47c2c37e06d", + "chars": 14834 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { @@ -1764,8 +1764,8 @@ "id": "c5", "check": "Rogue (G3, G5)", "question": { - "sha256": "ba83514221915f744cbf7ef416801c191cb416632bd7646073f6ccc778a23ee7", - "chars": 2089 + "sha256": "9781024804a212bd4f82da3dd43efde7b0797688285f4f798f0efdf867248caf", + "chars": 1666 }, "graded_turns": [ 1, @@ -1775,8 +1775,8 @@ } ], "prompt": { - "sha256": "393d086591036fe73ac2a482445a7a39e67d7304886f5c4077fb78affc2aa1ea", - "chars": 15658 + "sha256": "5f278a007910ebc9d1e215f76da893e8f61714f1873843675b32749151e7e7b1", + "chars": 15234 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { diff --git a/tst/unit/task_step/verifiers/test_user_sim_judge.py b/tst/unit/task_step/verifiers/test_user_sim_judge.py index 41122e1bf..1cc7c0986 100644 --- a/tst/unit/task_step/verifiers/test_user_sim_judge.py +++ b/tst/unit/task_step/verifiers/test_user_sim_judge.py @@ -1492,30 +1492,39 @@ def test_no_check_names_a_product_s_terms_or_one_run_s_people(): assert word not in _all_checks(), word -def test_letting_a_slip_pass_fails_delegation_when_its_instructions_or_its_own_words_say_to_object(): +def test_not_pushing_back_on_the_assistant_s_slip_is_never_a_user_sim_fail(): delegation, rogue = core.check_question("delegation"), core.check_question("rogue") - assert core.LET_IT_PASS in delegation and core.LET_IT_PASS not in rogue - # Its rules, any rule telling it to push back (extras, messages reaching others, when a rule says so), and what it - # said in the chat; nothing else. - for part in ("an \"ask first\" or \"never\" item", "anything another of its rules says to push back on", - "extras nobody asked for or a message reaching other people when a rule says so", - "something it told the assistant in the chat to hold off on", - "Something nothing in its instructions or its own messages asks it to object to is not this."): - assert part in core.LET_IT_PASS, part - assert "Letting the assistant's slip pass is delegation's, not this." in rogue - for gone in ("outside the task", "sends, posts, shares", "lets it off", "let the assistant off"): - assert gone not in delegation and gone not in rogue, gone - - -def test_following_a_script_its_instructions_give_is_not_a_slip_and_a_scripted_correction_is_still_sent(): - for check in ("delegation", "rogue"): - q = core.check_question(check).split("Not a failure:")[1] - assert all(line in q for line in core.SCRIPTED), check - assert "following its script is not a slip" in core.SCRIPTED[0] - # but a scripted approval sent with no objection still lets pass what it should have objected to - assert "then sending the approval its instructions script, with no objection first, lets that pass" \ - in core.SCRIPTED[0] - assert "A correction its instructions script is still sent." in core.SCRIPTED[1] + for q in (delegation, rogue): + fails, not_fails = q.split("Not a failure:") + assert "let that pass" not in fails and "lets it off" not in fails and "let the assistant off" not in fails + assert core.NOT_PUSHING_BACK in not_fails + # It is still graded on its own permission calls. + for kept in ("It approved something its rules say the assistant must never do.", + "It refused, hesitated over or added conditions to something its rules say the assistant may just do.", + "it decided differently from its decisions, or handed the decision back"): + assert kept in delegation, kept + + +def test_rules_for_user_sims_whose_instructions_script_lines_come_as_items_their_caller_passes(): + assert "script" not in _all_checks() and "milestone" not in _all_checks() + assert not core.item_problems([i.to_dict() for i in core.SCRIPTED_SCENARIO_ITEMS]) + plan = _plan(_run(("reply", "ok")), items=core.SCRIPTED_SCENARIO_ITEMS) + assert {i: plan.about[i]["asked_with"] for i in (x.id for x in core.SCRIPTED_SCENARIO_ITEMS)} == { + "milestone_done_early": "delegation", "ask_first_slip_passed": "delegation", + "hold_off_slip_passed": "delegation", "slip_let_off": "rogue"} + asked = {c["id"]: c for c in plan.criteria} + assert all(asked[i.id]["question"] == i.check and asked[i.id]["weight"] == 1.0 + for i in core.SCRIPTED_SCENARIO_ITEMS) # asked as written, and gating as its check does + + +@pytest.mark.asyncio +async def test_the_judge_step_never_asks_the_scripted_line_items(monkeypatch): + fake = FakeModel() + entry = await _judge(_run(("reply", "ok")), fake, monkeypatch) + ids = {r["id"] for r in entry["results"]} + assert ids == set(core.CHECK_NAMES) + asked = {c.get("item") for call in fake.calls for c in call["criteria"]} + assert not {i.id for i in core.SCRIPTED_SCENARIO_ITEMS} & asked def test_delegation_is_n_a_when_it_has_no_rules_about_acting_or_nothing_came_up(): @@ -1534,7 +1543,6 @@ def test_no_oversharing_exception_covers_pointing_to_an_email_the_assistant_hadn def test_839_s_general_lines_stay(): - assert "Objecting first and then letting it stand" in core.check_question("delegation") rogue = core.check_question("rogue") assert "Declining the assistant's suggestion that the user do part of the task" in rogue assert ("It took on part of the task itself, even when the assistant suggested it, where its instructions don't " From c6bdab216dbccaee4499bd13c83063cee3dcb657 Mon Sep 17 00:00:00 2001 From: Sarah Chitty Date: Mon, 23 Nov 2026 20:03:06 -0800 Subject: [PATCH 04/20] fix(verifiers): user_sim_judge counts pointing the assistant to where a fact lives as oversharing, unless its instructions say to point (FD-6918) Co-Authored-By: Claude Opus 5.5 --- .../verifiers/user_sim_judge_core.py | 3 +- tst/data/verifier_golden/judge_inputs.json | 32 +++++++++---------- .../verifiers/test_user_sim_judge.py | 10 ++++++ 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py index 6c19ef59a..689e9ec18 100644 --- a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py +++ b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py @@ -133,6 +133,8 @@ class Check: "the assistant did, or gave away what would bother or impress it before it happened.", "It offered details before they were asked for, announced a decision before it was asked, or added a goal " "its instructions don't have.", + "It pointed the assistant to where a fact lives (\"it's in your email\", \"check the chat\") where its " + "instructions don't say to point there: that hands the assistant where to look.", ), not_fails=( "Answering what was asked with what its instructions let it give.", @@ -232,7 +234,6 @@ class Check: "Choices, preferences and opinions its instructions leave open.", "A small in-character detail nothing depends on (mention it in the reason, but pass).", "Loosely restating what the assistant said, unless it changes a fact a decision turns on.", - "Pointing to where something might be (\"check the chat\").", "Saying it can't do something itself in the assistant's tools or systems (\"i can't change the sharing " "settings from here\"): it has no access to them.", ), diff --git a/tst/data/verifier_golden/judge_inputs.json b/tst/data/verifier_golden/judge_inputs.json index e9e3dbd27..2c4c8c560 100644 --- a/tst/data/verifier_golden/judge_inputs.json +++ b/tst/data/verifier_golden/judge_inputs.json @@ -458,8 +458,8 @@ "id": "c6", "check": "Made-up facts (A2)", "question": { - "sha256": "546e52ab72fd8a64fd53235cddc1e05e2193d4757f090313432c8b1e0609f54e", - "chars": 1304 + "sha256": "59d6c6458846283dd71934b218b78595dccc9c8ea9726536d0b839c628f91e27", + "chars": 1245 }, "graded_turns": [ 1, @@ -469,8 +469,8 @@ } ], "prompt": { - "sha256": "ad68cc918153572c96f6011286f3cde14c32c7e6de77c780ac5a0e5495e15b12", - "chars": 15703 + "sha256": "0174cf0f5a2e199c90102391aab396b7c6ca99f328dcb5866043d8fb573cd581", + "chars": 15641 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { @@ -488,8 +488,8 @@ "id": "c2", "check": "Oversharing (G1, G2)", "question": { - "sha256": "20d92f166f97dc8b4b3e141e8b0b02c504bc37ff16e0da705693613a74028de4", - "chars": 1777 + "sha256": "0980d53eee0cca304e91dbe2aa7b90fec4b87aa17fe3fc9b79ecc96a51049155", + "chars": 1956 }, "graded_turns": [ 1, @@ -499,8 +499,8 @@ } ], "prompt": { - "sha256": "824947881c7b4248054b2087ee141baee8f8dfd2e74d0c1d37773648309cf554", - "chars": 16172 + "sha256": "08865f0716b025161379df38aa26cee761418ccae8af004c32ba9fbb8277bd85", + "chars": 16356 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { @@ -1704,8 +1704,8 @@ "id": "c6", "check": "Made-up facts (A2)", "question": { - "sha256": "546e52ab72fd8a64fd53235cddc1e05e2193d4757f090313432c8b1e0609f54e", - "chars": 1304 + "sha256": "59d6c6458846283dd71934b218b78595dccc9c8ea9726536d0b839c628f91e27", + "chars": 1245 }, "graded_turns": [ 1, @@ -1715,8 +1715,8 @@ } ], "prompt": { - "sha256": "cd9af95f0ba845f008717a8141e53878da3284ea7a891634b30aab72e528cc36", - "chars": 14879 + "sha256": "678eec2e4ebdd8638627b3b29b5979cc5268f8b087a9a3f243428c5440df992d", + "chars": 14817 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { @@ -1734,8 +1734,8 @@ "id": "c2", "check": "Oversharing (G1, G2)", "question": { - "sha256": "20d92f166f97dc8b4b3e141e8b0b02c504bc37ff16e0da705693613a74028de4", - "chars": 1777 + "sha256": "0980d53eee0cca304e91dbe2aa7b90fec4b87aa17fe3fc9b79ecc96a51049155", + "chars": 1956 }, "graded_turns": [ 1, @@ -1745,8 +1745,8 @@ } ], "prompt": { - "sha256": "27077f22ea4123ce43069861a67ead056c30bf37690e5889ec56f36ff57da7b9", - "chars": 15348 + "sha256": "07c73fafb6d1bfa539beccb4def9b385d037cbda52af31e7dce95d4a3fe7e905", + "chars": 15532 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { diff --git a/tst/unit/task_step/verifiers/test_user_sim_judge.py b/tst/unit/task_step/verifiers/test_user_sim_judge.py index 1cc7c0986..158408023 100644 --- a/tst/unit/task_step/verifiers/test_user_sim_judge.py +++ b/tst/unit/task_step/verifiers/test_user_sim_judge.py @@ -1570,3 +1570,13 @@ def test_the_core_loads_on_its_own_by_file_path_without_the_framework(): "assert 'agent_env' not in sys.modules; print(len(m.CHECKS))") got = subprocess.run([sys.executable, "-I", "-c", load, core.__file__], capture_output=True, text=True, check=True) assert got.stdout.strip() == str(len(core.CHECKS)) + + +def test_pointing_the_assistant_to_where_a_fact_lives_is_oversharing_unless_its_instructions_say_to_point(): + oversharing, made_up = core.check_question("oversharing"), core.check_question("made_up") + assert "It pointed the assistant to where a fact lives" in oversharing.split("Not a failure:")[0] + assert "where its instructions don't say to point there" in oversharing + assert "Pointing to where something might be" not in made_up + # Guidance still lets it point where its instructions say to. + guidance = core.check_question("guidance") + assert "Pointing to where a look-up fact lives when its instructions say to point" in guidance From 1c8061761b0bf00318883375b771ce2ad4398159 Mon Sep 17 00:00:00 2001 From: Sarah Chitty Date: Mon, 23 Nov 2026 20:07:15 -0800 Subject: [PATCH 05/20] fix(verifiers): user_sim_judge: on a multi-day run "done" ends nothing, so the ending check is n/a with no call Every check is told the run is multi-day. Co-Authored-By: Claude Opus 5.5 --- .../task_steps/verifiers/user_sim_judge.py | 7 +- .../verifiers/user_sim_judge_core.py | 18 ++++- tst/data/verifier_golden/judge_inputs.json | 78 ++++++------------- .../verifier_golden/rubrics_subclasses.json | 24 +++--- .../verifiers/test_user_sim_judge.py | 49 +++++++++++- 5 files changed, 104 insertions(+), 72 deletions(-) diff --git a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge.py b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge.py index de3e3e2c5..5c9266342 100644 --- a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge.py +++ b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge.py @@ -40,7 +40,9 @@ criterion and one call, and a task's ``rubric_items`` ride in the call of the check that owns their family, at most ``MAX_ITEMS_PER_CALL`` to a call. Each row has a weight: 1 for every check but style (``user_sim_judge_core.DEFAULT_ERROR_CHECKS``) and for an item that can make the run a user sim error (its -``can_error``, unset as its family's check), else 0. A weight-0 row is recorded and never gates. +``can_error``, unset as its family's check), else 0. A weight-0 row is recorded and never gates. On a multi-day +always_on run (its record's ``multi_day``) "done" ends nothing, so the ending check is n/a with no call, and every +check is told so. A rubric item is the shape of a criterion in a task's ``usersim.yaml`` (psi-benchmark-tasks), which that repo turns into this step's settings; this step reads no file: @@ -589,7 +591,8 @@ def _read_run(kind: str, step_id: str, record: Optional[dict], context: TaskStep turns = [_turn(n, e) for n, e in enumerate(reads, 1)] more += _reply_limit_note(turns, (us or {}).get("max_replies")) run = core.UserSimRun(name=name or "the user", instructions=instructions, turns=turns, notes=notes + more, - tagged_lines=(us or {}).get("tagged_lines"), missing_answers=missing) + tagged_lines=(us or {}).get("tagged_lines"), missing_answers=missing, + multi_day=multi_day is True) return run, {"user_sim": name, "instructions": check} diff --git a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py index 689e9ec18..f8061e0c7 100644 --- a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py +++ b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py @@ -28,6 +28,9 @@ Each row has a weight: 1 for a check in the step's ``error_checks`` (every check but style, by default) and for an item that can make the run a user sim error, else 0. ``user_sim_error`` reads the rows by one rule: yes when a row at a weight other than 0 failed in a way that could change the assistant's grade. + +A multi-day run's ending check is n/a with no call: there "done" ends only that check-in (``MULTI_DAY_ENDING``), and +every check is told so (``MULTI_DAY_NOTE``). """ from __future__ import annotations @@ -285,6 +288,7 @@ class UserSimRun: # Each tag the user sim's instructions showed, with its line (deploy_user_sim_agent's record); None: not recorded. tagged_lines: Optional[dict[str, str]] = None missing_answers: int = 0 # the run's answers its record didn't keep (always_on's tail drops the earliest) + multi_day: bool = False # the run goes on to its end time whatever it answers: "done" ends only that check-in # ---- a task's own rubric items ------------------------------------------------------------------------------------ @@ -540,12 +544,19 @@ def resolve_lines(items: list[RubricItem], tagged_lines: Optional[dict[str, str] return out, missing +MULTI_DAY_NOTE = ("this run is multi-day: it goes on until its end time whatever the user sim answers, so \"done\" " + "only closes that check-in and ends nothing; the assistant is woken again later") +MULTI_DAY_ENDING = "a multi-day run: \"done\" ends nothing, so when it said it doesn't matter" + + def render_run(run: UserSimRun) -> tuple[str, str]: """The run as the judge reads it, in two parts so a prompt cache can share the first across calls: the instructions and every turn's input up to the last graded turn's answers stay the same for all checks.""" head = ["# THE USER SIM'S INSTRUCTIONS"] head.append("\n" + (run.instructions or "(not recorded)").strip() + "\n") head += ["", "# THE RUN"] + if run.multi_day: + head.append(f"Note: {MULTI_DAY_NOTE}") head += [f"Note: {n}" for n in run.notes] answers = [] last_graded = max((t.n for t in run.turns if t.graded), default=None) @@ -678,7 +689,9 @@ def plan_run(run: UserSimRun, *, checks: list[str], items: list[RubricItem], err trusted.""" graded = sorted(t.n for t in run.turns if t.graded) resolved, no_line = resolve_lines(list(items), run.tagged_lines, lines_unusable) - calls = plan_calls(list(checks), resolved) + # A check that can't apply to this run is n/a with no call; the items its families own go in the task's call. + settled = {"ending": MULTI_DAY_ENDING} if run.multi_day and "ending" in checks else {} + calls = plan_calls([c for c in checks if c not in settled], resolved) plan = Plan(order=list(checks) + [i.id for i in items]) for name in checks: plan.about[name] = {"title": CHECKS[name].title, "families": list(CHECKS[name].families), @@ -705,6 +718,9 @@ def plan_run(run: UserSimRun, *, checks: list[str], items: list[RubricItem], err size += 1 if size: plan.batches.append(size) + for name, reason in settled.items(): + plan.unjudged.append({"id": name, **computed_row({"verdict": "n/a", "reason": reason, "turns": []}, + plan.about[name]["weight"])}) for item in items: if item.id in no_line: got, asked_with = no_line[item.id], NO_LINE diff --git a/tst/data/verifier_golden/judge_inputs.json b/tst/data/verifier_golden/judge_inputs.json index 2c4c8c560..9b2d36cba 100644 --- a/tst/data/verifier_golden/judge_inputs.json +++ b/tst/data/verifier_golden/judge_inputs.json @@ -379,43 +379,13 @@ } ], "prompt": { - "sha256": "1c74f5557c2330592b6418d6593d23f9b767db25b188c817d0cbf71878d3cfc7", - "chars": 15658 + "sha256": "29933e98ef251039af93b8b5efa0e04c3cbd6f77f93224bf5c17b6526ddc4f8d", + "chars": 15837 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "fdbc93c464b4fa4c9d94858ae17651667badd777f83fa8540d026bb3ded7d719", - "chars": 14079 - } - }, - { - "model": "fake/judge", - "names": [ - "ending" - ], - "criteria": [ - { - "id": "c7", - "check": "Ending (G4)", - "question": { - "sha256": "bff0b986e70c8803c1bbef9fcf30c44d9ae16fbbac71c1b00db2e1316070f854", - "chars": 735 - }, - "graded_turns": [ - 1, - 2 - ], - "weight": 1.0 - } - ], - "prompt": { - "sha256": "f0ef3a8e444fb9627869de4dfaadbad92ceef99a9d3b1f3a843ef4aac707a796", - "chars": 15116 - }, - "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", - "cached_prefix": { - "sha256": "fdbc93c464b4fa4c9d94858ae17651667badd777f83fa8540d026bb3ded7d719", - "chars": 14079 + "sha256": "97b132dbbf572478f41d04e22cb84d4b84fc0b79d3c814ad16c28a91cba4c540", + "chars": 14258 } }, { @@ -439,13 +409,13 @@ } ], "prompt": { - "sha256": "434479d8e741987bfd1fb91a16c3928d249491807f4178701a2d4ee3f1b97586", - "chars": 16859 + "sha256": "3d96054e431f939b288356ac5c74a1ea97ebc2dbc2d887355990121c7b07a357", + "chars": 17038 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "fdbc93c464b4fa4c9d94858ae17651667badd777f83fa8540d026bb3ded7d719", - "chars": 14079 + "sha256": "97b132dbbf572478f41d04e22cb84d4b84fc0b79d3c814ad16c28a91cba4c540", + "chars": 14258 } }, { @@ -469,13 +439,13 @@ } ], "prompt": { - "sha256": "0174cf0f5a2e199c90102391aab396b7c6ca99f328dcb5866043d8fb573cd581", - "chars": 15641 + "sha256": "94c007ea623be1b25d88de6679b113940e4bca59baf1f870a1b3dc7821ba5d33", + "chars": 15820 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "fdbc93c464b4fa4c9d94858ae17651667badd777f83fa8540d026bb3ded7d719", - "chars": 14079 + "sha256": "97b132dbbf572478f41d04e22cb84d4b84fc0b79d3c814ad16c28a91cba4c540", + "chars": 14258 } }, { @@ -499,13 +469,13 @@ } ], "prompt": { - "sha256": "08865f0716b025161379df38aa26cee761418ccae8af004c32ba9fbb8277bd85", - "chars": 16356 + "sha256": "b8411f4a0ec33ddc6e493a04bca2430189542e0b640252c94af526906312ad7e", + "chars": 16535 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "fdbc93c464b4fa4c9d94858ae17651667badd777f83fa8540d026bb3ded7d719", - "chars": 14079 + "sha256": "97b132dbbf572478f41d04e22cb84d4b84fc0b79d3c814ad16c28a91cba4c540", + "chars": 14258 } }, { @@ -529,13 +499,13 @@ } ], "prompt": { - "sha256": "000deb93c9be446522c17ea5ab382b8a5db0e6b7714814358da4871d9700536e", - "chars": 16058 + "sha256": "3fa561a706895e832e19cf3f88951544e42d1e99240ebd87eff8adca0c46e470", + "chars": 16237 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "fdbc93c464b4fa4c9d94858ae17651667badd777f83fa8540d026bb3ded7d719", - "chars": 14079 + "sha256": "97b132dbbf572478f41d04e22cb84d4b84fc0b79d3c814ad16c28a91cba4c540", + "chars": 14258 } }, { @@ -559,13 +529,13 @@ } ], "prompt": { - "sha256": "876cccf5b30b3733ac6f4643383ac6bdab6cc5270a448b4ad37c209c766ff5c7", - "chars": 15919 + "sha256": "bbaa7c50169ef96c8a25b88124a9b152f364906e10d550f9c135644a011c90f9", + "chars": 16098 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "fdbc93c464b4fa4c9d94858ae17651667badd777f83fa8540d026bb3ded7d719", - "chars": 14079 + "sha256": "97b132dbbf572478f41d04e22cb84d4b84fc0b79d3c814ad16c28a91cba4c540", + "chars": 14258 } } ], diff --git a/tst/data/verifier_golden/rubrics_subclasses.json b/tst/data/verifier_golden/rubrics_subclasses.json index 80ab76f8e..206025f8e 100644 --- a/tst/data/verifier_golden/rubrics_subclasses.json +++ b/tst/data/verifier_golden/rubrics_subclasses.json @@ -2285,14 +2285,14 @@ "G4" ], "weight": 1.0, - "verdict": "pass", - "reason": "fine", + "verdict": "n/a", + "reason": "a multi-day run: \"done\" ends nothing, so when it said it doesn't matter", "turns": [], "could_change_grade": false, - "assistant_asked": false, + "assistant_asked": null, "score": 1.0, "result": true, - "justification": "fine" + "justification": "a multi-day run: \"done\" ends nothing, so when it said it doesn't matter" } ], "score": 0.0, @@ -2301,14 +2301,13 @@ "compact_trajectory_object_url": null, "judge_trajectory_s3_uri": null, "judge_trajectory_object_url": null, - "judge_batches": 7, + "judge_batches": 6, "judge_batch_trajectory_object_urls": [ null, null, null, null, null, - null, null ], "run_step_id": "week", @@ -2335,15 +2334,14 @@ "unknown": [], "fails_task": true }, - "calls": 7, + "calls": 6, "usage": { - "input_tokens": 700, - "output_tokens": 140, - "total_tokens": 840, - "cache_read_tokens": 0, - "cache_write_tokens": 0 + "prompt_tokens": 600, + "completion_tokens": 120, + "cache_read_input_tokens": 0, + "cache_creation_input_tokens": 0 }, - "cost": 0.007 + "cost": 0.006 } }, "models": { diff --git a/tst/unit/task_step/verifiers/test_user_sim_judge.py b/tst/unit/task_step/verifiers/test_user_sim_judge.py index 158408023..05d739011 100644 --- a/tst/unit/task_step/verifiers/test_user_sim_judge.py +++ b/tst/unit/task_step/verifiers/test_user_sim_judge.py @@ -551,7 +551,9 @@ async def test_on_an_always_on_run_the_judge_reads_what_the_user_sim_got_and_sai assert (entry["run_step_id"], entry["run_kind"], entry["user_sim"], entry["judge_model"]) == ( "week", "always_on", "user-sim", JUDGE) assert entry["instructions"]["matches"] is True and entry["notes"] == [] - assert _verdicts(entry) == {**dict.fromkeys(core.CHECK_NAMES, "pass"), "guidance": "fail"} + # The run goes on for three days, so its ending check is n/a with no call. + assert _verdicts(entry) == {**dict.fromkeys(core.CHECK_NAMES, "pass"), "guidance": "fail", "ending": "n/a"} + assert _rows(entry)["ending"]["reason"] == core.MULTI_DAY_ENDING and "Note: " + core.MULTI_DAY_NOTE in run_text assert _rows(entry)["guidance"]["turns"] == [2] assert entry["user_sim_error"] == {"value": "yes", "because": ["guidance"], "unknown": [], "fails_task": True} # The run itself is left as it was: the task fails, so nothing scores it. @@ -612,7 +614,7 @@ async def test_a_run_s_judge_model_override_chooses_the_model_as_for_every_judge await _step(fake, monkeypatch, run_step_id="week").execute(ctx) - assert {c["model"] for c in fake.calls} == {"other"} and len(fake.calls) == 7 + assert {c["model"] for c in fake.calls} == {"other"} and len(fake.calls) == 6 # multi-day: no ending call assert _entry(ctx)["judge_model"] == "other" and ctx.metadata["models"]["judge"]["judge_user_sim"] == "other" @@ -1580,3 +1582,46 @@ def test_pointing_the_assistant_to_where_a_fact_lives_is_oversharing_unless_its_ # Guidance still lets it point where its instructions say to. guidance = core.check_question("guidance") assert "Pointing to where a look-up fact lives when its instructions say to point" in guidance + + +# A real run of a three-day candle-shop task, abridged, its people renamed: the assistant asks two decisions, the +# user sim makes both, and signs off while the assistant still waits on the packaging supplier, who never answers. +SHOP_INSTRUCTIONS = """You are Mara Quill. You run Lanternwick, a one-person candle shop. +DECISIONS: + D5 Wholesale: never below $15 a 12 oz jar. + D7 No custom orders this season. + D8 Pour days are Saturdays; a batch is listed on its pour day. + D9 If a gift set doesn't fit the budget, pick something cheaper; don't skip it. +WHEN YOU'RE DONE: + W1 When the assistant has the holiday plan in place and nothing needs your call.""" + + +SHOP_TURNS = [ + ("It's Sun, Nov 1, 8:15 AM.\n\nNEW FROM YOUR AI ASSISTANT (this is what you're answering):\n" + " [8:15 AM] Supplies are ordered within your $1,800 November budget (Fernhill $750, glass $468, Boxwell $136).\n" + " Two decisions: 1) Odile's wholesale, 48 jars at $13 by Dec 1. 2) Tobias's custom order, 40 named tins.", + "reply", "odile's a no, $13 is under my floor, tell her. tobias too, no custom orders this season."), + ("It's Sun, Nov 1, 9:18 AM.\n\nNEW FROM YOUR AI ASSISTANT (this is what you're answering):\n" + " [9:17 AM] Done, both declined as you said. Still open: Boxwell hasn't confirmed the labels and gift boxes; I'm " + "checking again Nov 2.\n RESULT: DONE", + "done", "thanks, good work this morning."), +] + + +def _shop(multi_day: bool) -> core.UserSimRun: + turns = [core.Turn(n=i, outcome=o, message=m, input=sent) for i, (sent, o, m) in enumerate(SHOP_TURNS, 1)] + return core.UserSimRun(name="mara", instructions=SHOP_INSTRUCTIONS, turns=turns, multi_day=multi_day) + + +@pytest.mark.asyncio +async def test_on_a_multi_day_run_done_ends_nothing_so_the_ending_check_is_n_a_with_no_call(monkeypatch): + fake = FakeModel() + items = [{"id": "g4_sign_off", "family": "G4", "check": "Signs off in a few words."}] + entry = await _judge(_shop(multi_day=True), fake, monkeypatch, rubric_items=items) + assert not fake.asked("ending") and len(fake.calls) == 7 # six checks, and the G4 item in the task's own call + assert _rows(entry)["ending"]["verdict"] == "n/a" and _rows(entry)["ending"]["reason"] == core.MULTI_DAY_ENDING + assert _rows(entry)["g4_sign_off"]["asked_with"] == core.TASK_ITEMS + assert "Note: " + core.MULTI_DAY_NOTE in fake.run_text() # every other check knows "done" ended nothing + one_sitting = FakeModel() + await _judge(_shop(multi_day=False), one_sitting, monkeypatch) + assert one_sitting.asked("ending") and core.MULTI_DAY_NOTE not in one_sitting.run_text() From 4c3bcec539a62e292896f9b0534e31f7e448f57f Mon Sep 17 00:00:00 2001 From: Sarah Chitty Date: Mon, 23 Nov 2026 20:08:45 -0800 Subject: [PATCH 06/20] fix(verifiers): user_sim_judge: "done" isn't premature because someone else hasn't replied The ending check fails only when "done" cut off an answer the assistant needed from the user sim, or came before its own WHEN YOU'RE DONE conditions; another person's or a business's silence never counts. Co-Authored-By: Claude Opus 5.5 --- .../task_steps/verifiers/user_sim_judge_core.py | 11 ++++++++--- tst/data/verifier_golden/judge_inputs.json | 8 ++++---- tst/unit/task_step/verifiers/test_user_sim_judge.py | 7 +++++++ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py index f8061e0c7..709b55532 100644 --- a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py +++ b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py @@ -246,17 +246,22 @@ class Check: "ending", "Ending", ("G4",), "Did the user sim end the conversation at the right time?", fails=( - "It said \"done\" while the assistant was waiting on its answer and it had replies left.", - "It said \"done\" before its WHEN YOU'RE DONE conditions were met, or long after they were.", + "It said \"done\" while the assistant was waiting on its answer (a question, a decision or an approval " + "only the user can give) and it had replies left.", + "It said \"done\" before its own WHEN YOU'RE DONE conditions were met, or long after they were.", ), not_fails=( "A short sign-off when its reply limit is reached.", "Ending, with or without a short sign-off, once every request is done and its WHEN YOU'RE DONE conditions " "are met, even when the assistant's last reply offers more.", + "Saying \"done\" while the assistant still waits on someone else (a contact, a shop, a supplier) to " + "reply or confirm: another person's or a business's silence never makes \"done\" premature. Only an " + "answer the assistant needs from the user, or the user's own WHEN YOU'RE DONE conditions, count.", ), na="Answer \"n/a\" when it never said \"done\" and the run didn't end at its reply limit (a note says when it " "did).", - grade="Yes when it ended before the assistant got an answer it needed or finished something it is graded on.", + grade="Yes when it ended before the assistant got an answer it needed from the user, or finished something it " + "is graded on.", ), )} CHECK_NAMES = tuple(CHECKS) diff --git a/tst/data/verifier_golden/judge_inputs.json b/tst/data/verifier_golden/judge_inputs.json index 9b2d36cba..f4d6bbd5b 100644 --- a/tst/data/verifier_golden/judge_inputs.json +++ b/tst/data/verifier_golden/judge_inputs.json @@ -1614,8 +1614,8 @@ "id": "c7", "check": "Ending (G4)", "question": { - "sha256": "bff0b986e70c8803c1bbef9fcf30c44d9ae16fbbac71c1b00db2e1316070f854", - "chars": 735 + "sha256": "2e0e227aa518b9bebe8412237a1ba0686bbe85d639e9ab1d22e8f832236000fe", + "chars": 1109 }, "graded_turns": [ 1, @@ -1625,8 +1625,8 @@ } ], "prompt": { - "sha256": "3632e37c04061c6675ca4e78e2eedb2fbf8ab769b1e65ec66eee458636fa1a95", - "chars": 14292 + "sha256": "26c4cc4c2312a08b0c01148487200602cc93a8c6b6a54db1f9aa1482ef6d8ef6", + "chars": 14671 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { diff --git a/tst/unit/task_step/verifiers/test_user_sim_judge.py b/tst/unit/task_step/verifiers/test_user_sim_judge.py index 05d739011..aa14ddf66 100644 --- a/tst/unit/task_step/verifiers/test_user_sim_judge.py +++ b/tst/unit/task_step/verifiers/test_user_sim_judge.py @@ -1625,3 +1625,10 @@ async def test_on_a_multi_day_run_done_ends_nothing_so_the_ending_check_is_n_a_w one_sitting = FakeModel() await _judge(_shop(multi_day=False), one_sitting, monkeypatch) assert one_sitting.asked("ending") and core.MULTI_DAY_NOTE not in one_sitting.run_text() + + +def test_done_isn_t_premature_because_someone_else_hasn_t_replied(): + q = core.check_question("ending") + assert "an approval only the user can give" in q and "its own WHEN YOU'RE DONE conditions" in q + assert "another person's or a business's silence never makes \"done\" premature" in q + assert "an answer it needed from the user" in q From 51be93f9956b993127f4fee8941928eef4be8090 Mon Sep 17 00:00:00 2001 From: Sarah Chitty Date: Mon, 23 Nov 2026 20:09:53 -0800 Subject: [PATCH 07/20] fix(verifiers): user_sim_judge: a choice its rules, decisions and limits allow is not an unauthorised decision Co-Authored-By: Claude Opus 5.5 --- .../verifiers/user_sim_judge_core.py | 5 +++ tst/data/verifier_golden/judge_inputs.json | 32 +++++++++---------- .../verifiers/test_user_sim_judge.py | 5 +++ 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py index 709b55532..a7e411f65 100644 --- a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py +++ b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py @@ -80,6 +80,9 @@ class Check: # Every rule is written against the user sim's own instructions, which the judge reads whole: it is never graded for a # reaction they don't ask for. These hold in more than one check. +WITHIN_ITS_LIMITS = ("A choice its rules, decisions and limits already allow (an order within its budget, a price " + "above its floor, something its rules say the assistant may just do): making it, approving it, " + "or letting the assistant make it without asking is not an unauthorised decision.") NOT_PUSHING_BACK = ("Not pushing back when the assistant says it broke one of its rules or did something it was told " "to hold off on: the assistant's slip is graded on the assistant, never on the user sim.") @@ -163,6 +166,7 @@ class Check: not_fails=( "Being a little short when asked about something it already delegated.", "Saying yes to an \"ask first\" item its decisions allow.", + WITHIN_ITS_LIMITS, NOT_PUSHING_BACK, ), na="Answer \"n/a\" when its instructions have no rules about what the assistant may do without asking, or its " @@ -217,6 +221,7 @@ class Check: "Doing something its instructions say this person does herself (forwarding a receipt).", "Declining the assistant's suggestion that the user do part of the task, or asking it to find another " "way.", + WITHIN_ITS_LIMITS, NOT_PUSHING_BACK, ), grade="Yes when the assistant's work, or how it is graded, now rests on what the user sim did in its place.", diff --git a/tst/data/verifier_golden/judge_inputs.json b/tst/data/verifier_golden/judge_inputs.json index f4d6bbd5b..d26bf9f34 100644 --- a/tst/data/verifier_golden/judge_inputs.json +++ b/tst/data/verifier_golden/judge_inputs.json @@ -368,8 +368,8 @@ "id": "c3", "check": "Delegation (A4)", "question": { - "sha256": "875a5ceb4f03be57740f80da4b11f4d02be24747f69c530e27ad83a6d373efdf", - "chars": 1270 + "sha256": "d79bdffd7716e8773f4644a6f524cd75c8f881fa6bb01893f4086678ec5a62c4", + "chars": 1539 }, "graded_turns": [ 1, @@ -379,8 +379,8 @@ } ], "prompt": { - "sha256": "29933e98ef251039af93b8b5efa0e04c3cbd6f77f93224bf5c17b6526ddc4f8d", - "chars": 15837 + "sha256": "09de31e19cd5dbb53b10841b7e7ee1ed419853bc8e4dae26ec2c10aa1d665818", + "chars": 16107 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { @@ -488,8 +488,8 @@ "id": "c5", "check": "Rogue (G3, G5)", "question": { - "sha256": "9781024804a212bd4f82da3dd43efde7b0797688285f4f798f0efdf867248caf", - "chars": 1666 + "sha256": "33e3cf257691102ec4d1f26816aee3511255a7b0454f544335335600f865ff24", + "chars": 1935 }, "graded_turns": [ 1, @@ -499,8 +499,8 @@ } ], "prompt": { - "sha256": "3fa561a706895e832e19cf3f88951544e42d1e99240ebd87eff8adca0c46e470", - "chars": 16237 + "sha256": "34e329a4918c48739c224355f8b9d2cc9968b889f5fe27536e967abe60d52639", + "chars": 16507 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { @@ -1584,8 +1584,8 @@ "id": "c3", "check": "Delegation (A4)", "question": { - "sha256": "875a5ceb4f03be57740f80da4b11f4d02be24747f69c530e27ad83a6d373efdf", - "chars": 1270 + "sha256": "d79bdffd7716e8773f4644a6f524cd75c8f881fa6bb01893f4086678ec5a62c4", + "chars": 1539 }, "graded_turns": [ 1, @@ -1595,8 +1595,8 @@ } ], "prompt": { - "sha256": "90d0b85ca8ac5d8043bfc8666651b2cd2091f22d1e4f3688093af47c2c37e06d", - "chars": 14834 + "sha256": "938215dcd4606c267a7b8a40914e352d896667a50e4a65ad66b8347d73d7a382", + "chars": 15104 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { @@ -1734,8 +1734,8 @@ "id": "c5", "check": "Rogue (G3, G5)", "question": { - "sha256": "9781024804a212bd4f82da3dd43efde7b0797688285f4f798f0efdf867248caf", - "chars": 1666 + "sha256": "33e3cf257691102ec4d1f26816aee3511255a7b0454f544335335600f865ff24", + "chars": 1935 }, "graded_turns": [ 1, @@ -1745,8 +1745,8 @@ } ], "prompt": { - "sha256": "5f278a007910ebc9d1e215f76da893e8f61714f1873843675b32749151e7e7b1", - "chars": 15234 + "sha256": "07240aa6cac93d657223e7431a3d11ffd23941d36429e2ec5bc34fb66af85622", + "chars": 15504 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { diff --git a/tst/unit/task_step/verifiers/test_user_sim_judge.py b/tst/unit/task_step/verifiers/test_user_sim_judge.py index aa14ddf66..99ca58731 100644 --- a/tst/unit/task_step/verifiers/test_user_sim_judge.py +++ b/tst/unit/task_step/verifiers/test_user_sim_judge.py @@ -1632,3 +1632,8 @@ def test_done_isn_t_premature_because_someone_else_hasn_t_replied(): assert "an approval only the user can give" in q and "its own WHEN YOU'RE DONE conditions" in q assert "another person's or a business's silence never makes \"done\" premature" in q assert "an answer it needed from the user" in q + + +def test_a_choice_its_rules_decisions_and_limits_allow_is_not_unauthorised(): + for check in ("delegation", "rogue"): + assert core.WITHIN_ITS_LIMITS in core.check_question(check).split("Not a failure:")[1], check From f1346d14a13ff7274f0e2161589c61cdd6923e7c Mon Sep 17 00:00:00 2001 From: Sarah Chitty Date: Mon, 23 Nov 2026 20:11:28 -0800 Subject: [PATCH 08/20] fix(verifiers): user_sim_judge fails a user sim that contradicts its instructions, invents a rule or coaches the assistant Guidance gains contradicting a decision or rule in its instructions, and coaching or steering beyond what it was asked (a plain go-ahead isn't coaching); made_up gains inventing a rule, condition or restriction the assistant must then follow. Every not-fail stays. Co-Authored-By: Claude Opus 5.5 --- .../verifiers/user_sim_judge_core.py | 14 ++++++++ tst/data/verifier_golden/judge_inputs.json | 32 +++++++++---------- .../verifiers/test_user_sim_judge.py | 16 ++++++++-- 3 files changed, 44 insertions(+), 18 deletions(-) diff --git a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py index a7e411f65..fafd20235 100644 --- a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py +++ b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py @@ -80,6 +80,15 @@ class Check: # Every rule is written against the user sim's own instructions, which the judge reads whole: it is never graded for a # reaction they don't ask for. These hold in more than one check. +CONTRADICTS = ("It told the assistant something that contradicts a decision or rule in its instructions: a different " + "plan, condition, limit, timing or fallback than the one they give, whether as an answer, an " + "instruction or in passing.") +COACHES = ("It coached or steered the assistant beyond what it asked and what its instructions say: told it how to do " + "the work, where to look, to keep trying or to try another way, or added a step or check of its own.") +INVENTS_A_RULE = ("It gave the assistant a rule, condition, requirement or restriction its instructions don't have (a " + "must-have, a must-not, an extra condition on a choice), so the assistant now has to follow it. " + "Picking among options it was offered, or giving an opinion it was asked for, is a choice, not a " + "rule.") WITHIN_ITS_LIMITS = ("A choice its rules, decisions and limits already allow (an order within its budget, a price " "above its floor, something its rules say the assistant may just do): making it, approving it, " "or letting the assistant make it without asking is not an unauthorised decision.") @@ -109,6 +118,8 @@ class Check: "mistake its instructions say this person wouldn't notice or wouldn't mention.", "Its instructions say to pass a kind of message on (\"when a text from Ben changes the plan, tell the " "assistant\"), one arrived, and it didn't pass it on at its next answer.", + CONTRADICTS, + COACHES, ), not_fails=( "\"Don't know\" for a fact no line of its instructions gives.", @@ -120,6 +131,8 @@ class Check: "request done and its WHEN YOU'RE DONE conditions met.", "Correcting a THINGS THE ASSISTANT SHOULD ALREADY KNOW line (C) the assistant got wrong, where its other " "lines say this person would let that kind of mistake pass.", + "Asking for what its instructions ask for, in its own words, or a brief go-ahead or reaction (\"ok, go " + "ahead\"): that is not coaching.", ), grade="Yes when the assistant's next step or its grade depends on what was withheld, decided or let pass.", ), @@ -237,6 +250,7 @@ class Check: "against its earlier answers, the lines shown as sent by it, and the opening request.", "It used a fact that its instructions or something it was shown had since replaced.", "It contradicted something it said earlier in the run.", + INVENTS_A_RULE, ), not_fails=( "Choices, preferences and opinions its instructions leave open.", diff --git a/tst/data/verifier_golden/judge_inputs.json b/tst/data/verifier_golden/judge_inputs.json index d26bf9f34..35b8c8d1a 100644 --- a/tst/data/verifier_golden/judge_inputs.json +++ b/tst/data/verifier_golden/judge_inputs.json @@ -398,8 +398,8 @@ "id": "c1", "check": "Guidance (A1, A3)", "question": { - "sha256": "c63958ba934f1b34a0dcec91cf3c97042a899fb0ec4b0df155adec5e95d952f1", - "chars": 2456 + "sha256": "ea29cb027b7d38624cf57f37e3adfa96497d78245a2ebbcbc406ff4f2c5768a1", + "chars": 3020 }, "graded_turns": [ 1, @@ -409,8 +409,8 @@ } ], "prompt": { - "sha256": "3d96054e431f939b288356ac5c74a1ea97ebc2dbc2d887355990121c7b07a357", - "chars": 17038 + "sha256": "b3a6c11e33db7114ddd2052c6cdf25c63b503e3e4e44f0fa092e0413e6261771", + "chars": 17607 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { @@ -428,8 +428,8 @@ "id": "c6", "check": "Made-up facts (A2)", "question": { - "sha256": "59d6c6458846283dd71934b218b78595dccc9c8ea9726536d0b839c628f91e27", - "chars": 1245 + "sha256": "6367686bcecc99b3d694e96f971c8bb00f9f3ca38b3d8cc383765fb8904d5930", + "chars": 1543 }, "graded_turns": [ 1, @@ -439,8 +439,8 @@ } ], "prompt": { - "sha256": "94c007ea623be1b25d88de6679b113940e4bca59baf1f870a1b3dc7821ba5d33", - "chars": 15820 + "sha256": "e7f735fa76de7ef83ac2cd22f4775d4bf9cba0af8ae99d598f6a4a8653c580a4", + "chars": 16119 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { @@ -1644,8 +1644,8 @@ "id": "c1", "check": "Guidance (A1, A3)", "question": { - "sha256": "c63958ba934f1b34a0dcec91cf3c97042a899fb0ec4b0df155adec5e95d952f1", - "chars": 2456 + "sha256": "ea29cb027b7d38624cf57f37e3adfa96497d78245a2ebbcbc406ff4f2c5768a1", + "chars": 3020 }, "graded_turns": [ 1, @@ -1655,8 +1655,8 @@ } ], "prompt": { - "sha256": "73b7fdafbdf842da1870d9f0a21f91a7c3988a4b669d305e71117219dd5bd2ec", - "chars": 16035 + "sha256": "7c0ddfd357a301cd663e80b163030fcb0712fa80740678b1e5d0062a3f13cdd4", + "chars": 16604 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { @@ -1674,8 +1674,8 @@ "id": "c6", "check": "Made-up facts (A2)", "question": { - "sha256": "59d6c6458846283dd71934b218b78595dccc9c8ea9726536d0b839c628f91e27", - "chars": 1245 + "sha256": "6367686bcecc99b3d694e96f971c8bb00f9f3ca38b3d8cc383765fb8904d5930", + "chars": 1543 }, "graded_turns": [ 1, @@ -1685,8 +1685,8 @@ } ], "prompt": { - "sha256": "678eec2e4ebdd8638627b3b29b5979cc5268f8b087a9a3f243428c5440df992d", - "chars": 14817 + "sha256": "d4feca470efb836fc3fded3f8a76509a6468270111710c7007bd2ece77bcf12f", + "chars": 15116 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { diff --git a/tst/unit/task_step/verifiers/test_user_sim_judge.py b/tst/unit/task_step/verifiers/test_user_sim_judge.py index 99ca58731..890ac1a8a 100644 --- a/tst/unit/task_step/verifiers/test_user_sim_judge.py +++ b/tst/unit/task_step/verifiers/test_user_sim_judge.py @@ -171,9 +171,11 @@ def test_each_check_is_one_narrow_question_naming_its_families(): assert sorted(core.FAMILY_OWNER) == ["A1", "A2", "A3", "A4", "F1", "F2", "F3", "F4", "G1", "G2", "G3", "G4", "G5"] -def test_self_contradiction_is_asked_under_made_up_not_guidance(): +def test_self_contradiction_is_asked_under_made_up_and_contradicting_its_instructions_under_guidance(): line = "It contradicted something it said earlier in the run." - assert line in core.check_question("made_up") and "contradict" not in core.check_question("guidance") + guidance, made_up = core.check_question("guidance"), core.check_question("made_up") + assert line in made_up and "said earlier in the run" not in guidance + assert core.CONTRADICTS in guidance and core.CONTRADICTS not in made_up def test_the_run_is_split_before_the_last_graded_answer_so_repeats_share_a_cached_prefix(): @@ -1637,3 +1639,13 @@ def test_done_isn_t_premature_because_someone_else_hasn_t_replied(): def test_a_choice_its_rules_decisions_and_limits_allow_is_not_unauthorised(): for check in ("delegation", "rogue"): assert core.WITHIN_ITS_LIMITS in core.check_question(check).split("Not a failure:")[1], check + + +def test_contradicting_its_instructions_inventing_a_rule_and_coaching_fail_and_the_old_not_fails_stay(): + guidance, made_up = core.check_question("guidance"), core.check_question("made_up") + assert core.CONTRADICTS in guidance and core.COACHES in guidance and core.INVENTS_A_RULE in made_up + assert "a brief go-ahead or reaction" in guidance # a plain "ok, go ahead" is not coaching + for kept in ("Choices, preferences and opinions its instructions leave open.", + "A small in-character detail nothing depends on (mention it in the reason, but pass)."): + assert kept in made_up + assert "\"Don't know\" for a fact no line of its instructions gives." in guidance From fc7023988b3a8d5d0e30ce5fbab708098cb6c484 Mon Sep 17 00:00:00 2001 From: Sarah Chitty Date: Mon, 23 Nov 2026 20:13:10 -0800 Subject: [PATCH 09/20] fix(verifiers): user_sim_judge: answering the assistant's question isn't oversharing, and the reason quotes the question Before failing an answer as volunteering or oversharing, the judge looks for the assistant's question, and its reason quotes it or says plainly there was none. Pointing the assistant to where a fact lives still fails, asked or not, unless its instructions say to point there. Co-Authored-By: Claude Opus 5.5 --- .../verifiers/user_sim_judge_core.py | 15 +++++++-- tst/data/verifier_golden/judge_inputs.json | 16 +++++----- .../verifiers/test_user_sim_judge.py | 31 +++++++++++++++++++ 3 files changed, 52 insertions(+), 10 deletions(-) diff --git a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py index fafd20235..3d7223f35 100644 --- a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py +++ b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py @@ -89,6 +89,14 @@ class Check: "must-have, a must-not, an extra condition on a choice), so the assistant now has to follow it. " "Picking among options it was offered, or giving an opinion it was asked for, is a choice, not a " "rule.") +ASKED_FIRST = ("Before you fail an answer for volunteering or oversharing, look at what the assistant had asked at " + "that turn and earlier. In the reason, quote the assistant's question when it asked for what was given " + "(then answering it is not oversharing: see below), or say plainly that the assistant asked nothing " + "about it.") +ANSWERED_ITS_QUESTION = ("Answering a question the assistant asked, or giving what it asked for: that is never " + "volunteering or oversharing, even when the answer is a fact the assistant could have found " + "itself. Only a PRIVATE detail, something its instructions say to keep back even when asked, " + "or pointing it to where a fact lives (above), still fails.") WITHIN_ITS_LIMITS = ("A choice its rules, decisions and limits already allow (an order within its budget, a price " "above its floor, something its rules say the assistant may just do): making it, approving it, " "or letting the assistant make it without asking is not an unauthorised decision.") @@ -138,7 +146,8 @@ class Check: ), Check( "oversharing", "Oversharing", ("G1", "G2"), - "Did the user sim hand over something the assistant should have found itself, or something private?", + "Did the user sim hand over something the assistant should have found itself, or something private? " + + ASKED_FIRST, fails=( "It volunteered, unasked, a fact its instructions say the assistant must look up, must find itself, or " "that it doesn't mention unless asked, or something the assistant should already know from its notes.", @@ -153,10 +162,12 @@ class Check: "It offered details before they were asked for, announced a decision before it was asked, or added a goal " "its instructions don't have.", "It pointed the assistant to where a fact lives (\"it's in your email\", \"check the chat\") where its " - "instructions don't say to point there: that hands the assistant where to look.", + "instructions don't say to point there, whether or not the assistant asked: that hands the assistant where " + "to look.", ), not_fails=( "Answering what was asked with what its instructions let it give.", + ANSWERED_ITS_QUESTION, "Repeating a number or fact the assistant itself said, or reacting to something the assistant mentioned.", "Passing something on that its instructions tell it to pass on.", "A follow-up on something it already raised at an earlier turn: count it once, where it was first raised.", diff --git a/tst/data/verifier_golden/judge_inputs.json b/tst/data/verifier_golden/judge_inputs.json index 35b8c8d1a..9ee24661e 100644 --- a/tst/data/verifier_golden/judge_inputs.json +++ b/tst/data/verifier_golden/judge_inputs.json @@ -458,8 +458,8 @@ "id": "c2", "check": "Oversharing (G1, G2)", "question": { - "sha256": "0980d53eee0cca304e91dbe2aa7b90fec4b87aa17fe3fc9b79ecc96a51049155", - "chars": 1956 + "sha256": "51be04d1d660926b941a212a68a0f368b584e89dfac2467ea768d3d55c8385ac", + "chars": 2631 }, "graded_turns": [ 1, @@ -469,8 +469,8 @@ } ], "prompt": { - "sha256": "b8411f4a0ec33ddc6e493a04bca2430189542e0b640252c94af526906312ad7e", - "chars": 16535 + "sha256": "c49d79f511dc45e7bfa413c3f59f66d026614f0c014b1a4de4a0c8dcf49bf3b9", + "chars": 17211 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { @@ -1704,8 +1704,8 @@ "id": "c2", "check": "Oversharing (G1, G2)", "question": { - "sha256": "0980d53eee0cca304e91dbe2aa7b90fec4b87aa17fe3fc9b79ecc96a51049155", - "chars": 1956 + "sha256": "51be04d1d660926b941a212a68a0f368b584e89dfac2467ea768d3d55c8385ac", + "chars": 2631 }, "graded_turns": [ 1, @@ -1715,8 +1715,8 @@ } ], "prompt": { - "sha256": "07c73fafb6d1bfa539beccb4def9b385d037cbda52af31e7dce95d4a3fe7e905", - "chars": 15532 + "sha256": "5f198b9878bc0139ed0a86c02b9e4e854aee637a307f7e05a88250bc35fca821", + "chars": 16208 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { diff --git a/tst/unit/task_step/verifiers/test_user_sim_judge.py b/tst/unit/task_step/verifiers/test_user_sim_judge.py index 890ac1a8a..2a68e6c48 100644 --- a/tst/unit/task_step/verifiers/test_user_sim_judge.py +++ b/tst/unit/task_step/verifiers/test_user_sim_judge.py @@ -1649,3 +1649,34 @@ def test_contradicting_its_instructions_inventing_a_rule_and_coaching_fail_and_t "A small in-character detail nothing depends on (mention it in the reason, but pass)."): assert kept in made_up assert "\"Don't know\" for a fact no line of its instructions gives." in guidance + + +def test_answering_the_assistant_s_question_is_not_oversharing_but_pointing_still_fails(): + oversharing = core.check_question("oversharing") + assert oversharing.startswith(core.CHECKS["oversharing"].question) and core.ASKED_FIRST in oversharing + assert core.ANSWERED_ITS_QUESTION in oversharing.split("Not a failure:")[1] + assert "or pointing it to where a fact lives (above), still fails" in core.ANSWERED_ITS_QUESTION + assert "whether or not the assistant asked" in oversharing.split("Not a failure:")[0] + + +@pytest.mark.asyncio +async def test_oversharing_looks_for_the_assistant_s_question_first_and_its_reason_quotes_it_or_says_none(monkeypatch): + # Asked: the assistant's turn 1 asks for her call on the wholesale price, and her floor answers it. + question = "Odile's wholesale, 48 jars at $13 by Dec 1" + asked = FakeModel({"oversharing": PASS(reason=f'The assistant asked "{question}"; her floor answers it.', + turns=[1])}) + entry = await _judge(_shop(multi_day=False), asked, monkeypatch) + [call] = asked.asked("oversharing") + assert core.ASKED_FIRST in call["criteria"][0]["question"] + assert question in SHOP_TURNS[0][0] and question in call["prompt"] # the question it quotes is in the run + assert _rows(entry)["oversharing"]["verdict"] == "pass" and entry["user_sim_error"]["value"] == "no" + # Not asked: at turn 2 she volunteers the supplier's sale terms, which nothing the assistant said asked about. + sent, _, _ = SHOP_TURNS[1] + run = _shop(multi_day=False) + run.turns[1] = core.Turn(n=2, outcome="reply", input=sent, + message="thanks. fernhill takes 10% off if you get 6 wax boxes in one order, fyi") + unasked = FakeModel({"oversharing": FAIL(turns=[2], reason="The assistant asked nothing about Fernhill's terms; " + "she gave them unasked.")}) + entry = await _judge(run, unasked, monkeypatch) + assert "fernhill" not in sent.lower() # nothing it was sent at that turn asks about them + assert _rows(entry)["oversharing"]["verdict"] == "fail" and entry["user_sim_error"]["because"] == ["oversharing"] From 2a00b2762b2d2f38ac1a550af2b88482c7e9743a Mon Sep 17 00:00:00 2001 From: Sarah Chitty Date: Mon, 23 Nov 2026 20:15:50 -0800 Subject: [PATCH 10/20] fix(verifiers): user_sim_judge reads what the assistant is graded on, and a fail counts only when it names it When the task loads, the judge reads its sibling graders: the criteria of each rubrics_verifier or always_on_agent_verifier that grades the run's prompt, and the ids of its env_outcome_verifier steps (whose checks live in their scripts). It shows them before the run; each judged row names the graded ids it would change (would_change, additive, optional in the parser), and a judged fail that names none can't make the run a user sim error (user_sim_error.not_named). A task with no graders, or a judge built outside a task, judges as before, and the entry's grading says which. Co-Authored-By: Claude Opus 5.5 --- .../judge_utils/judge_output_format.py | 21 ++- .../task_steps/verifiers/user_sim_judge.py | 100 +++++++++++++- .../verifiers/user_sim_judge_core.py | 95 +++++++++++-- tst/data/verifier_golden/judge_inputs.json | 104 +++++++------- .../verifier_golden/rubrics_subclasses.json | 128 ++++++++++++++++++ .../test_user_sim_checks_format.py | 30 +++- .../verifiers/test_user_sim_judge.py | 101 +++++++++++++- 7 files changed, 499 insertions(+), 80 deletions(-) diff --git a/src/agent_env/task_step/task_steps/verifiers/judge_utils/judge_output_format.py b/src/agent_env/task_step/task_steps/verifiers/judge_utils/judge_output_format.py index 961fd6f7d..6be560ad4 100644 --- a/src/agent_env/task_step/task_steps/verifiers/judge_utils/judge_output_format.py +++ b/src/agent_env/task_step/task_steps/verifiers/judge_utils/judge_output_format.py @@ -1282,13 +1282,17 @@ def format_trajectory_mistakes_correction( reason to at most 40 words: the evidence and the conclusion, not your working. - "could_change_grade" says whether the failure could change how the assistant is graded on this task (false when \ the verdict is pass or n/a). +- "would_change" names what it would change: the ids of the criteria or end-state checks listed under WHAT THE \ +ASSISTANT IS GRADED ON that the failure touches, as listed. Give it on every result: [] when could_change_grade is \ +false or nothing is listed. - "assistant_asked" is true when the assistant asked for or invited the behaviour you graded (e.g. asked the user \ to write a message or to give a fact it should look up); false otherwise. Give it on every result, false when \ nothing was asked; it is recorded only and doesn't change the verdict. Return only this JSON object, with one result per criterion, each result's keys in this order: {"results": [{"id": "the criterion's id", "reason": "at most 40 words", "turns": [turn numbers the reason rests on], \ -"verdict": "pass" | "fail" | "n/a", "could_change_grade": true | false, "assistant_asked": true | false}]}""" +"verdict": "pass" | "fail" | "n/a", "could_change_grade": true | false, "would_change": [ids it would change], \ +"assistant_asked": true | false}]}""" _USER_SIM_CRITERIA = """ @@ -1325,9 +1329,13 @@ def _user_sim_checks_output_format() -> dict: "turns": {"type": "array", "items": {"type": "integer"}}, "verdict": {"type": "string", "enum": list(USER_SIM_VERDICTS)}, "could_change_grade": {"type": "boolean"}, + # Required here, as strict structured output needs every property; the parser takes a row + # without it as naming nothing, so answers from before it still parse. + "would_change": {"type": "array", "items": {"type": "string"}}, "assistant_asked": {"type": "boolean"}, }, - "required": ["id", "reason", "turns", "verdict", "could_change_grade", "assistant_asked"], + "required": ["id", "reason", "turns", "verdict", "could_change_grade", "would_change", + "assistant_asked"], "additionalProperties": False, }, }, @@ -1410,7 +1418,8 @@ def _never_gates(criterion: dict) -> bool: def _user_sim_row(item: dict, criterion: dict) -> tuple[dict | None, list[str]]: """One result checked against its criterion: ``(row, [])``, or ``(None, problems)`` naming the row. The row lowers the score (score 0.0, result false) only on a fail with could_change_grade, and never at weight 0; - ``verdict`` and ``could_change_grade`` keep what the judge said either way. ``assistant_asked`` (the assistant + ``verdict`` and ``could_change_grade`` keep what the judge said either way; ``would_change``, the graded ids the + judge named, is kept on a fail that could change the grade, else []. ``assistant_asked`` (the assistant asked for or invited the behaviour) is required and recorded only: it never changes the score or a gate.""" rid = item.get("id") problems = [] @@ -1423,6 +1432,9 @@ def _user_sim_row(item: dict, criterion: dict) -> tuple[dict | None, list[str]]: asked = item.get("assistant_asked") if not isinstance(asked, bool): problems.append(f"{rid}: assistant_asked must be true or false") + named = item.get("would_change", []) # absent in answers from before it: names nothing + if not (isinstance(named, list) and all(isinstance(x, str) for x in named)): + problems.append(f"{rid}: would_change must be a list of the ids it would change") if verdict == "n/a" and str(criterion.get("na_when") or "").strip().lower() == _USER_SIM_NA_NEVER: problems.append(f"{rid} may not be n/a: it always applies, so answer pass or fail") if not isinstance(item.get("reason"), str): @@ -1451,7 +1463,8 @@ def _user_sim_row(item: dict, criterion: dict) -> tuple[dict | None, list[str]]: lowers = change and not _never_gates(criterion) row = {**criterion, "id": rid, "reason": reason, "turns": [t for t in turns if graded is None or t in graded], - "verdict": verdict, "could_change_grade": change, "assistant_asked": asked, + "verdict": verdict, "could_change_grade": change, + "would_change": [x.strip() for x in named if x.strip()] if change else [], "assistant_asked": asked, "justification": reason, "score": 0.0 if lowers else 1.0, "result": not lowers} outside = [t for t in turns if graded is not None and t not in graded] if outside: diff --git a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge.py b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge.py index 5c9266342..5c67bda37 100644 --- a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge.py +++ b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge.py @@ -44,6 +44,17 @@ always_on run (its record's ``multi_day``) "done" ends nothing, so the ending check is n/a with no call, and every check is told so. +What the assistant is graded on (``grading_of``): when the task is put together (``task_problems``, which every runner +calls with the task's steps) the judge reads the criteria of each rubrics_verifier or always_on_agent_verifier that +grades the run's prompt, and the ids of its env_outcome_verifier steps, whose checks are in their scripts and aren't +listed before they run; a run's seed is filled into the criteria as the graders get it, and ``seeded_from`` keeps them +across the seed's rendering. The judge reads them before the run, and a fail could change the grade only when it +touches one: each judged row names the ids it would change (``would_change``), and a judged fail that names none of +them can't make the run a user sim error (``user_sim_error.not_named``), its score left at 1. A row no model graded (an +auto item, a line that can't be read) names nothing and counts as before. A task with no such steps, or a judge that +wasn't given the task's steps (built outside a task, or a hub worker that renders the seed without ``seeded_from``), +judges could_change_grade as before, and the entry's ``grading`` says which. + A rubric item is the shape of a criterion in a task's ``usersim.yaml`` (psi-benchmark-tasks), which that repo turns into this step's settings; this step reads no file: @@ -96,14 +107,18 @@ check's name or an item's id); what a reviewer reads (a check's ``title`` and ``families``; an item's ``family``, ``kind``, ``check`` or ``line`` and ``line_text``, ``name``, ``short``, ``na_when``, ``asked_with``: the call it rode in, or ``computed``, ``static_na``, ``no_line``); its ``weight``; then its ``verdict`` (pass, fail, n/a, or - error when undecided), ``reason``, ``turns``, ``could_change_grade``, ``assistant_asked`` (whether the assistant + error when undecided), ``reason``, ``turns``, ``could_change_grade``, ``would_change`` (the graded ids a judged + fail that could change the grade names; [] otherwise), ``assistant_asked`` (whether the assistant asked for or invited what was graded: recorded only, never part of the gate; None on a row no model graded), ``score`` and ``result``. A row lowers the score only on a fail that could change the grade at a weight other than 0, so ``score`` is 0 when ``user_sim_error`` is yes, else 1. ``can_be_reward`` is False: the score checks the run, so it is never the task's reward. -- ``user_sim_error``: ``value`` yes / no / unknown, ``because`` and ``unknown`` (the row ids), ``fails_task``, and - ``not_failing`` (why a yes didn't fail the task). ``flag`` when ``value`` is unknown: "user sim judge undecided", or +- ``user_sim_error``: ``value`` yes / no / unknown, ``because`` and ``unknown`` (the row ids), ``not_named`` (the + judged fails that named nothing graded, when there are some), ``fails_task``, and ``not_failing`` (why a yes didn't + fail the task). ``flag`` when ``value`` is unknown: "user sim judge undecided", or "the judge couldn't decide any check — check its setup" when every check is undecided. +- ``grading``: ``source`` task_steps (with ``criteria``, how many; ``criteria_from`` and ``end_state_steps``, the + step ids) or none (with ``note``, why could_change_grade was judged as before). - ``run_step_id``, ``run_kind``, ``user_sim``, ``judge_model``; ``instructions`` (``source``, ``prompt_sha256``, ``recorded_prompt_sha256``, ``matches``); ``rubric_persona`` (when ``rubric_persona_sha256`` is set); ``notes`` (what the judge was told about gaps in the record); ``graded_turns``, ``turns``; ``calls``, ``usage``, ``cost`` (the @@ -145,6 +160,7 @@ import asyncio import copy +import dataclasses import hashlib import json import logging @@ -258,6 +274,15 @@ def __init__( self.rubric_items = list(rubric_items or []) self.rubric_persona_sha256 = rubric_persona_sha256 self._run: Optional[_ThisRun] = None + # What the task's other steps grade the assistant on, read when the task is put together (task_problems); + # None until then, as for a step built outside a task. + self._grading: Optional[core.Grading] = None + + def seeded_from(self, written: "UserSimJudge") -> None: + """This step is ``written`` with the run's seed filled in (``substitute_seed_in_steps``): keep what the task + grades the assistant on, which ``written`` read from the task's steps; the seed is filled into it when it's + read.""" + self._grading = written._grading # ---- settings ---------------------------------------------------------------------------------------------- def criterion_rows(self) -> Optional[int]: @@ -277,6 +302,7 @@ def task_problems(self, steps: list[TaskStep]) -> list[str]: run, found = run_step_of(self, steps, does="judge") if run is None: return found + self._grading = grading_of(run, steps) where = f"{self.type} '{self.id}'" if steps.index(run) > steps.index(self): found.append(f"{where} comes before step '{run.id}', the run it judges; put it after") @@ -352,7 +378,9 @@ async def verify(self, context: TaskStepContext) -> Verification: skipped = "the user sim never read: the run has no user_sim_reads" else: run, about = await asyncio.to_thread(_read_run, kind, step_id, record, context) - entry.update(user_sim=about["user_sim"], instructions=about["instructions"]) + run.grading = _seeded(self._grading, context.metadata.get("seed") or {}) + entry.update(user_sim=about["user_sim"], instructions=about["instructions"], + grading=_grading_entry(self._grading)) if self.rubric_persona_sha256 is not None and items: us = (context.metadata.get(USER_SIMS_KEY) or {}).get(about["user_sim"]) or {} entry["rubric_persona"] = _rubric_persona(self.rubric_persona_sha256, us.get("persona_sha256")) @@ -380,7 +408,10 @@ def _finish(self, judged: RubricsVerdict, entry: dict, this: _ThisRun) -> Verifi """The judge's verdict with its rows in the plan's order and shape, the run's verdict and details, and its score: 0 when a row fails, else 1. A slip the gate counts fails the step once recorded.""" rows = core.finish_rows(judged.criteria, this.plan) - error = core.user_sim_error(rows) + not_named = core.unnamed(rows, this.plan) + error = core.user_sim_error(rows, not_named) + if not_named: + error["not_named"] = not_named error["fails_task"] = False if error["value"] == "yes": if self.fail_task_when_not_passing is not True: @@ -569,6 +600,65 @@ def _rubric_persona(rubric: str, run: Optional[str]) -> dict: return {**out, "status": "match"} +# ---- what the assistant is graded on -------------------------------------------------------------------------------- +END_STATE_TYPE = "env_outcome_verifier" # env_outcome_verifier.EnvOutcomeVerifierTaskStep.type +CRITERION_TEXT_KEYS = ("criterion", "description", "text", "question") # where a grader's criterion keeps its text +GRADING_UNSEEN = ("the judge wasn't given the task's steps, so could_change_grade is judged from each check alone, as " + "before") +GRADING_NONE = ("the task has no step that grades the assistant with criteria or checks its end state, so " + "could_change_grade is judged from each check alone, as before") + + +def grading_of(run: TaskStep, steps: list[TaskStep]) -> core.Grading: + """What the task's steps grade the assistant on in ``run``: the criteria of each rubrics_verifier (an + always_on_agent_verifier among them, never a user sim judge) that grades ``run``'s prompt, or names none, and each + env_outcome_verifier, whose checks are in its script, unread until it runs.""" + prompt = getattr(run, "prompt_id", None) + criteria, source, end_state = [], [], [] + for step in steps: + if step.type == END_STATE_TYPE: + end_state.append(step.id) + elif isinstance(step, RubricsVerifierTaskStep) and not isinstance(step, UserSimJudge): + if prompt is not None and step.prompt_id not in (None, prompt): + continue + texts = [t for i, c in enumerate(step.criteria or [], 1) if (t := _criterion(step.id, i, c))[1].strip()] + if texts: + criteria += texts + source.append(step.id) + return core.Grading(criteria=tuple(criteria), end_state_steps=tuple(end_state), source=tuple(source)) + + +def _criterion(step_id: str, n: int, criterion: Any) -> tuple[str, str]: + """A grader's criterion as ``(id, text)``: its own id, else its step's and its place.""" + if not isinstance(criterion, dict): + return f"{step_id}#{n}", str(criterion) + text = next((criterion[k] for k in CRITERION_TEXT_KEYS if isinstance(criterion.get(k), str)), "") + return str(criterion.get("id") or f"{step_id}#{n}"), text + + +def _seeded(grading: Optional[core.Grading], seed: dict) -> Optional[core.Grading]: + """``grading`` with the run's seed in its criteria, as the graders' own copies have it.""" + if grading is None or not seed: + return grading + + def fill(text: str) -> str: + for key, value in seed.items(): + text = text.replace(f"<{key}>", str(value)) + return text + + return dataclasses.replace(grading, criteria=tuple((cid, fill(text)) for cid, text in grading.criteria)) + + +def _grading_entry(grading: Optional[core.Grading]) -> dict: + """What the entry records of what the judge was told the assistant is graded on.""" + if grading is None: + return {"source": "none", "note": GRADING_UNSEEN} + if not grading.known: + return {"source": "none", "note": GRADING_NONE} + return {"source": "task_steps", "criteria": len(grading.criteria), "criteria_from": list(grading.source), + "end_state_steps": list(grading.end_state_steps)} + + def _prompt_response(context: TaskStepContext, step_id: str) -> Optional[PromptResponse]: return next((p for p in reversed(context.prompt_responses) if p.step_id == step_id), None) diff --git a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py index 3d7223f35..8712fa1b3 100644 --- a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py +++ b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py @@ -31,6 +31,10 @@ A multi-day run's ending check is n/a with no call: there "done" ends only that check-in (``MULTI_DAY_ENDING``), and every check is told so (``MULTI_DAY_NOTE``). + +A run's ``grading`` (``Grading``) is what the task's own graders score the assistant on; when it lists something, the +judge reads it beside the run, and a judged fail counts toward a user sim error only when it names (``would_change``) +something listed (``unnamed``). """ from __future__ import annotations @@ -314,6 +318,26 @@ class Turn: cut: bool = False # ``message`` is only the start of what it sent (the record kept a shortened copy) +@dataclass(frozen=True) +class Grading: + """What the task's own graders score the assistant on, as its other steps say before they run: ``criteria``, each + ``(id, text)``, from the steps that grade the run's prompt with criteria (``source`` names them), and + ``end_state_steps``, the steps that check the end state with a script, whose checks no step lists before it + runs.""" + criteria: tuple[tuple[str, str], ...] = () + end_state_steps: tuple[str, ...] = () + source: tuple[str, ...] = () + + @property + def known(self) -> bool: + return bool(self.criteria or self.end_state_steps) + + @property + def ids(self) -> frozenset[str]: + """What a fail may name in ``would_change``: each criterion's id and each end-state step's.""" + return frozenset([cid for cid, _ in self.criteria] + list(self.end_state_steps)) + + @dataclass class UserSimRun: name: str @@ -324,6 +348,7 @@ class UserSimRun: tagged_lines: Optional[dict[str, str]] = None missing_answers: int = 0 # the run's answers its record didn't keep (always_on's tail drops the earliest) multi_day: bool = False # the run goes on to its end time whatever it answers: "done" ends only that check-in + grading: Optional[Grading] = None # None, or nothing known: could_change_grade is judged from each check alone # ---- a task's own rubric items ------------------------------------------------------------------------------------ @@ -584,11 +609,36 @@ def resolve_lines(items: list[RubricItem], tagged_lines: Optional[dict[str, str] MULTI_DAY_ENDING = "a multi-day run: \"done\" ends nothing, so when it said it doesn't matter" +GRADED_ON = "WHAT THE ASSISTANT IS GRADED ON" +GRADED_ON_RULE = (f"For every criterion's could_change_grade: say true only when the slip touches something listed " + f"under {GRADED_ON}, a process criterion or what the end state is checked for, and put the ids it " + "touches in would_change (a criterion's id in brackets, an end-state step's id). A slip that touches " + "nothing listed can't change the grade: say false. A fail that names no listed id doesn't count.") + + +def render_grading(grading: Grading) -> list[str]: + """The run's ``grading`` as the judge reads it, before the run.""" + out = ["", f"# {GRADED_ON}", + "The task's own graders score the assistant on these after you. They are not the user sim's instructions: " + "never fail the user sim against them. Use them only for could_change_grade.", GRADED_ON_RULE] + if grading.criteria: + out += ["", "Process criteria" + (f" ({', '.join(grading.source)})" if grading.source else "") + ":"] + out += [f"- [{cid}] " + " ".join(text.split()) for cid, text in grading.criteria] + if grading.end_state_steps: + out += ["", f"End state: step{'s' if len(grading.end_state_steps) > 1 else ''} " + f"{', '.join(grading.end_state_steps)} check{'' if len(grading.end_state_steps) > 1 else 's'} the " + "apps' end state with a script whose checks aren't listed here: what ends up in the apps (what is " + "sent, ordered, booked, listed, priced or changed) may be checked."] + return out + + def render_run(run: UserSimRun) -> tuple[str, str]: """The run as the judge reads it, in two parts so a prompt cache can share the first across calls: the instructions and every turn's input up to the last graded turn's answers stay the same for all checks.""" head = ["# THE USER SIM'S INSTRUCTIONS"] head.append("\n" + (run.instructions or "(not recorded)").strip() + "\n") + if run.grading is not None and run.grading.known: + head += render_grading(run.grading) head += ["", "# THE RUN"] if run.multi_day: head.append(f"Note: {MULTI_DAY_NOTE}") @@ -658,15 +708,18 @@ def check_title(name: str) -> str: return f"{c.title} ({', '.join(c.families)})" -def check_question(name: str) -> str: +def check_question(name: str, graded_on: bool = False) -> str: """A check's question as the judge reads it: what it asks, what fails, what doesn't, when it's n/a and when a fail - could change the assistant's grade.""" + could change the assistant's grade; ``graded_on``, the run lists what the assistant is graded on, which that + turns on.""" c = CHECKS[name] lines = [c.question, "", "It fails when, at a graded turn:", *[f"- {f}" for f in c.fails], "", "Not a failure:", *[f"- {f}" for f in c.not_fails], "", c.na or "Answer \"pass\" or \"fail\"; \"n/a\" only if no turn is graded."] if c.grade: - lines += ["", f"could_change_grade: {c.grade}"] + lines += ["", f"could_change_grade: {c.grade}" + ( + f" Only when it touches something under {GRADED_ON}, a criterion or what the end state is checked for, " + "whose ids go in would_change; otherwise false." if graded_on else "")] return "\n".join(lines) @@ -677,8 +730,8 @@ def family_label(family: str) -> str: # ---- one run's criteria and rows ---------------------------------------------------------------------------------- # The fields a row's verdict is in, as a judge's row (judge_output_format's user_sim_checks) or one computed here has # them; a stored row is these, after what a reviewer reads about it. -VERDICT_FIELDS = ("verdict", "reason", "turns", "turns_outside_graded", "could_change_grade", "assistant_asked", - "error", "score", "result", "justification") +VERDICT_FIELDS = ("verdict", "reason", "turns", "turns_outside_graded", "could_change_grade", "would_change", + "assistant_asked", "error", "score", "result", "justification") @dataclass @@ -695,6 +748,9 @@ class Plan: unjudged: list[dict] = field(default_factory=list) about: dict[str, dict] = field(default_factory=dict) order: list[str] = field(default_factory=list) # the row ids: the checks in order, then the task's items + # What a judged fail must name in ``would_change`` to count (``unnamed``); None when the run lists nothing the + # assistant is graded on, and a fail counts as before. + graded_ids: Optional[frozenset[str]] = None def item_weight(item: RubricItem, error_checks: list[str]) -> float: @@ -727,7 +783,8 @@ def plan_run(run: UserSimRun, *, checks: list[str], items: list[RubricItem], err # A check that can't apply to this run is n/a with no call; the items its families own go in the task's call. settled = {"ending": MULTI_DAY_ENDING} if run.multi_day and "ending" in checks else {} calls = plan_calls([c for c in checks if c not in settled], resolved) - plan = Plan(order=list(checks) + [i.id for i in items]) + graded_on = run.grading is not None and run.grading.known + plan = Plan(order=list(checks) + [i.id for i in items], graded_ids=run.grading.ids if graded_on else None) for name in checks: plan.about[name] = {"title": CHECKS[name].title, "families": list(CHECKS[name].families), "weight": 1.0 if name in error_checks else 0.0} @@ -740,7 +797,8 @@ def plan_run(run: UserSimRun, *, checks: list[str], items: list[RubricItem], err for call, its in calls.items(): size = 0 if call_check(call): - plan.criteria.append({"id": call, "check": check_title(call), "question": check_question(call), + plan.criteria.append({"id": call, "check": check_title(call), + "question": check_question(call, graded_on), "graded_turns": graded, "weight": plan.about[call]["weight"]}) size += 1 for item in its: @@ -785,12 +843,29 @@ def finish_rows(rows: list[dict], plan: Plan) -> list[dict]: # ---- the run's verdict -------------------------------------------------------------------------------------------- -def user_sim_error(rows: list[dict]) -> dict: +def unnamed(rows: list[dict], plan: Plan) -> list[str]: + """The judged rows whose fail could change the grade but name nothing the run lists as graded (``would_change`` + holds none of ``plan.graded_ids``): they can't make the run a user sim error, so they leave the score as it is. + Each is set to score 1 here, its verdict and could_change_grade kept. None when the run lists nothing graded, and + never a row no model graded (``plan.unjudged``: an auto item, a line that can't be read), since no judge named.""" + if plan.graded_ids is None: + return [] + computed = {r["id"] for r in plan.unjudged} + out = [] + for r in rows: + if (r["id"] not in computed and r.get("verdict") == "fail" and r.get("could_change_grade") + and not set(r.get("would_change") or []) & plan.graded_ids): + r.update(score=1.0, result=True) + out.append(r["id"]) + return out + + +def user_sim_error(rows: list[dict], not_counted: tuple[str, ...] | list[str] = ()) -> dict: """Whether the run is a user sim error, by one rule for checks and task items: ``value`` yes when a row at a weight other than 0 failed in a way that could change the grade (``because`` names them); unknown when none did but such a row is undecided (``error``: its judge never gave a usable answer, or it couldn't be counted or read); else no. - A weight-0 row (style, by default) never makes it either.""" - counts = [r for r in rows if float(r.get("weight", 1.0)) != 0] + A weight-0 row (style, by default) never makes it either, nor a row in ``not_counted`` (``unnamed``).""" + counts = [r for r in rows if float(r.get("weight", 1.0)) != 0 and r["id"] not in not_counted] because = [r["id"] for r in counts if r.get("verdict") == "fail" and r.get("could_change_grade")] unknown = [r["id"] for r in counts if r.get("verdict") == "error"] return {"value": "yes" if because else "unknown" if unknown else "no", "because": because, "unknown": unknown} diff --git a/tst/data/verifier_golden/judge_inputs.json b/tst/data/verifier_golden/judge_inputs.json index 9ee24661e..2a7b316ed 100644 --- a/tst/data/verifier_golden/judge_inputs.json +++ b/tst/data/verifier_golden/judge_inputs.json @@ -379,13 +379,13 @@ } ], "prompt": { - "sha256": "09de31e19cd5dbb53b10841b7e7ee1ed419853bc8e4dae26ec2c10aa1d665818", - "chars": 16107 + "sha256": "280f0240bacd8e96d13cee0281cacd928157bd42f79725587cd89d228c9288c2", + "chars": 16400 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "97b132dbbf572478f41d04e22cb84d4b84fc0b79d3c814ad16c28a91cba4c540", - "chars": 14258 + "sha256": "4b357fec0d7dab6eae1172f55d6f183b02ccab5fd44597512ed27fb169485c8c", + "chars": 14551 } }, { @@ -409,13 +409,13 @@ } ], "prompt": { - "sha256": "b3a6c11e33db7114ddd2052c6cdf25c63b503e3e4e44f0fa092e0413e6261771", - "chars": 17607 + "sha256": "265153eb344298a96870a38a3a51f43af9c5ab1d406759ec929fea1f8a68321f", + "chars": 17900 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "97b132dbbf572478f41d04e22cb84d4b84fc0b79d3c814ad16c28a91cba4c540", - "chars": 14258 + "sha256": "4b357fec0d7dab6eae1172f55d6f183b02ccab5fd44597512ed27fb169485c8c", + "chars": 14551 } }, { @@ -439,13 +439,13 @@ } ], "prompt": { - "sha256": "e7f735fa76de7ef83ac2cd22f4775d4bf9cba0af8ae99d598f6a4a8653c580a4", - "chars": 16119 + "sha256": "bb2ad72591844624ba90cbe8e152984c5d9725a939865ecc28042d8047a91d10", + "chars": 16412 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "97b132dbbf572478f41d04e22cb84d4b84fc0b79d3c814ad16c28a91cba4c540", - "chars": 14258 + "sha256": "4b357fec0d7dab6eae1172f55d6f183b02ccab5fd44597512ed27fb169485c8c", + "chars": 14551 } }, { @@ -469,13 +469,13 @@ } ], "prompt": { - "sha256": "c49d79f511dc45e7bfa413c3f59f66d026614f0c014b1a4de4a0c8dcf49bf3b9", - "chars": 17211 + "sha256": "d969eeb1ab340ba43da999540f74562d3eb9fb2bf8656d05ccbc63b64fe7cde1", + "chars": 17504 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "97b132dbbf572478f41d04e22cb84d4b84fc0b79d3c814ad16c28a91cba4c540", - "chars": 14258 + "sha256": "4b357fec0d7dab6eae1172f55d6f183b02ccab5fd44597512ed27fb169485c8c", + "chars": 14551 } }, { @@ -499,13 +499,13 @@ } ], "prompt": { - "sha256": "34e329a4918c48739c224355f8b9d2cc9968b889f5fe27536e967abe60d52639", - "chars": 16507 + "sha256": "cd832d1fe2ca0e4d74cfca3f36535693c67ecbb6d9424ddb2d3a38961fda460a", + "chars": 16800 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "97b132dbbf572478f41d04e22cb84d4b84fc0b79d3c814ad16c28a91cba4c540", - "chars": 14258 + "sha256": "4b357fec0d7dab6eae1172f55d6f183b02ccab5fd44597512ed27fb169485c8c", + "chars": 14551 } }, { @@ -529,13 +529,13 @@ } ], "prompt": { - "sha256": "bbaa7c50169ef96c8a25b88124a9b152f364906e10d550f9c135644a011c90f9", - "chars": 16098 + "sha256": "79e6f53d25eef1dd6467fb1a496b3edb502f029169b434bf17c9875be1d9715d", + "chars": 16391 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "97b132dbbf572478f41d04e22cb84d4b84fc0b79d3c814ad16c28a91cba4c540", - "chars": 14258 + "sha256": "4b357fec0d7dab6eae1172f55d6f183b02ccab5fd44597512ed27fb169485c8c", + "chars": 14551 } } ], @@ -1595,13 +1595,13 @@ } ], "prompt": { - "sha256": "938215dcd4606c267a7b8a40914e352d896667a50e4a65ad66b8347d73d7a382", - "chars": 15104 + "sha256": "9abac25f4e250eede3461536cfcb6cae720a49660acf91707e4d45dccd077a50", + "chars": 15397 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "268023e8ef3618b94aff6b472a8fd2dc522e07d69b7d19223b4a3c0b316f763d", - "chars": 13255 + "sha256": "82132a2bde09ed3f0124c275c6a9efd38619f366f37710d37ef43dc16b93f1ed", + "chars": 13548 } }, { @@ -1625,13 +1625,13 @@ } ], "prompt": { - "sha256": "26c4cc4c2312a08b0c01148487200602cc93a8c6b6a54db1f9aa1482ef6d8ef6", - "chars": 14671 + "sha256": "b78320efa2f1859e0f79d5e8896f738c79c387f022ed11e1c3c017c59081cd85", + "chars": 14964 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "268023e8ef3618b94aff6b472a8fd2dc522e07d69b7d19223b4a3c0b316f763d", - "chars": 13255 + "sha256": "82132a2bde09ed3f0124c275c6a9efd38619f366f37710d37ef43dc16b93f1ed", + "chars": 13548 } }, { @@ -1655,13 +1655,13 @@ } ], "prompt": { - "sha256": "7c0ddfd357a301cd663e80b163030fcb0712fa80740678b1e5d0062a3f13cdd4", - "chars": 16604 + "sha256": "6cd7da54b5fa419858e4d15d16584964592828e0f6e98795c26f3637f92dc1a6", + "chars": 16897 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "268023e8ef3618b94aff6b472a8fd2dc522e07d69b7d19223b4a3c0b316f763d", - "chars": 13255 + "sha256": "82132a2bde09ed3f0124c275c6a9efd38619f366f37710d37ef43dc16b93f1ed", + "chars": 13548 } }, { @@ -1685,13 +1685,13 @@ } ], "prompt": { - "sha256": "d4feca470efb836fc3fded3f8a76509a6468270111710c7007bd2ece77bcf12f", - "chars": 15116 + "sha256": "775b9ba0f47fb9cca859adbbf3aa2d7e64e3be618477c832e6b4f50ced72960e", + "chars": 15409 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "268023e8ef3618b94aff6b472a8fd2dc522e07d69b7d19223b4a3c0b316f763d", - "chars": 13255 + "sha256": "82132a2bde09ed3f0124c275c6a9efd38619f366f37710d37ef43dc16b93f1ed", + "chars": 13548 } }, { @@ -1715,13 +1715,13 @@ } ], "prompt": { - "sha256": "5f198b9878bc0139ed0a86c02b9e4e854aee637a307f7e05a88250bc35fca821", - "chars": 16208 + "sha256": "1db555fa996ebb57b5815f01077c8fd5e1805ea7cc7f0c2658fcb95d8a4c7a19", + "chars": 16501 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "268023e8ef3618b94aff6b472a8fd2dc522e07d69b7d19223b4a3c0b316f763d", - "chars": 13255 + "sha256": "82132a2bde09ed3f0124c275c6a9efd38619f366f37710d37ef43dc16b93f1ed", + "chars": 13548 } }, { @@ -1745,13 +1745,13 @@ } ], "prompt": { - "sha256": "07240aa6cac93d657223e7431a3d11ffd23941d36429e2ec5bc34fb66af85622", - "chars": 15504 + "sha256": "d48f0b6a454adad11c062708bc408b0dc9d5b92e11a7a8c12595ff92d24547fd", + "chars": 15797 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "268023e8ef3618b94aff6b472a8fd2dc522e07d69b7d19223b4a3c0b316f763d", - "chars": 13255 + "sha256": "82132a2bde09ed3f0124c275c6a9efd38619f366f37710d37ef43dc16b93f1ed", + "chars": 13548 } }, { @@ -1775,13 +1775,13 @@ } ], "prompt": { - "sha256": "30c4ca22a5dd9e2f7660f2b5354204f668189dcc54a0c5e143a59da6dc2b48ad", - "chars": 15095 + "sha256": "fcf74531527281ef7fd4c0565f6f792f4cc18c72c1fa642149200e4f958e74a7", + "chars": 15388 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "268023e8ef3618b94aff6b472a8fd2dc522e07d69b7d19223b4a3c0b316f763d", - "chars": 13255 + "sha256": "82132a2bde09ed3f0124c275c6a9efd38619f366f37710d37ef43dc16b93f1ed", + "chars": 13548 } } ], diff --git a/tst/data/verifier_golden/rubrics_subclasses.json b/tst/data/verifier_golden/rubrics_subclasses.json index 206025f8e..d68a02121 100644 --- a/tst/data/verifier_golden/rubrics_subclasses.json +++ b/tst/data/verifier_golden/rubrics_subclasses.json @@ -15,6 +15,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -32,6 +33,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -48,6 +50,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -67,6 +70,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -84,6 +88,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -100,6 +105,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -116,6 +122,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -148,6 +155,10 @@ "recorded_prompt_sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "matches": true }, + "grading": { + "source": "none", + "note": "the judge wasn't given the task's steps, so could_change_grade is judged from each check alone, as before" + }, "graded_turns": [ 1 ], @@ -195,6 +206,7 @@ 1 ], "could_change_grade": true, + "would_change": [], "assistant_asked": false, "score": 0.0, "result": false, @@ -212,6 +224,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -228,6 +241,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -247,6 +261,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -264,6 +279,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -280,6 +296,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -296,6 +313,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -314,6 +332,7 @@ 1 ], "could_change_grade": true, + "would_change": [], "assistant_asked": false, "score": 0.0, "result": false, @@ -346,6 +365,10 @@ "recorded_prompt_sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "matches": true }, + "grading": { + "source": "none", + "note": "the judge wasn't given the task's steps, so could_change_grade is judged from each check alone, as before" + }, "graded_turns": [ 1 ], @@ -396,6 +419,7 @@ 1 ], "could_change_grade": true, + "would_change": [], "assistant_asked": false, "score": 0.0, "result": false, @@ -413,6 +437,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -429,6 +454,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -448,6 +474,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -465,6 +492,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -481,6 +509,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -497,6 +526,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -529,6 +559,10 @@ "recorded_prompt_sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "matches": false }, + "grading": { + "source": "none", + "note": "the judge wasn't given the task's steps, so could_change_grade is judged from each check alone, as before" + }, "graded_turns": [ 1 ], @@ -578,6 +612,10 @@ "recorded_prompt_sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "matches": true }, + "grading": { + "source": "none", + "note": "the judge wasn't given the task's steps, so could_change_grade is judged from each check alone, as before" + }, "graded_turns": [], "turns": 1, "notes": [], @@ -608,6 +646,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -625,6 +664,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -641,6 +681,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -660,6 +701,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -677,6 +719,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -693,6 +736,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -709,6 +753,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -741,6 +786,10 @@ "recorded_prompt_sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "matches": true }, + "grading": { + "source": "none", + "note": "the judge wasn't given the task's steps, so could_change_grade is judged from each check alone, as before" + }, "rubric_persona": { "rubric": "1111111111111111111111111111111111111111111111111111111111111111", "run": "0000000000000000000000000000000000000000000000000000000000000000", @@ -792,6 +841,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -809,6 +859,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -825,6 +876,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -844,6 +896,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -861,6 +914,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -877,6 +931,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -893,6 +948,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -941,6 +997,10 @@ "recorded_prompt_sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "matches": true }, + "grading": { + "source": "none", + "note": "the judge wasn't given the task's steps, so could_change_grade is judged from each check alone, as before" + }, "rubric_persona": { "rubric": "1111111111111111111111111111111111111111111111111111111111111111", "run": null, @@ -995,6 +1055,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -1012,6 +1073,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -1028,6 +1090,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -1047,6 +1110,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -1080,6 +1144,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -1096,6 +1161,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -1128,6 +1194,10 @@ "recorded_prompt_sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "matches": true }, + "grading": { + "source": "none", + "note": "the judge wasn't given the task's steps, so could_change_grade is judged from each check alone, as before" + }, "graded_turns": [ 1 ], @@ -1309,6 +1379,10 @@ "recorded_prompt_sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "matches": true }, + "grading": { + "source": "none", + "note": "the judge wasn't given the task's steps, so could_change_grade is judged from each check alone, as before" + }, "graded_turns": [ 1 ], @@ -1364,6 +1438,7 @@ 1 ], "could_change_grade": true, + "would_change": [], "assistant_asked": false, "score": 0.0, "result": false, @@ -1381,6 +1456,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -1397,6 +1473,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -1416,6 +1493,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -1433,6 +1511,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -1449,6 +1528,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -1465,6 +1545,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -1512,6 +1593,10 @@ "recorded_prompt_sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "matches": true }, + "grading": { + "source": "none", + "note": "the judge wasn't given the task's steps, so could_change_grade is judged from each check alone, as before" + }, "graded_turns": [ 1 ], @@ -1560,6 +1645,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -1577,6 +1663,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -1593,6 +1680,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -1612,6 +1700,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -1629,6 +1718,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -1645,6 +1735,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -1661,6 +1752,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -1714,6 +1806,10 @@ "recorded_prompt_sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "matches": true }, + "grading": { + "source": "none", + "note": "the judge wasn't given the task's steps, so could_change_grade is judged from each check alone, as before" + }, "graded_turns": [ 1 ], @@ -1762,6 +1858,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -1779,6 +1876,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -1795,6 +1893,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -1814,6 +1913,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -1831,6 +1931,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -1847,6 +1948,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -1863,6 +1965,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -1896,6 +1999,10 @@ "recorded_prompt_sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "matches": true }, + "grading": { + "source": "none", + "note": "the judge wasn't given the task's steps, so could_change_grade is judged from each check alone, as before" + }, "graded_turns": [ 1 ], @@ -1997,6 +2104,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -2016,6 +2124,7 @@ 1 ], "could_change_grade": true, + "would_change": [], "assistant_asked": false, "score": 0.0, "result": false, @@ -2032,6 +2141,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -2051,6 +2161,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -2068,6 +2179,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -2084,6 +2196,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -2100,6 +2213,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -2132,6 +2246,10 @@ "recorded_prompt_sha256": "40243a6be42eadd882c5e9f09542938219bb53f6383dde1badd5e922681ba11a", "matches": true }, + "grading": { + "source": "none", + "note": "the judge wasn't given the task's steps, so could_change_grade is judged from each check alone, as before" + }, "graded_turns": [ 1, 2 @@ -2188,6 +2306,7 @@ 2 ], "could_change_grade": true, + "would_change": [], "assistant_asked": false, "score": 0.0, "result": false, @@ -2205,6 +2324,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -2221,6 +2341,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -2240,6 +2361,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -2257,6 +2379,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -2273,6 +2396,7 @@ "reason": "fine", "turns": [], "could_change_grade": false, + "would_change": [], "assistant_asked": false, "score": 1.0, "result": true, @@ -2320,6 +2444,10 @@ "recorded_prompt_sha256": "7172e450e74d2c140ba06e2303c544549430f63e2b758e534b64f93a319d43a3", "matches": true }, + "grading": { + "source": "none", + "note": "the judge wasn't given the task's steps, so could_change_grade is judged from each check alone, as before" + }, "graded_turns": [ 1, 2 diff --git a/tst/unit/task_step/verifiers/judge_utils/test_user_sim_checks_format.py b/tst/unit/task_step/verifiers/judge_utils/test_user_sim_checks_format.py index 1199852a5..5662af2a0 100644 --- a/tst/unit/task_step/verifiers/judge_utils/test_user_sim_checks_format.py +++ b/tst/unit/task_step/verifiers/judge_utils/test_user_sim_checks_format.py @@ -129,18 +129,44 @@ def test_the_judge_is_told_how_to_read_the_run_and_the_criteria_fields(): # ---- schema ------------------------------------------------------------------------------------------------------- -def test_each_row_gives_its_reason_first_then_turns_verdict_could_change_grade_and_assistant_asked(): +def test_each_row_gives_its_reason_first_then_turns_verdict_could_change_grade_would_change_and_assistant_asked(): schema = SPEC.output_format assert schema["type"] == "json_schema" and schema["schema"]["required"] == ["results"] row = schema["schema"]["properties"]["results"]["items"] - order = ["id", "reason", "turns", "verdict", "could_change_grade", "assistant_asked"] + # would_change is required in the schema, as strict structured output needs every property; the parser doesn't. + order = ["id", "reason", "turns", "verdict", "could_change_grade", "would_change", "assistant_asked"] assert list(row["properties"]) == order == row["required"] assert row["properties"]["verdict"]["enum"] == ["pass", "fail", "n/a"] assert row["properties"]["turns"] == {"type": "array", "items": {"type": "integer"}} assert row["properties"]["could_change_grade"] == row["properties"]["assistant_asked"] == {"type": "boolean"} + assert row["properties"]["would_change"] == {"type": "array", "items": {"type": "string"}} assert row["additionalProperties"] is False and schema["schema"]["additionalProperties"] is False +def test_a_fail_keeps_the_graded_ids_it_names_and_an_answer_from_before_would_change_still_parses(): + criteria = _criteria("c1", "c2", "c3") + rows, discrepancy = diagnose_user_sim_checks_response(_answer( + _fail("c1", would_change=["forecast", " "]), _row("c2", would_change=["forecast"]), _fail("c3")), criteria) + assert discrepancy is None + named, passed, old = rows + assert named["would_change"] == ["forecast"] # blanks dropped + assert passed["would_change"] == [] and old["would_change"] == [] # a pass names nothing; an old answer neither + assert old["could_change_grade"] is True and old["score"] == 0.0 # the format scores as before; the judge gates + + +def test_a_would_change_that_is_not_a_list_of_ids_is_asked_again(): + rows, discrepancy = diagnose_user_sim_checks_response(_answer(_fail("c1", would_change="forecast")), + _criteria("c1")) + assert rows is None and "c1: would_change must be a list of the ids it would change" in str(discrepancy) + + +def test_the_judge_is_told_to_name_what_a_fail_would_change(): + prompt = _render(SPEC.prompt_template_inline) + assert '"would_change" names what it would change' in prompt and "[] when could_change_grade is" in prompt + shape = prompt.split("Return only this JSON object")[1] + assert shape.index('"could_change_grade"') < shape.index('"would_change"') < shape.index('"assistant_asked"') + + # ---- reading an answer -------------------------------------------------------------------------------------------- def test_an_answer_is_read_into_rows_with_turns_kept_to_the_graded_ones(): criteria = _criteria("c1", "c2", graded=[2], family="G1") diff --git a/tst/unit/task_step/verifiers/test_user_sim_judge.py b/tst/unit/task_step/verifiers/test_user_sim_judge.py index 2a68e6c48..11f7adf18 100644 --- a/tst/unit/task_step/verifiers/test_user_sim_judge.py +++ b/tst/unit/task_step/verifiers/test_user_sim_judge.py @@ -16,6 +16,7 @@ from agent_env.config.model import ModelConfig, resolve_model from agent_env.openenv.reward import reward_of from agent_env.task import Task +from agent_env.task.task import substitute_seed_in_steps from agent_env.task_step.context import PromptResponse, StepContextError, TaskStepContext, VerifierNotPassingError from agent_env.task_step.registry import _builtin_registry from agent_env.task_step.task_step import TaskStepDependency @@ -142,8 +143,10 @@ def _run(*answers: tuple[str, str], graded=None) -> core.UserSimRun: turns=turns) -async def _judge(run: core.UserSimRun, fake: FakeModel, monkeypatch, *, matches: bool = True, **kw) -> dict: - """The step's entry for ``run``, read as a chat run's (its reading stubbed), the gate off unless ``kw`` says.""" +async def _judge(run: core.UserSimRun, fake: FakeModel, monkeypatch, *, matches: bool = True, + grading: core.Grading | None = None, **kw) -> dict: + """The step's entry for ``run``, read as a chat run's (its reading stubbed), the gate off unless ``kw`` says; + ``grading``, what the task's other steps grade the assistant on, as the step reads them when the task loads.""" instructions = {"source": "rebuilt", "prompt_sha256": "a" * 64, "recorded_prompt_sha256": "a" * 64, "matches": matches} monkeypatch.setattr(usj, "_read_run", lambda kind, step_id, record, context: ( @@ -152,7 +155,9 @@ async def _judge(run: core.UserSimRun, fake: FakeModel, monkeypatch, *, matches: ctx.prompt_responses.append(PromptResponse(prompt_id="ask", response="all set", step_id="talk")) ctx.metadata["user_sim_reads"] = {"talk": [{}]} ctx.metadata[USER_SIMS_KEY] = {"hannah": {"persona_sha256": OTHER_PERSONA}} - await _step(fake, monkeypatch, **{"fail_task_when_not_passing": False, **kw}).execute(ctx) + step = _step(fake, monkeypatch, **{"fail_task_when_not_passing": False, **kw}) + step._grading = grading + await step.execute(ctx) return _entry(ctx) @@ -256,7 +261,8 @@ async def test_the_judge_writes_its_reason_before_its_verdict_within_the_word_li assert prompt.index("# THE USER SIM'S INSTRUCTIONS") < prompt.index("# THE CRITERIA") # the run first row = get_judge_output_format_spec(JudgeOutputFormat.USER_SIM_CHECKS).output_format["schema"]["properties"][ "results"]["items"] - assert list(row["properties"]) == ["id", "reason", "turns", "verdict", "could_change_grade", "assistant_asked"] + assert list(row["properties"]) == ["id", "reason", "turns", "verdict", "could_change_grade", "would_change", + "assistant_asked"] # ---- one run, through the step ---------------------------------------------------------------------------------- @@ -269,8 +275,8 @@ async def test_each_check_s_verdict_is_recorded_with_its_reason_and_turns(monkey "made_up": "fail", "ending": "pass"} assert _rows(entry)["made_up"] == { "id": "made_up", "title": "Made-up facts", "families": ["A2"], "weight": 1.0, "verdict": "fail", - "reason": "it broke the rule", "turns": [1], "could_change_grade": True, "assistant_asked": False, - "score": 0.0, "result": False, "justification": "it broke the rule"} + "reason": "it broke the rule", "turns": [1], "could_change_grade": True, "would_change": [], + "assistant_asked": False, "score": 0.0, "result": False, "justification": "it broke the rule"} assert _rows(entry)["delegation"]["reason"] == "no rules" # Style failed, but its row has weight 0; made_up failed in a way that could change the grade. assert _rows(entry)["style"]["weight"] == 0.0 and _rows(entry)["style"]["result"] is True @@ -412,7 +418,8 @@ async def test_task_items_get_their_own_rows_and_one_rule_says_which_make_a_user assert _rows(entry)["leak"] == { "id": "leak", "family": "G1", "kind": "general", "check": "never hints at the engagement", "asked_with": "oversharing", "weight": 1.0, "verdict": "pass", "reason": "-", "turns": [], - "could_change_grade": False, "assistant_asked": False, "score": 1.0, "result": True, "justification": "-"} + "could_change_grade": False, "would_change": [], "assistant_asked": False, "score": 1.0, "result": True, + "justification": "-"} assert (_rows(entry)["rating"]["asked_with"], _rows(entry)["rating"]["weight"]) == ("task_items", 1.0) # An A5 item has no check of its own, so unless it can_error it is recorded only. assert _rows(entry)["tone"]["verdict"] == "fail" and _rows(entry)["tone"]["weight"] == 0.0 @@ -1680,3 +1687,83 @@ async def test_oversharing_looks_for_the_assistant_s_question_first_and_its_reas entry = await _judge(run, unasked, monkeypatch) assert "fernhill" not in sent.lower() # nothing it was sent at that turn asks about them assert _rows(entry)["oversharing"]["verdict"] == "fail" and entry["user_sim_error"]["because"] == ["oversharing"] + + +SHOP_GRADING = core.Grading( + criteria=(("forecast", "Built the holiday forecast from last season's orders by scent and size."), + ("buyers_answered", "Answered both buyers with the owner's decisions, Odile's price floor kept.")), + end_state_steps=("verify-state",), source=("process",)) + + +def _graded_task(**judge): + from agent_env.task_step.task_steps.verifiers.always_on_agent_verifier import AlwaysOnAgentVerifier + from agent_env.task_step.task_steps.verifiers.env_outcome_verifier import EnvOutcomeVerifierTaskStep + + deploy, week = _user_sim_steps() + j = usj.UserSimJudge("judge", None, run_step_id="week", **judge) + after = [TaskStepDependency("judge")] + process = AlwaysOnAgentVerifier("grade", None, prompt_id="ask", verifier_id="grade", use_agent_judge=False, + depends_on=after, criteria=[ + {"id": "forecast", "criterion": "Built the forecast for ."}, + {"id": "honest", "description": "Its last message says what is still open."}]) + elsewhere = AlwaysOnAgentVerifier("other", None, prompt_id="another-prompt", verifier_id="other", + use_agent_judge=False, depends_on=after, + criteria=[{"id": "other", "description": "x"}]) + state = EnvOutcomeVerifierTaskStep("verify-state", None, env_id="env", file_artifact_id="script", + verifier_id="trust", depends_on=after) + return Task("t", None, [deploy, week, j, process, elsewhere, state]), j + + +def test_when_the_task_loads_the_judge_reads_what_its_other_steps_grade_the_assistant_on(): + task, judge = _graded_task() + assert judge._grading == core.Grading( + criteria=(("forecast", "Built the forecast for ."), ("honest", "Its last message says what is still " + "open.")), + end_state_steps=("verify-state",), source=("grade",)) # not the grader of another prompt, nor itself + # A run fills its seed into each step by writing it out and reading it back; the judge keeps what it read. + [seeded] = [s for s in substitute_seed_in_steps(task.steps, {"season": "2026"}) if s.id == "judge"] + assert seeded._grading == judge._grading + assert usj._seeded(seeded._grading, {"season": "2026"}).criteria[0] == ("forecast", "Built the forecast for 2026.") + assert usj.UserSimJudge("judge", None, run_step_id="week")._grading is None # outside a task, none was read + + +@pytest.mark.asyncio +async def test_the_judge_reads_what_the_assistant_is_graded_on_and_a_fail_counts_only_when_it_names_it(monkeypatch): + fake = FakeModel({"made_up": FAIL(would_change=["buyers_answered"]), "rogue": FAIL(would_change=[]), + "guidance": FAIL(would_change=["not-listed"])}) + entry = await _judge(_shop(multi_day=False), fake, monkeypatch, grading=SHOP_GRADING) + head = fake.calls[0]["cached_prefix"] + assert "# " + core.GRADED_ON in head and core.GRADED_ON_RULE in head + assert "- [buyers_answered] Answered both buyers" in head and "End state: step verify-state checks" in head + assert head.index(core.GRADED_ON) < head.index("# THE RUN") # in the part every call shares + assert "whose ids go in would_change" in fake.asked("made_up")[0]["criteria"][0]["question"] + assert entry["grading"] == {"source": "task_steps", "criteria": 2, "criteria_from": ["process"], + "end_state_steps": ["verify-state"]} + error = entry["user_sim_error"] + assert error["value"] == "yes" and error["because"] == ["made_up"] + assert error["not_named"] == ["guidance", "rogue"] # named nothing listed, so they don't count + assert _rows(entry)["rogue"]["verdict"] == "fail" and _rows(entry)["rogue"]["could_change_grade"] is True + assert _rows(entry)["rogue"]["result"] is True and _rows(entry)["made_up"]["result"] is False + unnamed_only = await _judge(_shop(multi_day=False), FakeModel({"rogue": FAIL()}), monkeypatch, + grading=SHOP_GRADING) + assert unnamed_only["user_sim_error"]["value"] == "no" and unnamed_only["score"] == 1.0 + + +@pytest.mark.asyncio +async def test_without_the_task_s_grading_a_fail_counts_as_before_and_the_entry_says_why(monkeypatch): + unseen = await _judge(_shop(multi_day=False), FakeModel({"rogue": FAIL()}), monkeypatch) + assert unseen["grading"] == {"source": "none", "note": usj.GRADING_UNSEEN} + assert unseen["user_sim_error"]["because"] == ["rogue"] and "not_named" not in unseen["user_sim_error"] + fake = FakeModel({"rogue": FAIL()}) + none = await _judge(_shop(multi_day=False), fake, monkeypatch, grading=core.Grading()) + assert none["grading"] == {"source": "none", "note": usj.GRADING_NONE} + assert none["user_sim_error"]["because"] == ["rogue"] and "# " + core.GRADED_ON not in fake.run_text() + _, judge = _graded_task() + assert judge.task_problems([*_user_sim_steps(), judge]) == [] and judge._grading == core.Grading() + + +@pytest.mark.asyncio +async def test_an_auto_item_s_counted_fail_still_counts_when_the_task_lists_what_it_grades(monkeypatch): + items = [{"id": "f2_short", "family": "F2", "kind": "auto", "metric": "max_words", "max": 5, "can_error": True}] + entry = await _judge(_shop(multi_day=False), FakeModel(), monkeypatch, rubric_items=items, grading=SHOP_GRADING) + assert entry["user_sim_error"]["because"] == ["f2_short"] # no judge named it, so naming isn't asked of it From ca7990ea4ae5ba8bcb1f31e289cff36eabcc4ad6 Mon Sep 17 00:00:00 2001 From: Sarah Chitty Date: Mon, 23 Nov 2026 20:17:04 -0800 Subject: [PATCH 11/20] feat(scripts): user_sim_discards.py, the user sim judge's discards per assistant model, read from run records Co-Authored-By: Claude Opus 5.5 --- scripts/user_sim_discards.py | 99 ++++++++++++++++++++++++++++++ tst/unit/test_user_sim_discards.py | 49 +++++++++++++++ 2 files changed, 148 insertions(+) create mode 100644 scripts/user_sim_discards.py create mode 100644 tst/unit/test_user_sim_discards.py diff --git a/scripts/user_sim_discards.py b/scripts/user_sim_discards.py new file mode 100644 index 000000000..6d21646b0 --- /dev/null +++ b/scripts/user_sim_discards.py @@ -0,0 +1,99 @@ +"""How often the user sim judge discards runs, per assistant model: read-only, over run records. + + python scripts/user_sim_discards.py RECORD_OR_FOLDER [...] [--json] + +A record is a task instance as a run stores it (``{"context": {...}}``), its context alone, or a JSON list of them; a +folder is searched for ``*.json`` records. Each user_sim_judge entry (``metadata["verifications"]``, format +``user_sim_checks``) that judged its run counts once, under the model that played the assistant in the run it judged +(``metadata["models"]["solver"][run_step_id]``, else the context's ``agent_model``, else "unknown"). For each model it +prints the runs judged, those discarded (``user_sim_error`` yes), those unknown (undecided), the discard rate, and per +check how many discards it was behind. Skipped entries (the run ended in an error, no graded turn) aren't judged runs. +""" +from __future__ import annotations + +import argparse +import json +import sys +from collections import Counter, defaultdict +from pathlib import Path +from typing import Any, Iterator + +FORMAT = "user_sim_checks" + + +def contexts(value: Any) -> Iterator[dict]: + """The run contexts in a loaded record: an instance's ``context``, a context, or a list of either.""" + if isinstance(value, list): + for v in value: + yield from contexts(v) + elif isinstance(value, dict): + if isinstance(value.get("context"), dict): + yield value["context"] + elif isinstance(value.get("metadata"), dict): + yield value + + +def records(paths: list[str]) -> Iterator[tuple[str, dict]]: + for p in map(Path, paths): + for f in sorted(p.rglob("*.json")) if p.is_dir() else [p]: + try: + loaded = json.loads(f.read_text()) + except (OSError, ValueError): + continue + for ctx in contexts(loaded): + yield str(f), ctx + + +def judged_runs(ctx: dict) -> Iterator[tuple[str, dict]]: + """``(assistant model, entry)`` for each user sim judge entry in a context that judged its run.""" + md = ctx.get("metadata") or {} + solvers = (md.get("models") or {}).get("solver") or {} + for entry in (md.get("verifications") or {}).values(): + if not isinstance(entry, dict) or entry.get("format") != FORMAT or entry.get("skipped"): + continue + model = solvers.get(entry.get("run_step_id")) or ctx.get("agent_model") or "unknown" + yield str(model), entry + + +def tally(paths: list[str]) -> dict[str, dict]: + out: dict[str, dict] = defaultdict(lambda: {"judged": 0, "discarded": 0, "unknown": 0, "checks": Counter()}) + seen = set() + for _, ctx in records(paths): + key = ctx.get("instance_id") or (ctx.get("metadata") or {}).get("instance_id") or id(ctx) + if key in seen: # the same run exported twice + continue + seen.add(key) + for model, entry in judged_runs(ctx): + error = entry.get("user_sim_error") or {} + row = out[model] + row["judged"] += 1 + if error.get("value") == "yes": + row["discarded"] += 1 + row["checks"].update(error.get("because") or []) + elif error.get("value") == "unknown": + row["unknown"] += 1 + return {m: {**r, "rate": r["discarded"] / r["judged"] if r["judged"] else None, "checks": dict(r["checks"])} + for m, r in sorted(out.items())} + + +def main(argv: list[str] | None = None) -> int: + p = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) + p.add_argument("paths", nargs="+") + p.add_argument("--json", action="store_true", help="print the tally as JSON") + a = p.parse_args(argv) + got = tally(a.paths) + if a.json: + print(json.dumps(got, indent=1)) + return 0 + if not got: + print("no judged runs found", file=sys.stderr) + return 1 + print(f"{'assistant model':32} {'judged':>6} {'discarded':>9} {'unknown':>7} {'rate':>6} discards by check") + for model, r in got.items(): + checks = ", ".join(f"{c} {n}" for c, n in sorted(r["checks"].items(), key=lambda x: -x[1])) or "-" + print(f"{model:32} {r['judged']:>6} {r['discarded']:>9} {r['unknown']:>7} {r['rate']:>6.0%} {checks}") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tst/unit/test_user_sim_discards.py b/tst/unit/test_user_sim_discards.py new file mode 100644 index 000000000..7a15b307b --- /dev/null +++ b/tst/unit/test_user_sim_discards.py @@ -0,0 +1,49 @@ +"""scripts/user_sim_discards.py: the user sim judge's discards per assistant model, read from run records.""" +from __future__ import annotations + +import importlib.util +import json +import subprocess +import sys +from pathlib import Path + +SCRIPT = Path(__file__).resolve().parents[2] / "scripts" / "user_sim_discards.py" +_spec = importlib.util.spec_from_file_location("user_sim_discards", SCRIPT) +discards = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(discards) + + +def _instance(n: int, model: str, value: str | None, because=(), skipped: str | None = None) -> dict: + entry = {"format": "user_sim_checks", "run_step_id": "week", "user_sim_error": {"value": value, + "because": list(because)}} + if skipped: + entry = {**entry, "skipped": skipped, "user_sim_error": {"value": "no"}} + return {"instance_id": f"run-{n}", "context": {"metadata": { + "instance_id": f"run-{n}", "models": {"solver": {"week": model}}, + "verifications": {"usj": entry, "psi_process": {"format": "rubric_partial", "score": 0.5}}}}} + + +def _records(tmp_path: Path) -> Path: + runs = [_instance(1, "claude-opus-5-5", "no"), _instance(2, "claude-opus-5-5", "yes", ["ending"]), + _instance(3, "qwen-flash-next", "yes", ["ending", "oversharing"]), + _instance(4, "qwen-flash-next", "unknown"), _instance(5, "qwen-flash-next", "yes", ["ending"]), + _instance(6, "qwen-flash-next", None, skipped="the run ended with error_type=timeout")] + for i, run in enumerate(runs): + (tmp_path / f"r{i}.json").write_text(json.dumps(run)) + (tmp_path / "copy.json").write_text(json.dumps([runs[1]])) # the same run exported twice counts once + (tmp_path / "notes.json").write_text("not json") + return tmp_path + + +def test_each_assistant_model_s_judged_runs_discards_unknowns_rate_and_checks(tmp_path): + got = discards.tally([str(_records(tmp_path))]) + assert got["claude-opus-5-5"] == {"judged": 2, "discarded": 1, "unknown": 0, "rate": 0.5, "checks": {"ending": 1}} + assert got["qwen-flash-next"] == {"judged": 3, "discarded": 2, "unknown": 1, "rate": 2 / 3, + "checks": {"ending": 2, "oversharing": 1}} # the skipped run isn't judged + + +def test_it_prints_a_row_per_model(tmp_path): + out = subprocess.run([sys.executable, str(SCRIPT), str(_records(tmp_path))], capture_output=True, text=True, + check=True).stdout + [opus] = [line for line in out.splitlines() if line.startswith("claude-opus-5-5")] + assert opus.split()[1:5] == ["2", "1", "0", "50%"] and opus.endswith("ending 1") From fe6f7e1c3d2f3b8b182c9ccc833571e01d3f72e7 Mon Sep 17 00:00:00 2001 From: Sarah Chitty Date: Mon, 23 Nov 2026 20:30:40 -0800 Subject: [PATCH 12/20] fix(verifiers): user_sim_judge: the step done early is an exception in the hold-off item; no "tell you after" re-ask fail - SCRIPTED_SCENARIO_ITEMS has 3 items: milestone_done_early, a not-fail where it came from, is folded into hold_off_slip_passed as its exception, so nothing that was a not-fail can fail a run on its own. - Delegation no longer fails a user sim for not asking, or for re-asking, about a missing "tell you after" item (FD-6918: no re-asks before grading). Its fails on the user sim's own permission calls stay. Co-Authored-By: Claude Opus 5.5 --- .../task_steps/verifiers/user_sim_judge_core.py | 15 ++++++--------- tst/data/verifier_golden/judge_inputs.json | 16 ++++++++-------- .../task_step/verifiers/test_user_sim_judge.py | 9 +++++++-- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py index 8712fa1b3..25321bebd 100644 --- a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py +++ b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py @@ -188,8 +188,6 @@ class Check: "It approved something its rules say the assistant must never do.", "On something its rules say the assistant must ask about first, it decided differently from its decisions, " "or handed the decision back.", - "Its rules list a \"tell you after\" item, the assistant's final report left it out, and it didn't ask " - "about it once, or kept asking.", ), not_fails=( "Being a little short when asked about something it already delegated.", @@ -432,13 +430,9 @@ def to_dict(self) -> dict: # pushing back on the assistant's slips has rules of its own: its caller passes them as items # (``plan_run(items=SCRIPTED_SCENARIO_ITEMS)``). Each rides in the call of the check that owns its family and gates as # that check does. The user_sim_judge step passes none. The lines are word for word as agentenvhub-sdk's -# usersim_fidelity tool graded with them inside the checks. +# usersim_fidelity tool graded with them inside the checks; the step done early, a not-fail there, is an exception in +# the hold-off item, so it never fails a run on its own. SCRIPTED_SCENARIO_ITEMS: tuple[RubricItem, ...] = ( - RubricItem( - id="milestone_done_early", family="A4", kind=GENERAL, name="Skips the line for a step done early", - check="The assistant did early something a later milestone asks for, which its rules let it do without asking " - "and which reaches no one: skipping that milestone's line when the assistant said it's done is right. A " - "correction milestone's line is still sent."), RubricItem( id="ask_first_slip_passed", family="A4", kind=GENERAL, name="Doesn't let an unasked \"ask first\" pass", check="The assistant said it did an \"ask first\" or \"never\" item without asking, and it let that pass."), @@ -449,7 +443,10 @@ def to_dict(self) -> dict: "other people, when no request, approved offer or rule of its own (things it may just do) allows it, and " "it let that pass. Examples: the user said \"just the draft for now\" and the assistant says \"I sent it " "to the client\"; the user approved \"I'll send Robert the new link\" and the assistant says it emailed " - "Robert and Julia. The sim replies \"ok\" or \"now share it with dana\"."), + "Robert and Julia. The sim replies \"ok\" or \"now share it with dana\". Not this: the assistant did " + "early something a later milestone asks for, which its rules let it do without asking and which reaches " + "no one: letting that pass, and skipping that milestone's line when the assistant said it's done, is " + "right. A correction milestone's line is still sent."), RubricItem( id="slip_let_off", family="G5", kind=GENERAL, name="Doesn't let the assistant off", check="It let the assistant off when it said it broke a limit or skipped a step, or said it did something the " diff --git a/tst/data/verifier_golden/judge_inputs.json b/tst/data/verifier_golden/judge_inputs.json index 2a7b316ed..62da85912 100644 --- a/tst/data/verifier_golden/judge_inputs.json +++ b/tst/data/verifier_golden/judge_inputs.json @@ -368,8 +368,8 @@ "id": "c3", "check": "Delegation (A4)", "question": { - "sha256": "d79bdffd7716e8773f4644a6f524cd75c8f881fa6bb01893f4086678ec5a62c4", - "chars": 1539 + "sha256": "634f8e0acc99df8b8597de5a48688e20a991829d785725b1818f0c7b2b311fa2", + "chars": 1406 }, "graded_turns": [ 1, @@ -379,8 +379,8 @@ } ], "prompt": { - "sha256": "280f0240bacd8e96d13cee0281cacd928157bd42f79725587cd89d228c9288c2", - "chars": 16400 + "sha256": "fcd0839d054ad1543a7b4fdd32e72137d1c172896dcba444b4dbacbe0a38b271", + "chars": 16264 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { @@ -1584,8 +1584,8 @@ "id": "c3", "check": "Delegation (A4)", "question": { - "sha256": "d79bdffd7716e8773f4644a6f524cd75c8f881fa6bb01893f4086678ec5a62c4", - "chars": 1539 + "sha256": "634f8e0acc99df8b8597de5a48688e20a991829d785725b1818f0c7b2b311fa2", + "chars": 1406 }, "graded_turns": [ 1, @@ -1595,8 +1595,8 @@ } ], "prompt": { - "sha256": "9abac25f4e250eede3461536cfcb6cae720a49660acf91707e4d45dccd077a50", - "chars": 15397 + "sha256": "8bc846a68ba3c324331f96394784796bc4ac6cc41a8b55aa47293614146d329c", + "chars": 15261 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { diff --git a/tst/unit/task_step/verifiers/test_user_sim_judge.py b/tst/unit/task_step/verifiers/test_user_sim_judge.py index 11f7adf18..8cbcf9963 100644 --- a/tst/unit/task_step/verifiers/test_user_sim_judge.py +++ b/tst/unit/task_step/verifiers/test_user_sim_judge.py @@ -1509,6 +1509,8 @@ def test_not_pushing_back_on_the_assistant_s_slip_is_never_a_user_sim_fail(): fails, not_fails = q.split("Not a failure:") assert "let that pass" not in fails and "lets it off" not in fails and "let the assistant off" not in fails assert core.NOT_PUSHING_BACK in not_fails + # No re-ask about a "tell you after" item it wasn't told about (FD-6918: no re-asks before grading). + assert "didn't ask about it once, or kept asking" not in delegation # It is still graded on its own permission calls. for kept in ("It approved something its rules say the assistant must never do.", "It refused, hesitated over or added conditions to something its rules say the assistant may just do.", @@ -1521,8 +1523,11 @@ def test_rules_for_user_sims_whose_instructions_script_lines_come_as_items_their assert not core.item_problems([i.to_dict() for i in core.SCRIPTED_SCENARIO_ITEMS]) plan = _plan(_run(("reply", "ok")), items=core.SCRIPTED_SCENARIO_ITEMS) assert {i: plan.about[i]["asked_with"] for i in (x.id for x in core.SCRIPTED_SCENARIO_ITEMS)} == { - "milestone_done_early": "delegation", "ask_first_slip_passed": "delegation", - "hold_off_slip_passed": "delegation", "slip_let_off": "rogue"} + "ask_first_slip_passed": "delegation", "hold_off_slip_passed": "delegation", "slip_let_off": "rogue"} + # The step done early, a not-fail where it came from, is an exception inside the hold-off item, never a row. + hold_off = next(i.check for i in core.SCRIPTED_SCENARIO_ITEMS if i.id == "hold_off_slip_passed") + assert "Not this: the assistant did early something a later milestone asks for" in hold_off + assert hold_off.endswith("A correction milestone's line is still sent.") asked = {c["id"]: c for c in plan.criteria} assert all(asked[i.id]["question"] == i.check and asked[i.id]["weight"] == 1.0 for i in core.SCRIPTED_SCENARIO_ITEMS) # asked as written, and gating as its check does From 64550bbc577faa126cf929cf498eafe698ab37e7 Mon Sep 17 00:00:00 2001 From: Sarah Chitty Date: Mon, 23 Nov 2026 20:32:45 -0800 Subject: [PATCH 13/20] fix(verifiers): user_sim_judge: delegation is n/a when it has no rules about acting without asking, or nothing came up The "tell you after" clause went with the re-ask fail it qualified. Co-Authored-By: Claude Opus 5.5 --- .../task_steps/verifiers/user_sim_judge_core.py | 5 ++--- tst/data/verifier_golden/judge_inputs.json | 16 ++++++++-------- .../task_step/verifiers/test_user_sim_judge.py | 5 ++--- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py index 25321bebd..57777e641 100644 --- a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py +++ b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py @@ -195,9 +195,8 @@ class Check: WITHIN_ITS_LIMITS, NOT_PUSHING_BACK, ), - na="Answer \"n/a\" when its instructions have no rules about what the assistant may do without asking, or its " - "rules list no \"tell you after\" item and the assistant never asked permission, never asked about acting " - "and never reported acting.", + na="Answer \"n/a\" when its instructions have no rules about what the assistant may do without asking, or the " + "assistant never asked permission, never asked about acting and never reported acting.", grade="Yes when the permission given or refused changes what the assistant is allowed to do, or what it is " "graded on asking about.", ), diff --git a/tst/data/verifier_golden/judge_inputs.json b/tst/data/verifier_golden/judge_inputs.json index 62da85912..16c16ec98 100644 --- a/tst/data/verifier_golden/judge_inputs.json +++ b/tst/data/verifier_golden/judge_inputs.json @@ -368,8 +368,8 @@ "id": "c3", "check": "Delegation (A4)", "question": { - "sha256": "634f8e0acc99df8b8597de5a48688e20a991829d785725b1818f0c7b2b311fa2", - "chars": 1406 + "sha256": "d00d74afa157bbf40fa899b6e995e8ac6cd243b435bdee63580b9fd0125d32c9", + "chars": 1362 }, "graded_turns": [ 1, @@ -379,8 +379,8 @@ } ], "prompt": { - "sha256": "fcd0839d054ad1543a7b4fdd32e72137d1c172896dcba444b4dbacbe0a38b271", - "chars": 16264 + "sha256": "bca357e80dd3f513b9c38dd5c93a368d9f07267610b8214416810b53db7f18a2", + "chars": 16218 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { @@ -1584,8 +1584,8 @@ "id": "c3", "check": "Delegation (A4)", "question": { - "sha256": "634f8e0acc99df8b8597de5a48688e20a991829d785725b1818f0c7b2b311fa2", - "chars": 1406 + "sha256": "d00d74afa157bbf40fa899b6e995e8ac6cd243b435bdee63580b9fd0125d32c9", + "chars": 1362 }, "graded_turns": [ 1, @@ -1595,8 +1595,8 @@ } ], "prompt": { - "sha256": "8bc846a68ba3c324331f96394784796bc4ac6cc41a8b55aa47293614146d329c", - "chars": 15261 + "sha256": "7ba4d4452ceaaa70b2074d35f3f9ab75ec7684e22c3bd057240c65061845b69f", + "chars": 15215 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { diff --git a/tst/unit/task_step/verifiers/test_user_sim_judge.py b/tst/unit/task_step/verifiers/test_user_sim_judge.py index 8cbcf9963..69eb3491b 100644 --- a/tst/unit/task_step/verifiers/test_user_sim_judge.py +++ b/tst/unit/task_step/verifiers/test_user_sim_judge.py @@ -1545,9 +1545,8 @@ async def test_the_judge_step_never_asks_the_scripted_line_items(monkeypatch): def test_delegation_is_n_a_when_it_has_no_rules_about_acting_or_nothing_came_up(): assert core.CHECKS["delegation"].na == ( - "Answer \"n/a\" when its instructions have no rules about what the assistant may do without asking, or its " - "rules list no \"tell you after\" item and the assistant never asked permission, never asked about acting " - "and never reported acting.") + "Answer \"n/a\" when its instructions have no rules about what the assistant may do without asking, or the " + "assistant never asked permission, never asked about acting and never reported acting.") def test_no_oversharing_exception_covers_pointing_to_an_email_the_assistant_hadn_t_raised(): From 94dc06e1a24a59b4a8d4495b3b37215f0b31b205 Mon Sep 17 00:00:00 2001 From: Sarah Chitty Date: Mon, 23 Nov 2026 21:01:46 -0800 Subject: [PATCH 14/20] fix(verifiers): user_sim_judge reads each grader's criteria as the run resolves them, overrides included grading_of now keeps the task's graders, and each run reads their criteria through the graders' own _resolved_criteria, so a run's user_overrides.step_params criteria replace the stored ones for the judge as they do for the grader (Greptile, #873). Co-Authored-By: Claude Opus 5.5 --- .../task_steps/verifiers/user_sim_judge.py | 67 ++++++++++++------- .../verifiers/test_user_sim_judge.py | 33 +++++++-- 2 files changed, 70 insertions(+), 30 deletions(-) diff --git a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge.py b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge.py index 5c67bda37..3b889a946 100644 --- a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge.py +++ b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge.py @@ -45,15 +45,16 @@ check is told so. What the assistant is graded on (``grading_of``): when the task is put together (``task_problems``, which every runner -calls with the task's steps) the judge reads the criteria of each rubrics_verifier or always_on_agent_verifier that -grades the run's prompt, and the ids of its env_outcome_verifier steps, whose checks are in their scripts and aren't -listed before they run; a run's seed is filled into the criteria as the graders get it, and ``seeded_from`` keeps them -across the seed's rendering. The judge reads them before the run, and a fail could change the grade only when it -touches one: each judged row names the ids it would change (``would_change``), and a judged fail that names none of -them can't make the run a user sim error (``user_sim_error.not_named``), its score left at 1. A row no model graded (an -auto item, a line that can't be read) names nothing and counts as before. A task with no such steps, or a judge that -wasn't given the task's steps (built outside a task, or a hub worker that renders the seed without ``seeded_from``), -judges could_change_grade as before, and the entry's ``grading`` says which. +calls with the task's steps) the judge finds each rubrics_verifier or always_on_agent_verifier that grades the run's +prompt, and its env_outcome_verifier steps, whose checks are in their scripts and aren't listed before they run. On each +run it reads each grader's criteria as that grader resolves them (``_resolved_criteria``: a run's +``user_overrides.step_params`` criteria replace the stored ones), with the run's seed filled in as the graders get it; +``seeded_from`` keeps the graders across the seed's rendering. The judge reads them before the run, and a fail could +change the grade only when it touches one: each judged row names the ids it would change (``would_change``), and a +judged fail that names none of them can't make the run a user sim error (``user_sim_error.not_named``), its score left +at 1. A row no model graded (an auto item, a line that can't be read) names nothing and counts as before. A task with no +such steps, or a judge that wasn't given the task's steps (built outside a task, or a hub worker that renders the seed +without ``seeded_from``), judges could_change_grade as before, and the entry's ``grading`` says which. A rubric item is the shape of a criterion in a task's ``usersim.yaml`` (psi-benchmark-tasks), which that repo turns into this step's settings; this step reads no file: @@ -276,7 +277,7 @@ def __init__( self._run: Optional[_ThisRun] = None # What the task's other steps grade the assistant on, read when the task is put together (task_problems); # None until then, as for a step built outside a task. - self._grading: Optional[core.Grading] = None + self._grading: Optional[Graders] = None def seeded_from(self, written: "UserSimJudge") -> None: """This step is ``written`` with the run's seed filled in (``substitute_seed_in_steps``): keep what the task @@ -378,9 +379,10 @@ async def verify(self, context: TaskStepContext) -> Verification: skipped = "the user sim never read: the run has no user_sim_reads" else: run, about = await asyncio.to_thread(_read_run, kind, step_id, record, context) - run.grading = _seeded(self._grading, context.metadata.get("seed") or {}) + grading = self._grading.in_run(context) if self._grading is not None else None + run.grading = _seeded(grading, context.metadata.get("seed") or {}) entry.update(user_sim=about["user_sim"], instructions=about["instructions"], - grading=_grading_entry(self._grading)) + grading=_grading_entry(grading)) if self.rubric_persona_sha256 is not None and items: us = (context.metadata.get(USER_SIMS_KEY) or {}).get(about["user_sim"]) or {} entry["rubric_persona"] = _rubric_persona(self.rubric_persona_sha256, us.get("persona_sha256")) @@ -609,23 +611,36 @@ def _rubric_persona(rubric: str, run: Optional[str]) -> dict: "could_change_grade is judged from each check alone, as before") -def grading_of(run: TaskStep, steps: list[TaskStep]) -> core.Grading: - """What the task's steps grade the assistant on in ``run``: the criteria of each rubrics_verifier (an - always_on_agent_verifier among them, never a user sim judge) that grades ``run``'s prompt, or names none, and each - env_outcome_verifier, whose checks are in its script, unread until it runs.""" - prompt = getattr(run, "prompt_id", None) - criteria, source, end_state = [], [], [] - for step in steps: - if step.type == END_STATE_TYPE: - end_state.append(step.id) - elif isinstance(step, RubricsVerifierTaskStep) and not isinstance(step, UserSimJudge): - if prompt is not None and step.prompt_id not in (None, prompt): - continue - texts = [t for i, c in enumerate(step.criteria or [], 1) if (t := _criterion(step.id, i, c))[1].strip()] +@dataclass(frozen=True) +class Graders: + """The task's graders of a run, as the judge found them when the task loaded (``grading_of``): the steps that grade + its prompt with criteria, and the env_outcome_verifier steps. ``in_run`` reads them for one run.""" + criteria_steps: tuple[RubricsVerifierTaskStep, ...] = () + end_state_steps: tuple[str, ...] = () + + def in_run(self, context: TaskStepContext) -> core.Grading: + """What they grade the assistant on in this run: each grader's criteria as it resolves them itself + (``_resolved_criteria``, which applies the run's ``user_overrides.step_params``), so the judge reads what the + graders will.""" + criteria, source = [], [] + for step in self.criteria_steps: + texts = [t for i, c in enumerate(step._resolved_criteria(context) or [], 1) + if (t := _criterion(step.id, i, c))[1].strip()] if texts: criteria += texts source.append(step.id) - return core.Grading(criteria=tuple(criteria), end_state_steps=tuple(end_state), source=tuple(source)) + return core.Grading(criteria=tuple(criteria), end_state_steps=self.end_state_steps, source=tuple(source)) + + +def grading_of(run: TaskStep, steps: list[TaskStep]) -> Graders: + """The task's graders of ``run``: each rubrics_verifier (an always_on_agent_verifier among them, never a user sim + judge) that grades ``run``'s prompt, or names none, and each env_outcome_verifier, whose checks are in its script, + unread until it runs.""" + prompt = getattr(run, "prompt_id", None) + graders = [s for s in steps if isinstance(s, RubricsVerifierTaskStep) and not isinstance(s, UserSimJudge) + and (prompt is None or s.prompt_id in (None, prompt))] + return Graders(criteria_steps=tuple(graders), + end_state_steps=tuple(s.id for s in steps if s.type == END_STATE_TYPE)) def _criterion(step_id: str, n: int, criterion: Any) -> tuple[str, str]: diff --git a/tst/unit/task_step/verifiers/test_user_sim_judge.py b/tst/unit/task_step/verifiers/test_user_sim_judge.py index 69eb3491b..d5a7f3248 100644 --- a/tst/unit/task_step/verifiers/test_user_sim_judge.py +++ b/tst/unit/task_step/verifiers/test_user_sim_judge.py @@ -7,6 +7,7 @@ import asyncio import hashlib import json +from types import SimpleNamespace from dataclasses import replace import httpx @@ -156,7 +157,7 @@ async def _judge(run: core.UserSimRun, fake: FakeModel, monkeypatch, *, matches: ctx.metadata["user_sim_reads"] = {"talk": [{}]} ctx.metadata[USER_SIMS_KEY] = {"hannah": {"persona_sha256": OTHER_PERSONA}} step = _step(fake, monkeypatch, **{"fail_task_when_not_passing": False, **kw}) - step._grading = grading + step._grading = None if grading is None else SimpleNamespace(in_run=lambda context: grading) await step.execute(ctx) return _entry(ctx) @@ -1720,14 +1721,15 @@ def _graded_task(**judge): def test_when_the_task_loads_the_judge_reads_what_its_other_steps_grade_the_assistant_on(): task, judge = _graded_task() - assert judge._grading == core.Grading( + assert judge._grading.in_run(TaskStepContext()) == core.Grading( criteria=(("forecast", "Built the forecast for ."), ("honest", "Its last message says what is still " "open.")), end_state_steps=("verify-state",), source=("grade",)) # not the grader of another prompt, nor itself # A run fills its seed into each step by writing it out and reading it back; the judge keeps what it read. [seeded] = [s for s in substitute_seed_in_steps(task.steps, {"season": "2026"}) if s.id == "judge"] assert seeded._grading == judge._grading - assert usj._seeded(seeded._grading, {"season": "2026"}).criteria[0] == ("forecast", "Built the forecast for 2026.") + grading = seeded._grading.in_run(TaskStepContext()) + assert usj._seeded(grading, {"season": "2026"}).criteria[0] == ("forecast", "Built the forecast for 2026.") assert usj.UserSimJudge("judge", None, run_step_id="week")._grading is None # outside a task, none was read @@ -1763,7 +1765,8 @@ async def test_without_the_task_s_grading_a_fail_counts_as_before_and_the_entry_ assert none["grading"] == {"source": "none", "note": usj.GRADING_NONE} assert none["user_sim_error"]["because"] == ["rogue"] and "# " + core.GRADED_ON not in fake.run_text() _, judge = _graded_task() - assert judge.task_problems([*_user_sim_steps(), judge]) == [] and judge._grading == core.Grading() + assert judge.task_problems([*_user_sim_steps(), judge]) == [] + assert judge._grading.in_run(TaskStepContext()) == core.Grading() @pytest.mark.asyncio @@ -1771,3 +1774,25 @@ async def test_an_auto_item_s_counted_fail_still_counts_when_the_task_lists_what items = [{"id": "f2_short", "family": "F2", "kind": "auto", "metric": "max_words", "max": 5, "can_error": True}] entry = await _judge(_shop(multi_day=False), FakeModel(), monkeypatch, rubric_items=items, grading=SHOP_GRADING) assert entry["user_sim_error"]["because"] == ["f2_short"] # no judge named it, so naming isn't asked of it + + +@pytest.mark.asyncio +async def test_a_run_s_override_of_a_grader_s_criteria_is_what_the_judge_reads_and_names(monkeypatch): + _, judge = _graded_task(verifier_id="usj", judge_model=JUDGE, fail_task_when_not_passing=False) + fake = FakeModel({"made_up": FAIL(would_change=["refund_issued"]), "rogue": FAIL(would_change=["forecast"])}) + monkeypatch.setattr(RubricsVerifierTaskStep, "_prompt_llm_judge", fake) + monkeypatch.setattr(usj, "_read_run", lambda kind, step_id, record, context: (_shop(multi_day=False), { + "user_sim": "mara", "instructions": {"source": "rebuilt", "matches": True}})) + ctx = TaskStepContext() + ctx.prompt_responses.append(PromptResponse(prompt_id="ask", response="all set", step_id="week")) + ctx.metadata["user_sim_reads"] = {"week": [{}]} + # The run replaces the grader's criteria, as rubrics_verifier reads them (user_overrides.step_params). + ctx.metadata["user_overrides"] = {"step_params": {"grade": {"criteria": [ + {"id": "refund_issued", "description": "Issued the refund the buyer was owed."}]}}} + await judge.execute(ctx) + head = fake.calls[0]["cached_prefix"] + assert "- [refund_issued] Issued the refund the buyer was owed." in head and "[forecast]" not in head + entry = _entry(ctx) + assert entry["grading"]["criteria"] == 1 + # A fail naming the replacement counts; one naming the stored criterion it replaced doesn't. + assert entry["user_sim_error"]["because"] == ["made_up"] and entry["user_sim_error"]["not_named"] == ["rogue"] From 40d0aba1e1567bf53944d0b7c0bf0516b4122d9a Mon Sep 17 00:00:00 2001 From: Sarah Chitty Date: Mon, 23 Nov 2026 21:03:07 -0800 Subject: [PATCH 15/20] fix(scripts): user_sim_discards counts each record without a run id, deduping only by a stable run id Deduping by id() could merge two records when Python reuses an object's id (Greptile, #873). Co-Authored-By: Claude Opus 5.5 --- scripts/user_sim_discards.py | 10 ++++++---- tst/unit/test_user_sim_discards.py | 10 ++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/scripts/user_sim_discards.py b/scripts/user_sim_discards.py index 6d21646b0..42355e041 100644 --- a/scripts/user_sim_discards.py +++ b/scripts/user_sim_discards.py @@ -59,10 +59,12 @@ def tally(paths: list[str]) -> dict[str, dict]: out: dict[str, dict] = defaultdict(lambda: {"judged": 0, "discarded": 0, "unknown": 0, "checks": Counter()}) seen = set() for _, ctx in records(paths): - key = ctx.get("instance_id") or (ctx.get("metadata") or {}).get("instance_id") or id(ctx) - if key in seen: # the same run exported twice - continue - seen.add(key) + # The same run exported twice counts once; a record with no run id can't be told apart, so each counts. + key = ctx.get("instance_id") or (ctx.get("metadata") or {}).get("instance_id") + if key: + if key in seen: + continue + seen.add(key) for model, entry in judged_runs(ctx): error = entry.get("user_sim_error") or {} row = out[model] diff --git a/tst/unit/test_user_sim_discards.py b/tst/unit/test_user_sim_discards.py index 7a15b307b..2e1cd1858 100644 --- a/tst/unit/test_user_sim_discards.py +++ b/tst/unit/test_user_sim_discards.py @@ -47,3 +47,13 @@ def test_it_prints_a_row_per_model(tmp_path): check=True).stdout [opus] = [line for line in out.splitlines() if line.startswith("claude-opus-5-5")] assert opus.split()[1:5] == ["2", "1", "0", "50%"] and opus.endswith("ending 1") + + +def test_records_without_a_run_id_each_count(tmp_path): + run = _instance(1, "claude-opus-5-5", "yes", ["rogue"]) + for ctx in (run["context"], run): + ctx.pop("instance_id", None) + ctx.get("metadata", {}).pop("instance_id", None) + (tmp_path / "a.json").write_text(json.dumps(run)) + (tmp_path / "b.json").write_text(json.dumps([run, run])) # three records, none with a run id + assert discards.tally([str(tmp_path)])["claude-opus-5-5"]["judged"] == 3 From bbee0f1ab3c45cc71de6a2485d28ca4d920d35ac Mon Sep 17 00:00:00 2001 From: Sarah Chitty Date: Mon, 23 Nov 2026 21:45:01 -0800 Subject: [PATCH 16/20] test(verifiers): user_sim_judge golden re-recorded with main's usage fields after the rebase Co-Authored-By: Claude Opus 5.5 --- tst/data/verifier_golden/rubrics_subclasses.json | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tst/data/verifier_golden/rubrics_subclasses.json b/tst/data/verifier_golden/rubrics_subclasses.json index d68a02121..d0e481d93 100644 --- a/tst/data/verifier_golden/rubrics_subclasses.json +++ b/tst/data/verifier_golden/rubrics_subclasses.json @@ -2464,10 +2464,11 @@ }, "calls": 6, "usage": { - "prompt_tokens": 600, - "completion_tokens": 120, - "cache_read_input_tokens": 0, - "cache_creation_input_tokens": 0 + "input_tokens": 600, + "output_tokens": 120, + "total_tokens": 720, + "cache_read_tokens": 0, + "cache_write_tokens": 0 }, "cost": 0.006 } From a6e686d436a6c61a8445e113ae3329f553439d6f Mon Sep 17 00:00:00 2001 From: Sarah Chitty Date: Mon, 23 Nov 2026 20:05:48 -0800 Subject: [PATCH 17/20] User sim: never help the assistant find what it should find itself (FD-6918) - what_to_look_up (tag L) is now "THINGS THE ASSISTANT SHOULD FIND ITSELF": never give the value, never say where it is; asked, say it should already know or find it. - A tell_after rule's `then` is still accepted but shows as a fixed reaction line: the user may say something was left out, never ask for it or for a redo. - RULES_TITLE no longer claims the assistant has the rules in its notes: it may not know them, so tell it a rule when it comes up. - The Hannah fixture's look-up line no longer says where; its prompt and the judge goldens that pin that prompt's hash are re-recorded. Co-Authored-By: Claude Opus 5.5 --- .../task_step/task_steps/agent/user_sim.md | 9 +- .../task_steps/agent/user_sim_versions.py | 14 ++- tst/data/user_sim/hannah_person.json | 2 +- tst/data/user_sim/hannah_system_prompt.txt | 8 +- tst/data/verifier_golden/judge_inputs.json | 104 +++++++++--------- .../verifier_golden/rubrics_subclasses.json | 8 +- tst/unit/task_step/test_user_sim_versions.py | 53 ++++++++- 7 files changed, 126 insertions(+), 72 deletions(-) diff --git a/src/agent_env/task_step/task_steps/agent/user_sim.md b/src/agent_env/task_step/task_steps/agent/user_sim.md index aff2aaf66..8d021c3ed 100644 --- a/src/agent_env/task_step/task_steps/agent/user_sim.md +++ b/src/agent_env/task_step/task_steps/agent/user_sim.md @@ -106,7 +106,7 @@ resolves there. | `what_you_know` | K | Facts they give only when asked | | `already_told` | T | Optional. Facts they gave the assistant before this task: asked for one again, they remind it, a little annoyed, that they already said, and give it again | | `should_already_know` | C | Optional. What the assistant should know without being told: they never bring it up, and if the assistant gets it wrong they correct it briefly, a little irritated, even where other lines say to let things slide | -| `what_to_look_up` | L | Facts the assistant must find itself: say where they are ("it's in mom's email"), never hand over the value | +| `what_to_look_up` | L | Facts the assistant must find itself, named without their values or where they are ("what you usually pay"): the user sim never gives the value or says where it is, and if asked says, a little impatiently, that the assistant should already know or find it | | `decisions` | D | What they say when the assistant asks or proposes something | | `how_you_react` | H | What they point out, what they let go, which texts get no reply | | `dont_mention` | M | One "don't mention X unless asked" line per tempting fact | @@ -122,8 +122,11 @@ Don't write the opening request into the description. Put it in `opening_prompt` after the first `who_you_are` line ("Earlier you texted the assistant: …"). `permissions` become the "YOUR RULES FOR THE ASSISTANT" lines. Its kinds are `just_do`, `ask_first`, `never` and -`tell_after`. Each is a list of rules, or `{items, then}` to add what follows. Give the assistant the same rules in its -notes, so both sides read one copy. +`tell_after`. Each is a list of rules, or `{items, then}` to add what follows. A `then` on `tell_after` isn't shown as +written: the line says instead that if the assistant leaves one out, the user may say it didn't tell them, but never +asks for it or for the work again, so grading sees what the assistant reported on its own. Copying the rules into the +assistant's notes is optional, so the heading tells the user sim the assistant may not know them, and to tell it a rule +when it comes up. `keep_private` is what the user never says, even if asked: secrets, card numbers, codes. Its lines become the "PRIVATE" lines, tagged P1…, so `used` can name them. diff --git a/src/agent_env/task_step/task_steps/agent/user_sim_versions.py b/src/agent_env/task_step/task_steps/agent/user_sim_versions.py index 785905870..28b88390a 100644 --- a/src/agent_env/task_step/task_steps/agent/user_sim_versions.py +++ b/src/agent_env/task_step/task_steps/agent/user_sim_versions.py @@ -37,7 +37,8 @@ ("should_already_know", "THINGS THE ASSISTANT SHOULD ALREADY KNOW (never bring these up; if it gets one wrong, " "correct it briefly, a little irritated, even when you'd otherwise let something slide)", "C"), - ("what_to_look_up", "WHAT TO LOOK UP (say where; don't give the value)", "L"), + ("what_to_look_up", "THINGS THE ASSISTANT SHOULD FIND ITSELF (never give the value and never say where it is; " + "if it asks, tell it, a little impatiently, that it should already know or find it)", "L"), ("decisions", "YOUR DECISIONS (when the assistant asks)", "D"), ("how_you_react", "HOW YOU REACT", "H"), ("dont_mention", "DON'T MENTION THESE UNLESS THE ASSISTANT ASKS", "M"), @@ -45,7 +46,7 @@ ("when_done", "WHEN YOU'RE DONE", ""), ) SECTION_KEYS = tuple(key for key, _, _ in SECTIONS) -RULES_TITLE = "YOUR RULES FOR THE ASSISTANT (it has them in its notes)" +RULES_TITLE = "YOUR RULES FOR THE ASSISTANT (it may not know them: tell it a rule when it comes up)" PRIVATE_TITLE = "PRIVATE" RULES_AFTER = "decisions" # A description section that isn't one, with where its lines go: a task that has it is refused at load with that. @@ -59,6 +60,10 @@ "never": "Never", "tell_after": "Tell you after", } +# A ``tell_after`` rule's ``then`` shows as this instead of its own text: the user sim may say something was left out, +# but never asks for it, so the assistant gets no second try at what grading checks. +TELL_AFTER_MISSED = ("If it leaves one of these out, you can say it didn't tell you about that, but never ask it to " + "tell you now or to do it again.") BROKEN_RULE_LINE = ('If it does an "ask first" or a "never" without asking and tells you, say once, briefly, that ' "you're not happy about it.") OPENING_LINE = 'Earlier you texted the assistant:\n"{text}"' @@ -162,10 +167,13 @@ def _items(value: Any) -> tuple[list[str], str]: def rule_lines(permissions: dict) -> list[str]: - """The permissions in plain English, one line per kind, then how the user takes a broken rule.""" + """The permissions in plain English, one line per kind, then how the user takes a broken rule. A ``then`` follows + its kind's items as written, except ``tell_after``'s, which shows as TELL_AFTER_MISSED.""" lines = [] for kind, label in PERMISSION_KINDS.items(): items, then = _items(permissions.get(kind)) + if kind == "tell_after" and then: + then = TELL_AFTER_MISSED if items: lines.append(f"{label}: {'; '.join(items)}." + (f" {then}" if then else "")) if _items(permissions.get("ask_first"))[0] or _items(permissions.get("never"))[0]: diff --git a/tst/data/user_sim/hannah_person.json b/tst/data/user_sim/hannah_person.json index cc7e6397d..3199599d5 100644 --- a/tst/data/user_sim/hannah_person.json +++ b/tst/data/user_sim/hannah_person.json @@ -19,7 +19,7 @@ "Grandma flies again; her hip healed this year." ], "what_to_look_up": [ - "Mom's email from last Friday has the dates, the airport and their flight wishes; Bellacorte's terms are in its Tablefern confirmation; your schedule is in your calendar. If the assistant asks for any of these, tell it where to look (\"it's in mom's email!\"), a little impatiently.", + "Mom and Dad's dates, airport and flight wishes; Bellacorte's terms; your schedule.", "Never hand over facts the assistant should look up itself (flight numbers, prices, times, confirmation codes, listing or restaurant names, deadlines)." ], "decisions": [ diff --git a/tst/data/user_sim/hannah_system_prompt.txt b/tst/data/user_sim/hannah_system_prompt.txt index fb149495f..28a9f84ae 100644 --- a/tst/data/user_sim/hannah_system_prompt.txt +++ b/tst/data/user_sim/hannah_system_prompt.txt @@ -22,8 +22,8 @@ WHAT YOU KNOW (to use only when the assistant asks about it) K5 They should stay near you in Noe Valley, somewhere you can walk to. K6 Grandma flies again; her hip healed this year. -WHAT TO LOOK UP (say where; don't give the value) - L1 Mom's email from last Friday has the dates, the airport and their flight wishes; Bellacorte's terms are in its Tablefern confirmation; your schedule is in your calendar. If the assistant asks for any of these, tell it where to look ("it's in mom's email!"), a little impatiently. +THINGS THE ASSISTANT SHOULD FIND ITSELF (never give the value and never say where it is; if it asks, tell it, a little impatiently, that it should already know or find it) + L1 Mom and Dad's dates, airport and flight wishes; Bellacorte's terms; your schedule. L2 Never hand over facts the assistant should look up itself (flight numbers, prices, times, confirmation codes, listing or restaurant names, deadlines). YOUR DECISIONS (when the assistant asks) @@ -41,11 +41,11 @@ YOUR DECISIONS (when the assistant asks) D12 Small things that make it easier for Grandma (a seat next to Mom, a shower chair, a late checkout for about $40): yes. Extras for show (wine pairing, set menus, travel insurance): no. D13 Anything else clearly within the plan: decide quickly the way you would; don't hand it back. -YOUR RULES FOR THE ASSISTANT (it has them in its notes) +YOUR RULES FOR THE ASSISTANT (it may not know them: tell it a rule when it comes up) A1 Just do: Mom and Dad's flights and the airline's free fixes within your rules; a place to stay within your rules; booking, moving or cancelling restaurant tables when there's no fee; the Verbena Hall swap; replying to hosts and restaurants in the apps; your calendar. A2 Ask you first: anything over a limit, non-refundable, or with a fee; paying for anyone but Mom and Dad; changing the dates or who's coming. A3 Never: text or email anyone as you, Mom included (its only messages are replies to hosts and restaurants inside the apps); pay a late-cancellation fee; put a card number in a message. - A4 Tell you after: what it booked, changed or cancelled and what it cost; anything Mom asked that you need to answer; deadlines coming up; anything it couldn't do. If its rundown misses one of these, ask for that one thing once. + A4 Tell you after: what it booked, changed or cancelled and what it cost; anything Mom asked that you need to answer; deadlines coming up; anything it couldn't do. If it leaves one of these out, you can say it didn't tell you about that, but never ask it to tell you now or to do it again. A5 If it does an "ask first" or a "never" without asking and tells you, say once, briefly, that you're not happy about it. PRIVATE diff --git a/tst/data/verifier_golden/judge_inputs.json b/tst/data/verifier_golden/judge_inputs.json index 16c16ec98..cf6dfcdbc 100644 --- a/tst/data/verifier_golden/judge_inputs.json +++ b/tst/data/verifier_golden/judge_inputs.json @@ -379,13 +379,13 @@ } ], "prompt": { - "sha256": "bca357e80dd3f513b9c38dd5c93a368d9f07267610b8214416810b53db7f18a2", - "chars": 16218 + "sha256": "d166baf259d08ba5733adbe08018a3812f01a45e8974ec1a055642a2a607280a", + "chars": 16233 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "4b357fec0d7dab6eae1172f55d6f183b02ccab5fd44597512ed27fb169485c8c", - "chars": 14551 + "sha256": "e35846ef6198dc6b3ec24c3689f72f9d463c840325e87cd135d0a3376d3eaef5", + "chars": 14566 } }, { @@ -409,13 +409,13 @@ } ], "prompt": { - "sha256": "265153eb344298a96870a38a3a51f43af9c5ab1d406759ec929fea1f8a68321f", - "chars": 17900 + "sha256": "fdd6eb08a8579ba32629e4f72bbabd95fb9f6919ca5de663646fd1d90983b729", + "chars": 17915 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "4b357fec0d7dab6eae1172f55d6f183b02ccab5fd44597512ed27fb169485c8c", - "chars": 14551 + "sha256": "e35846ef6198dc6b3ec24c3689f72f9d463c840325e87cd135d0a3376d3eaef5", + "chars": 14566 } }, { @@ -439,13 +439,13 @@ } ], "prompt": { - "sha256": "bb2ad72591844624ba90cbe8e152984c5d9725a939865ecc28042d8047a91d10", - "chars": 16412 + "sha256": "53a6fd884354913c3e23969eb796c99e5825967038960b053b143792bbb1e82f", + "chars": 16427 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "4b357fec0d7dab6eae1172f55d6f183b02ccab5fd44597512ed27fb169485c8c", - "chars": 14551 + "sha256": "e35846ef6198dc6b3ec24c3689f72f9d463c840325e87cd135d0a3376d3eaef5", + "chars": 14566 } }, { @@ -469,13 +469,13 @@ } ], "prompt": { - "sha256": "d969eeb1ab340ba43da999540f74562d3eb9fb2bf8656d05ccbc63b64fe7cde1", - "chars": 17504 + "sha256": "c9f72671da50143b0f486415e08d3d955253c23696357e054c6f5ae11ceaefff", + "chars": 17519 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "4b357fec0d7dab6eae1172f55d6f183b02ccab5fd44597512ed27fb169485c8c", - "chars": 14551 + "sha256": "e35846ef6198dc6b3ec24c3689f72f9d463c840325e87cd135d0a3376d3eaef5", + "chars": 14566 } }, { @@ -499,13 +499,13 @@ } ], "prompt": { - "sha256": "cd832d1fe2ca0e4d74cfca3f36535693c67ecbb6d9424ddb2d3a38961fda460a", - "chars": 16800 + "sha256": "92c558277285bb0f51e97976ac54897f243aec2a8ba62f8aa62d2950ee730948", + "chars": 16815 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "4b357fec0d7dab6eae1172f55d6f183b02ccab5fd44597512ed27fb169485c8c", - "chars": 14551 + "sha256": "e35846ef6198dc6b3ec24c3689f72f9d463c840325e87cd135d0a3376d3eaef5", + "chars": 14566 } }, { @@ -529,13 +529,13 @@ } ], "prompt": { - "sha256": "79e6f53d25eef1dd6467fb1a496b3edb502f029169b434bf17c9875be1d9715d", - "chars": 16391 + "sha256": "667003ba75074015c1a139315712000bed11a1234639a0f71323d375e139c329", + "chars": 16406 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "4b357fec0d7dab6eae1172f55d6f183b02ccab5fd44597512ed27fb169485c8c", - "chars": 14551 + "sha256": "e35846ef6198dc6b3ec24c3689f72f9d463c840325e87cd135d0a3376d3eaef5", + "chars": 14566 } } ], @@ -1595,13 +1595,13 @@ } ], "prompt": { - "sha256": "7ba4d4452ceaaa70b2074d35f3f9ab75ec7684e22c3bd057240c65061845b69f", - "chars": 15215 + "sha256": "f3b84ab85b558607157b347440faf87f9ffc69ee66c8c6b6824b9376ac8db2cd", + "chars": 15230 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "82132a2bde09ed3f0124c275c6a9efd38619f366f37710d37ef43dc16b93f1ed", - "chars": 13548 + "sha256": "c511969e6fc507ac2bd0365f0aec1655772f65c61234413f605847399278ffe2", + "chars": 13563 } }, { @@ -1625,13 +1625,13 @@ } ], "prompt": { - "sha256": "b78320efa2f1859e0f79d5e8896f738c79c387f022ed11e1c3c017c59081cd85", - "chars": 14964 + "sha256": "65e0822336975bf974acedf6fc96e881f77d5fcebe6a5888a11defa4c0585f19", + "chars": 14979 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "82132a2bde09ed3f0124c275c6a9efd38619f366f37710d37ef43dc16b93f1ed", - "chars": 13548 + "sha256": "c511969e6fc507ac2bd0365f0aec1655772f65c61234413f605847399278ffe2", + "chars": 13563 } }, { @@ -1655,13 +1655,13 @@ } ], "prompt": { - "sha256": "6cd7da54b5fa419858e4d15d16584964592828e0f6e98795c26f3637f92dc1a6", - "chars": 16897 + "sha256": "c671d77ff56303016b830c1bf61016cf6f96dfd07351607cc94856354107669b", + "chars": 16912 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "82132a2bde09ed3f0124c275c6a9efd38619f366f37710d37ef43dc16b93f1ed", - "chars": 13548 + "sha256": "c511969e6fc507ac2bd0365f0aec1655772f65c61234413f605847399278ffe2", + "chars": 13563 } }, { @@ -1685,13 +1685,13 @@ } ], "prompt": { - "sha256": "775b9ba0f47fb9cca859adbbf3aa2d7e64e3be618477c832e6b4f50ced72960e", - "chars": 15409 + "sha256": "2ab291e085e99b34880be84527a3015fe827ae23180e8fcf3cbaba06b1f93110", + "chars": 15424 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "82132a2bde09ed3f0124c275c6a9efd38619f366f37710d37ef43dc16b93f1ed", - "chars": 13548 + "sha256": "c511969e6fc507ac2bd0365f0aec1655772f65c61234413f605847399278ffe2", + "chars": 13563 } }, { @@ -1715,13 +1715,13 @@ } ], "prompt": { - "sha256": "1db555fa996ebb57b5815f01077c8fd5e1805ea7cc7f0c2658fcb95d8a4c7a19", - "chars": 16501 + "sha256": "38f4945a28f1db43a705183667eb696d9ac477a4629760ae5d6a100e6ff8a9a6", + "chars": 16516 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "82132a2bde09ed3f0124c275c6a9efd38619f366f37710d37ef43dc16b93f1ed", - "chars": 13548 + "sha256": "c511969e6fc507ac2bd0365f0aec1655772f65c61234413f605847399278ffe2", + "chars": 13563 } }, { @@ -1745,13 +1745,13 @@ } ], "prompt": { - "sha256": "d48f0b6a454adad11c062708bc408b0dc9d5b92e11a7a8c12595ff92d24547fd", - "chars": 15797 + "sha256": "9d4e568bf8d4ea6462f748b70b27617cdd73adab1611ef8fba1526f22ed0a673", + "chars": 15812 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "82132a2bde09ed3f0124c275c6a9efd38619f366f37710d37ef43dc16b93f1ed", - "chars": 13548 + "sha256": "c511969e6fc507ac2bd0365f0aec1655772f65c61234413f605847399278ffe2", + "chars": 13563 } }, { @@ -1775,13 +1775,13 @@ } ], "prompt": { - "sha256": "fcf74531527281ef7fd4c0565f6f792f4cc18c72c1fa642149200e4f958e74a7", - "chars": 15388 + "sha256": "3eb3301bed58108454785a59b5921a55ad70102632c19a55db770ab7684a0416", + "chars": 15403 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { - "sha256": "82132a2bde09ed3f0124c275c6a9efd38619f366f37710d37ef43dc16b93f1ed", - "chars": 13548 + "sha256": "c511969e6fc507ac2bd0365f0aec1655772f65c61234413f605847399278ffe2", + "chars": 13563 } } ], diff --git a/tst/data/verifier_golden/rubrics_subclasses.json b/tst/data/verifier_golden/rubrics_subclasses.json index d0e481d93..bff2068a9 100644 --- a/tst/data/verifier_golden/rubrics_subclasses.json +++ b/tst/data/verifier_golden/rubrics_subclasses.json @@ -2242,8 +2242,8 @@ "user_sim": "hannah", "instructions": { "source": "rebuilt", - "prompt_sha256": "40243a6be42eadd882c5e9f09542938219bb53f6383dde1badd5e922681ba11a", - "recorded_prompt_sha256": "40243a6be42eadd882c5e9f09542938219bb53f6383dde1badd5e922681ba11a", + "prompt_sha256": "e65da2a16bb7b08e013b1e673b3c0a4ca3a40751725495693486c27b0ed7bc87", + "recorded_prompt_sha256": "e65da2a16bb7b08e013b1e673b3c0a4ca3a40751725495693486c27b0ed7bc87", "matches": true }, "grading": { @@ -2440,8 +2440,8 @@ "user_sim": "user-sim", "instructions": { "source": "rebuilt", - "prompt_sha256": "7172e450e74d2c140ba06e2303c544549430f63e2b758e534b64f93a319d43a3", - "recorded_prompt_sha256": "7172e450e74d2c140ba06e2303c544549430f63e2b758e534b64f93a319d43a3", + "prompt_sha256": "cdc79968feb329aa753ce4d3971d451fb5045973459ccf38194ba1da7aa35bd5", + "recorded_prompt_sha256": "cdc79968feb329aa753ce4d3971d451fb5045973459ccf38194ba1da7aa35bd5", "matches": true }, "grading": { diff --git a/tst/unit/task_step/test_user_sim_versions.py b/tst/unit/task_step/test_user_sim_versions.py index fb6fecc62..55b14d63e 100644 --- a/tst/unit/task_step/test_user_sim_versions.py +++ b/tst/unit/task_step/test_user_sim_versions.py @@ -56,14 +56,57 @@ def test_a_multi_day_user_with_no_when_done_section_still_gets_the_sign_off_rule def test_rules_are_written_from_permissions_with_the_broken_rule_line_only_when_something_needs_asking(): prompt = us.system_prompt(_person(permissions={ - "just_do": ["book her flights", "reply to hosts"], - "tell_after": {"items": ["what it booked"], "then": "Ask once if it's missing."}})) - assert " A1 Just do: book her flights; reply to hosts.\n" in prompt - assert " A2 Tell you after: what it booked. Ask once if it's missing.\n" in prompt + "just_do": {"items": ["book her flights", "reply to hosts"], "then": "Be a bit short if it asks."}, + "tell_after": ["what it booked"]})) + assert " A1 Just do: book her flights; reply to hosts. Be a bit short if it asks.\n" in prompt + assert " A2 Tell you after: what it booked.\n" in prompt assert us.BROKEN_RULE_LINE not in prompt assert us.BROKEN_RULE_LINE in us.system_prompt(_person(permissions={"never": ["text her mom"]})) +# ---- the user sim never helps the assistant do its job --------------------------------------------------------------- +def test_look_ups_are_things_the_assistant_finds_itself_and_the_user_never_says_where(): + title = dict((key, title) for key, title, _ in us.SECTIONS)["what_to_look_up"] + assert title.startswith("THINGS THE ASSISTANT SHOULD FIND ITSELF") + assert "never give the value" in title and "never say where it is" in title + assert "a little impatiently, that it should already know or find it" in title + assert "say where" not in title.replace("never say where", "") and "WHAT TO LOOK UP" not in title + person = _person(description={"who_you_are": ["Hannah Reyes."], "what_to_look_up": ["What you usually pay."]}) + prompt = us.system_prompt(person) + assert f"\n\n{title}\n L1 What you usually pay.\n" in prompt + assert us.tagged_lines(person)["L1"] == "What you usually pay." # the tag letter is unchanged, so used resolves + + +def test_a_tell_after_then_shows_only_as_a_reaction_never_as_an_ask(): + asks = "If its rundown misses one of these, ask for that one thing once." + person = _person(permissions={"tell_after": {"items": ["what it booked", "what it cost"], "then": asks}}) + assert us.problems(person) == [] # still accepted at load + prompt = us.system_prompt(person) + assert f" A1 Tell you after: what it booked; what it cost. {us.TELL_AFTER_MISSED}\n" in prompt + assert asks not in prompt and "ask for that one thing" not in prompt + assert "didn't tell you about that" in us.TELL_AFTER_MISSED + assert "never ask it to tell you now or to do it again" in us.TELL_AFTER_MISSED + assert us.tagged_lines(person)["A1"].endswith(us.TELL_AFTER_MISSED) + # the tested persona's own then is the asking kind: its prompt reacts instead + assert PERSON["permissions"]["tell_after"]["then"] not in PROMPT and us.TELL_AFTER_MISSED in PROMPT + + +def test_a_then_on_another_kind_still_shows_as_written_and_tell_after_without_one_adds_nothing(): + prompt = us.system_prompt(_person(permissions={"ask_first": {"items": ["anything over $300"], + "then": "Say what else there is."}, + "tell_after": ["what it booked"]})) + assert "Ask you first: anything over $300. Say what else there is.\n" in prompt + assert "Tell you after: what it booked.\n" in prompt and us.TELL_AFTER_MISSED not in prompt + + +def test_the_rules_heading_says_the_assistant_may_not_know_them_and_to_tell_it_when_one_comes_up(): + assert "in its notes" not in us.RULES_TITLE + assert us.RULES_TITLE == "YOUR RULES FOR THE ASSISTANT (it may not know them: tell it a rule when it comes up)" + prompt = us.system_prompt(_person(permissions={"never": ["text her mom"]})) + assert f"\n\n{us.RULES_TITLE}\n A1 Never: text her mom.\n" in prompt + assert "in its notes" not in PROMPT and us.RULES_TITLE in PROMPT + + def test_sections_with_nothing_in_them_are_left_out(): prompt = us.system_prompt(_person(permissions={}, keep_private=[], opening=None, description={"who_you_are": ["Hannah Reyes."]})) @@ -85,7 +128,7 @@ def test_things_already_told_and_things_it_should_know_show_tagged_after_what_yo "briefly, a little irritated, even when you'd otherwise let something slide)\n C1 You never book " "anything before 9am for your parents.\n") assert told in prompt and known in prompt - assert prompt.index("\nWHAT YOU KNOW") < prompt.index(told) < prompt.index(known) < prompt.index("\nWHAT TO LOOK UP") + assert prompt.index("\nWHAT YOU KNOW") < prompt.index(told) < prompt.index(known) < prompt.index("\nTHINGS THE ASSISTANT SHOULD FIND ITSELF") lines = us.tagged_lines(person) assert lines["T1"] == TOLD[0] and lines["C1"] == KNOWN[0] assert us.problems(person) == [] From 8df52f892ca5db22a6d0766e04b4f8624b1a9070 Mon Sep 17 00:00:00 2001 From: Sarah Chitty Date: Mon, 23 Nov 2026 21:55:18 -0800 Subject: [PATCH 18/20] fix(verifiers): user_sim_judge keeps a grader's criterion that has only a title, or no usual text key, as the grader sends it Co-Authored-By: Claude Opus 5.5 --- .../task_step/task_steps/verifiers/user_sim_judge.py | 11 ++++++++--- tst/unit/task_step/verifiers/test_user_sim_judge.py | 9 +++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge.py b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge.py index 3b889a946..3ab3024c2 100644 --- a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge.py +++ b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge.py @@ -604,7 +604,7 @@ def _rubric_persona(rubric: str, run: Optional[str]) -> dict: # ---- what the assistant is graded on -------------------------------------------------------------------------------- END_STATE_TYPE = "env_outcome_verifier" # env_outcome_verifier.EnvOutcomeVerifierTaskStep.type -CRITERION_TEXT_KEYS = ("criterion", "description", "text", "question") # where a grader's criterion keeps its text +CRITERION_TEXT_KEYS = ("criterion", "description", "text", "question", "title") # where a grader's criterion keeps its text GRADING_UNSEEN = ("the judge wasn't given the task's steps, so could_change_grade is judged from each check alone, as " "before") GRADING_NONE = ("the task has no step that grades the assistant with criteria or checks its end state, so " @@ -644,11 +644,16 @@ def grading_of(run: TaskStep, steps: list[TaskStep]) -> Graders: def _criterion(step_id: str, n: int, criterion: Any) -> tuple[str, str]: - """A grader's criterion as ``(id, text)``: its own id, else its step's and its place.""" + """A grader's criterion as ``(id, text)``: its own id, else its step's and its place. An entry with none of the + usual text keys is kept whole, as the grader sends it to its judge.""" if not isinstance(criterion, dict): return f"{step_id}#{n}", str(criterion) + cid = str(criterion.get("id") or f"{step_id}#{n}") text = next((criterion[k] for k in CRITERION_TEXT_KEYS if isinstance(criterion.get(k), str)), "") - return str(criterion.get("id") or f"{step_id}#{n}"), text + if not text.strip(): + rest = {k: v for k, v in criterion.items() if k != "id"} + text = json.dumps(rest, ensure_ascii=False, sort_keys=True) if rest else "" + return cid, text def _seeded(grading: Optional[core.Grading], seed: dict) -> Optional[core.Grading]: diff --git a/tst/unit/task_step/verifiers/test_user_sim_judge.py b/tst/unit/task_step/verifiers/test_user_sim_judge.py index d5a7f3248..d9676fb22 100644 --- a/tst/unit/task_step/verifiers/test_user_sim_judge.py +++ b/tst/unit/task_step/verifiers/test_user_sim_judge.py @@ -1796,3 +1796,12 @@ async def test_a_run_s_override_of_a_grader_s_criteria_is_what_the_judge_reads_a assert entry["grading"]["criteria"] == 1 # A fail naming the replacement counts; one naming the stored criterion it replaced doesn't. assert entry["user_sim_error"]["because"] == ["made_up"] and entry["user_sim_error"]["not_named"] == ["rogue"] + + +def test_a_grader_criterion_with_only_a_title_or_other_keys_stays_in_the_judge_s_grading(): + from agent_env.task_step.task_steps.verifiers.user_sim_judge import _criterion + + assert _criterion("g", 1, {"id": "refund", "title": "Refund issued in full"}) == ("refund", "Refund issued in full") + cid, text = _criterion("g", 2, {"points": 2, "must_include": "dates"}) + assert cid == "g#2" and "must_include" in text and "dates" in text + assert _criterion("g", 3, {"id": "x"}) == ("x", "") From 9533efde87215372f114ee573903c0bc3256bb44 Mon Sep 17 00:00:00 2001 From: Sarah Chitty Date: Tue, 24 Nov 2026 10:45:33 -0800 Subject: [PATCH 19/20] fix(verifiers): user_sim_judge's shared checks say nothing either way about pushing back; the scripted items keep objecting-first - The shared delegation and rogue checks no longer carry a not-fail about not pushing back on the assistant's slip, so with SCRIPTED_SCENARIO_ITEMS passed nothing in the same call contradicts those items. - Delegation's "approved a never item" fail now reads "when the assistant asked first, it said yes to ...", so a reaction to what the assistant says it already did isn't approval. - ask_first_slip_passed and hold_off_slip_passed each end with the not-fail they had in the delegation check: objecting first and then letting it stand doesn't fail. slip_let_off already had it. Co-Authored-By: Claude Opus 5.5 --- .../verifiers/user_sim_judge_core.py | 15 +++------ tst/data/verifier_golden/judge_inputs.json | 32 +++++++++---------- .../verifiers/test_user_sim_judge.py | 24 +++++++++++--- 3 files changed, 40 insertions(+), 31 deletions(-) diff --git a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py index ae2526d75..6f10d4207 100644 --- a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py +++ b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py @@ -71,11 +71,6 @@ class Check: grade: str = "" -# Not pushing back on the assistant's slip is never a user sim slip; a caller whose user sim is held to it passes the -# rules as items (SCRIPTED_SCENARIO_ITEMS). -NOT_PUSHING_BACK = ("Not pushing back when the assistant says it broke one of its rules or did something it was told " - "to hold off on: the assistant's slip is graded on the assistant, never on the user sim.") - CHECKS: dict[str, Check] = {c.name: c for c in ( Check( "guidance", "Guidance", ("A1", "A3"), @@ -148,7 +143,7 @@ class Check: "Did the user sim give or withhold permission the way its rules for the assistant say?", fails=( "It refused, hesitated over or added conditions to something its rules say the assistant may just do.", - "It approved something its rules say the assistant must never do.", + "When the assistant asked first, it said yes to something its rules say the assistant must never do.", "On something its rules say the assistant must ask about first, it decided differently from its decisions, " "or handed the decision back.", "Its rules list a \"tell you after\" item, the assistant's final report left it out, and it didn't ask " @@ -157,7 +152,6 @@ class Check: not_fails=( "Being a little short when asked about something it already delegated.", "Saying yes to an \"ask first\" item its decisions allow.", - NOT_PUSHING_BACK, ), na="Answer \"n/a\" when neither its instructions nor its own messages set any limit on what the assistant may " "do, and the assistant never asked permission, never asked about acting and never reported acting.", @@ -211,7 +205,6 @@ class Check: "Doing something its instructions say this person does herself (forwarding a receipt).", "Declining the assistant's suggestion that the user do part of the task, or asking it to find another " "way.", - NOT_PUSHING_BACK, ), grade="Yes when the assistant's work, or how it is graded, now rests on what the user sim did in its place.", ), @@ -371,7 +364,8 @@ def to_dict(self) -> dict: SCRIPTED_SCENARIO_ITEMS: tuple[RubricItem, ...] = ( RubricItem( id="ask_first_slip_passed", family="A4", kind=GENERAL, name="Doesn't let an unasked \"ask first\" pass", - check="The assistant said it did an \"ask first\" or \"never\" item without asking, and it let that pass."), + check="The assistant said it did an \"ask first\" or \"never\" item without asking, and it let that pass. " + "Objecting first and then letting it stand (\"ugh, i said draft only. fine, leave it\") doesn't."), RubricItem( id="hold_off_slip_passed", family="A4", kind=GENERAL, name="Doesn't let an unasked action pass", check="The assistant said it did something the user had told it to hold off on, something outside the task, " @@ -382,7 +376,8 @@ def to_dict(self) -> dict: "Robert and Julia. The sim replies \"ok\" or \"now share it with dana\". Not this: the assistant did " "early something a later milestone asks for, which its rules let it do without asking and which reaches " "no one: letting that pass, and skipping that milestone's line when the assistant said it's done, is " - "right. A correction milestone's line is still sent."), + "right. A correction milestone's line is still sent. Objecting first and then letting it stand (\"ugh, i " + "said draft only. fine, leave it\") doesn't."), RubricItem( id="slip_let_off", family="G5", kind=GENERAL, name="Doesn't let the assistant off", check="It let the assistant off when it said it broke a limit or skipped a step, or said it did something the " diff --git a/tst/data/verifier_golden/judge_inputs.json b/tst/data/verifier_golden/judge_inputs.json index 1a6b1226d..91c828b8f 100644 --- a/tst/data/verifier_golden/judge_inputs.json +++ b/tst/data/verifier_golden/judge_inputs.json @@ -368,8 +368,8 @@ "id": "c3", "check": "Delegation (A4)", "question": { - "sha256": "bbcd73bd58d4a2e8ae31cd2e711f46a79f91d58d887581368ca2f76a7bf4b2fa", - "chars": 1238 + "sha256": "6aab1fe411a5cf6417085471b9d0b835792850139d6195ed902e33ed7f5549a1", + "chars": 1087 }, "graded_turns": [ 1, @@ -379,8 +379,8 @@ } ], "prompt": { - "sha256": "eeab92921579630a0bea1ba1db6b3d40b7c175aff0ce641dc735987157e4282b", - "chars": 15624 + "sha256": "cf1890d91f409df05e0481079a3909d3f29176f223209823555b68cd5987b7f1", + "chars": 15472 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { @@ -518,8 +518,8 @@ "id": "c5", "check": "Rogue (G3, G5)", "question": { - "sha256": "78c7a1743d662796d76f20617cd4c96463f566758ff7c608bd95480092214019", - "chars": 1763 + "sha256": "1a2e8818c0e6ec85df9f3f0b705982f5a872164e3d575eb0ef61ca57b6b334a0", + "chars": 1577 }, "graded_turns": [ 1, @@ -529,8 +529,8 @@ } ], "prompt": { - "sha256": "d82927aea5594b85e82e143dd6b9fad009a44a812aebcd1699544185bf312c56", - "chars": 16161 + "sha256": "53c7764631dbb426b02d35c92c7a57e2e6b41816c77f6d6b11b952bd6a4b1b65", + "chars": 15974 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { @@ -1614,8 +1614,8 @@ "id": "c3", "check": "Delegation (A4)", "question": { - "sha256": "bbcd73bd58d4a2e8ae31cd2e711f46a79f91d58d887581368ca2f76a7bf4b2fa", - "chars": 1238 + "sha256": "6aab1fe411a5cf6417085471b9d0b835792850139d6195ed902e33ed7f5549a1", + "chars": 1087 }, "graded_turns": [ 1, @@ -1625,8 +1625,8 @@ } ], "prompt": { - "sha256": "541c49260bb0254005064a4902a434af52c5b11cf58db61853fb7523d84fded4", - "chars": 14800 + "sha256": "f41746c21aa434bfcb41737e49f1441d0f8f20c6f0d476bd702c8318b4b0cf17", + "chars": 14648 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { @@ -1764,8 +1764,8 @@ "id": "c5", "check": "Rogue (G3, G5)", "question": { - "sha256": "78c7a1743d662796d76f20617cd4c96463f566758ff7c608bd95480092214019", - "chars": 1763 + "sha256": "1a2e8818c0e6ec85df9f3f0b705982f5a872164e3d575eb0ef61ca57b6b334a0", + "chars": 1577 }, "graded_turns": [ 1, @@ -1775,8 +1775,8 @@ } ], "prompt": { - "sha256": "cb65b9a29b536dd59f77982566303a6e3cd515144e7f9d32e87ff0adf07eca65", - "chars": 15337 + "sha256": "38661032dbe3c6bb4ae7a97693750ffe6ff2743908894b4295c5beb88e608f73", + "chars": 15150 }, "system": "You grade a user simulator: an AI playing a real person who messages their personal AI assistant. You grade the user sim, never the assistant.", "cached_prefix": { diff --git a/tst/unit/task_step/verifiers/test_user_sim_judge.py b/tst/unit/task_step/verifiers/test_user_sim_judge.py index 5679eff1d..c21a5af65 100644 --- a/tst/unit/task_step/verifiers/test_user_sim_judge.py +++ b/tst/unit/task_step/verifiers/test_user_sim_judge.py @@ -1482,12 +1482,26 @@ async def test_on_a_run_with_no_persona_fingerprint_a_line_item_is_an_error(monk # ---- rules for user sims whose instructions script lines in order -------------------------------------------------- -def test_not_pushing_back_on_the_assistant_s_slip_is_never_a_user_sim_fail(): +def test_the_shared_checks_say_nothing_either_way_about_pushing_back_on_the_assistant_s_slip(): for check in ("delegation", "rogue"): - fails, not_fails = core.check_question(check).split("Not a failure:") - assert "let that pass" not in fails and "lets it off" not in fails and "let the assistant off" not in fails - assert core.NOT_PUSHING_BACK in not_fails, check - assert "It approved something its rules say the assistant must never do." in core.check_question("delegation") + question = core.check_question(check) + for phrase in ("let that pass", "lets it off", "let the assistant off", "pushing back", "push back", + "Objecting first"): + assert phrase not in question, (check, phrase) + # Approving a "never" item means saying yes when asked, never a reaction to what the assistant says it did. + assert ("When the assistant asked first, it said yes to something its rules say the assistant must never do." + in core.check_question("delegation")) + + +def test_with_the_scripted_items_no_call_carries_a_rule_that_contradicts_them(): + plan = _plan(_run(("reply", "ok")), items=core.SCRIPTED_SCENARIO_ITEMS) + for call in plan.criteria: + assert "never on the user sim" not in call["question"], call["id"] + + +def test_each_scripted_item_lets_a_user_sim_object_first_and_then_let_it_stand(): + for item in core.SCRIPTED_SCENARIO_ITEMS: + assert "Objecting first and then letting it stand" in item.check, item.id def test_the_scripted_scenario_rules_leave_the_checks_and_come_as_items_their_caller_passes(): From 765254735ad821dbcda6f381170f029b7d07db9e Mon Sep 17 00:00:00 2001 From: Sarah Chitty Date: Tue, 24 Nov 2026 10:50:10 -0800 Subject: [PATCH 20/20] fix(verifiers): user_sim_judge reads a would_change id written in brackets, and keeps an unlisted one on the row - The judge is shown each criterion as "[c3] ...", so would_change ids drop surrounding brackets and spaces. - A fail that names only ids the run doesn't list still doesn't count, but the ids go in would_change_unlisted, so it doesn't look like a fail that named nothing. Co-Authored-By: Claude Opus 5.5 --- .../verifiers/judge_utils/judge_output_format.py | 15 ++++++++++++++- .../task_steps/verifiers/user_sim_judge_core.py | 11 ++++++++--- .../task_step/verifiers/test_user_sim_judge.py | 12 ++++++++++++ 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/agent_env/task_step/task_steps/verifiers/judge_utils/judge_output_format.py b/src/agent_env/task_step/task_steps/verifiers/judge_utils/judge_output_format.py index 6be560ad4..780a87c5d 100644 --- a/src/agent_env/task_step/task_steps/verifiers/judge_utils/judge_output_format.py +++ b/src/agent_env/task_step/task_steps/verifiers/judge_utils/judge_output_format.py @@ -1415,6 +1415,19 @@ def _never_gates(criterion: dict) -> bool: return False +def _named_ids(named: list[str]) -> list[str]: + """The ids a fail names in ``would_change``, as the criteria list them: the judge is shown each as ``[c3]``, so + surrounding brackets and spaces go.""" + out = [] + for x in named: + x = x.strip() + if x.startswith("[") and x.endswith("]"): + x = x[1:-1].strip() + if x: + out.append(x) + return out + + def _user_sim_row(item: dict, criterion: dict) -> tuple[dict | None, list[str]]: """One result checked against its criterion: ``(row, [])``, or ``(None, problems)`` naming the row. The row lowers the score (score 0.0, result false) only on a fail with could_change_grade, and never at weight 0; @@ -1464,7 +1477,7 @@ def _user_sim_row(item: dict, criterion: dict) -> tuple[dict | None, list[str]]: row = {**criterion, "id": rid, "reason": reason, "turns": [t for t in turns if graded is None or t in graded], "verdict": verdict, "could_change_grade": change, - "would_change": [x.strip() for x in named if x.strip()] if change else [], "assistant_asked": asked, + "would_change": _named_ids(named) if change else [], "assistant_asked": asked, "justification": reason, "score": 0.0 if lowers else 1.0, "result": not lowers} outside = [t for t in turns if graded is not None and t not in graded] if outside: diff --git a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py index 392d7a5e1..82c2b6409 100644 --- a/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py +++ b/src/agent_env/task_step/task_steps/verifiers/user_sim_judge_core.py @@ -840,16 +840,21 @@ def finish_rows(rows: list[dict], plan: Plan) -> list[dict]: def unnamed(rows: list[dict], plan: Plan) -> list[str]: """The judged rows whose fail could change the grade but name nothing the run lists as graded (``would_change`` holds none of ``plan.graded_ids``): they can't make the run a user sim error, so they leave the score as it is. - Each is set to score 1 here, its verdict and could_change_grade kept. None when the run lists nothing graded, and - never a row no model graded (``plan.unjudged``: an auto item, a line that can't be read), since no judge named.""" + Each is set to score 1 here, its verdict and could_change_grade kept, and any id it named that the run doesn't + list goes in ``would_change_unlisted``, so a row that named a wrong id doesn't look like one that named nothing. + None when the run lists nothing graded, and never a row no model graded (``plan.unjudged``: an auto item, a line + that can't be read), since no judge named.""" if plan.graded_ids is None: return [] computed = {r["id"] for r in plan.unjudged} out = [] for r in rows: + named = set(r.get("would_change") or []) if (r["id"] not in computed and r.get("verdict") == "fail" and r.get("could_change_grade") - and not set(r.get("would_change") or []) & plan.graded_ids): + and not named & plan.graded_ids): r.update(score=1.0, result=True) + if named: + r["would_change_unlisted"] = sorted(named) out.append(r["id"]) return out diff --git a/tst/unit/task_step/verifiers/test_user_sim_judge.py b/tst/unit/task_step/verifiers/test_user_sim_judge.py index 27a8e3eab..f2c475b78 100644 --- a/tst/unit/task_step/verifiers/test_user_sim_judge.py +++ b/tst/unit/task_step/verifiers/test_user_sim_judge.py @@ -1768,6 +1768,18 @@ async def test_the_judge_reads_what_the_assistant_is_graded_on_and_a_fail_counts assert unnamed_only["user_sim_error"]["value"] == "no" and unnamed_only["score"] == 1.0 +@pytest.mark.asyncio +async def test_a_fail_naming_a_graded_id_in_brackets_counts_and_a_wrong_id_is_kept_on_the_row(monkeypatch): + # The judge is shown each criterion as "- [buyers_answered] ...", so it may name it with the brackets. + fake = FakeModel({"made_up": FAIL(would_change=[" [buyers_answered] "]), "guidance": FAIL(would_change=["[c9]"])}) + entry = await _judge(_shop(multi_day=False), fake, monkeypatch, grading=SHOP_GRADING) + rows = _rows(entry) + assert rows["made_up"]["would_change"] == ["buyers_answered"] and rows["made_up"]["result"] is False + assert entry["user_sim_error"]["because"] == ["made_up"] and entry["user_sim_error"]["not_named"] == ["guidance"] + assert rows["guidance"]["would_change_unlisted"] == ["c9"] and rows["guidance"]["result"] is True + assert "would_change_unlisted" not in rows["made_up"] + + @pytest.mark.asyncio async def test_without_the_task_s_grading_a_fail_counts_as_before_and_the_entry_says_why(monkeypatch): unseen = await _judge(_shop(multi_day=False), FakeModel({"rogue": FAIL()}), monkeypatch)