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..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 @@ -143,27 +143,15 @@ 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.", - "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.", ), 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 +198,13 @@ 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.", ), 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 +353,43 @@ 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. " + "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, " + "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. 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 " + "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..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": "f0d06ee0e730ed5ba5c510cd8af30264c5031201b289c1ac1552199c3ad75906", - "chars": 2067 + "sha256": "6aab1fe411a5cf6417085471b9d0b835792850139d6195ed902e33ed7f5549a1", + "chars": 1087 }, "graded_turns": [ 1, @@ -379,8 +379,8 @@ } ], "prompt": { - "sha256": "d3cfa33e15797595ff396f09d952d9d424c7395736719072b219506487e6bbd9", - "chars": 16472 + "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": "cbd8402b56dea793524e275eda6e419a8aea127bd0efa38bc704211358147cc9", - "chars": 2431 + "sha256": "1a2e8818c0e6ec85df9f3f0b705982f5a872164e3d575eb0ef61ca57b6b334a0", + "chars": 1577 }, "graded_turns": [ 1, @@ -529,8 +529,8 @@ } ], "prompt": { - "sha256": "dc62637bb7a81bcc12eedcd24e2902c541f7da13eebaea9fff7e420b3742acd8", - "chars": 16837 + "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": "f0d06ee0e730ed5ba5c510cd8af30264c5031201b289c1ac1552199c3ad75906", - "chars": 2067 + "sha256": "6aab1fe411a5cf6417085471b9d0b835792850139d6195ed902e33ed7f5549a1", + "chars": 1087 }, "graded_turns": [ 1, @@ -1625,8 +1625,8 @@ } ], "prompt": { - "sha256": "d74e2262304f35bcf319c67d8803c849987f2ca7787965440ba931bc88e51e98", - "chars": 15648 + "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": "cbd8402b56dea793524e275eda6e419a8aea127bd0efa38bc704211358147cc9", - "chars": 2431 + "sha256": "1a2e8818c0e6ec85df9f3f0b705982f5a872164e3d575eb0ef61ca57b6b334a0", + "chars": 1577 }, "graded_turns": [ 1, @@ -1775,8 +1775,8 @@ } ], "prompt": { - "sha256": "65ee7a6f04375dfe6581292893d7984024e90f462123629458999495ab697990", - "chars": 16013 + "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 8840e8bca..c21a5af65 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,59 @@ 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_the_shared_checks_say_nothing_either_way_about_pushing_back_on_the_assistant_s_slip(): + for check in ("delegation", "rogue"): + 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(): + 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"