From 4299fbdad71db2b5e8ff37aa8b9fe239402a8f67 Mon Sep 17 00:00:00 2001 From: Yev Meyer Date: Tue, 17 Nov 2026 14:28:33 -0500 Subject: [PATCH 1/6] fix(probes): show tool_calling's simulated service its other endpoints The tool simulator and its judge read only the called tool's spec, so an ID one tool returned could take a form another offered tool does not accept: a listing tool returning `pet_8f3c1d92` where the detail tool takes an integer `pet_id`, and every follow-up call then failed its schema check. Both now read the service's other endpoints, the other offered tools with their parameter types, one per line (`_other_endpoints`). An ID or other value a response returns has the type and form those endpoints take for it, and the judge fails a response that returns one they don't take. The tool_calling prompt version is v1.12. Signed-off-by: Yev Meyer --- .../engine/probes/tool_calling/README.md | 15 +++--- .../assets/tool_calling/README.md | 16 ++++--- .../assets/tool_calling/prompts.yaml | 14 ++++++ .../engine/probes/tool_calling/probe.py | 32 ++++++++++++- .../engine/probes/tool_calling/prompts.py | 14 ++++++ tests/probes/tool_calling/contract.py | 2 +- tests/probes/tool_calling/test_probe.py | 48 ++++++++++++++++++- 7 files changed, 125 insertions(+), 16 deletions(-) diff --git a/src/usersim/engine/probes/tool_calling/README.md b/src/usersim/engine/probes/tool_calling/README.md index 1ae0aa5e..17b7edfb 100644 --- a/src/usersim/engine/probes/tool_calling/README.md +++ b/src/usersim/engine/probes/tool_calling/README.md @@ -26,12 +26,15 @@ the other probes. - The assistant is offered the tools. A call that breaks the tool's schema gets a 400, a call without the user's credential gets a 401, and any other call gets a response the `api_response_model` writes for that tool. It writes from - what the service would see: the call, the calls made earlier in the - conversation with their responses, and its clock, never the conversation's - messages, so a detail the user gives reaches it only through the arguments the - assistant passes. Before the assistant sees the response, `judge_model` - checks it against the call (the tool's description, the arguments, the - earlier calls' responses, the clock, any computed value) and has a rejected + what the service would see: the call, the service's other endpoints (the + other offered tools, with their parameter types), the calls made earlier in + the conversation with their responses, and its clock, never the + conversation's messages, so a detail the user gives reaches it only through + the arguments the assistant passes. An ID or other value it returns has the + type and form the other endpoints take for it. Before the assistant sees the + response, `judge_model` checks it against the call (the tool's description, + the arguments, the other endpoints, the earlier calls' responses, the clock, + any computed value) and has a rejected one rewritten with its reason; a response still rejected when the attempts run out stands, and the row carries an `unverified_tool_response` warning. A call that sets a new password leaves diff --git a/src/usersim/engine/probes/tool_calling/assets/tool_calling/README.md b/src/usersim/engine/probes/tool_calling/assets/tool_calling/README.md index fc3dca58..7dfa47ff 100644 --- a/src/usersim/engine/probes/tool_calling/assets/tool_calling/README.md +++ b/src/usersim/engine/probes/tool_calling/assets/tool_calling/README.md @@ -117,10 +117,13 @@ toolsets_seed.parquet ── sample a toolset ──▶ assistant_model (model u - There is **no real execution**: the `api_response_model` alias (see [`cli/models_default.toml`](../../../../../cli/models_default.toml)) synthesizes the tool's response from the schema, so a run needs no live service. It sees - what the service would: the call, the calls made earlier in the conversation - with their responses and the time each was made, which it keeps consistent - with, and its clock, noon UTC on the conversation's date at the user's first - message and two minutes later with each one after, up to 12:59, but none of + what the service would: the call, the service's other endpoints (the other + offered tools' names and parameter types), whose parameters an ID or other + value it returns fits, such as an integer ID where they take an integer, the + calls made earlier in the conversation with their responses and the time + each was made, which it keeps consistent with, and its clock, noon UTC on + the conversation's date at the user's first message and two minutes later + with each one after, up to 12:59, but none of the conversation's messages. An event after the clock has no result yet, while what is planned for later, such as a schedule, a listing or a forecast, already exists; an identical call returns the same data, except @@ -147,8 +150,9 @@ toolsets_seed.parquet ── sample a toolset ──▶ assistant_model (model u assistant sees it: that it answers the call, agrees with the earlier calls' responses and the clock, gives no result for an event later than the clock while letting a schedule or forecast for later stand, - computes values correctly, and holds no placeholder - such as an `example.com` link. It checks real-world facts only where the + computes values correctly, returns IDs and values of the type and form the + service's other endpoints take, and holds no placeholder such as an + `example.com` link. It checks real-world facts only where the arguments or the tool's description fix them. A rejected response is rewritten with the judge's reason, within `max_response_attempts` (the probe's `judge_responses` setting turns this off). The judge is the models file's `api_response_judge_model` (the diff --git a/src/usersim/engine/probes/tool_calling/assets/tool_calling/prompts.yaml b/src/usersim/engine/probes/tool_calling/assets/tool_calling/prompts.yaml index 3f0ae163..7b032599 100644 --- a/src/usersim/engine/probes/tool_calling/assets/tool_calling/prompts.yaml +++ b/src/usersim/engine/probes/tool_calling/assets/tool_calling/prompts.yaml @@ -93,6 +93,13 @@ tool_simulator_prompt: |- Tool call arguments: {tool_args} + The service's other endpoints: + + {other_endpoints} + + An ID or other value the response returns has the type and form these endpoints take for it, such as an + integer ID where they take an integer. + The calls this caller made earlier, each with the time it was made and what the service returned, are the service's own records: @@ -134,6 +141,11 @@ tool_simulator_judge_prompt: |- Tool call arguments: {tool_args} {credentials}{caller} + The service's other endpoints: + + {other_endpoints} + + The calls this caller made earlier, each with the time it was made and what the service returned: {earlier_calls} @@ -152,6 +164,7 @@ tool_simulator_judge_prompt: |- kind that moves with it, such as a live score, a job's progress, stock or a price. Anything planned for after the current time, such as a schedule, a listing, a forecast or a booking, is fine. - Every value the tool computes (a total, a conversion, a date difference, a formula) is correct for the arguments. + - An ID or other value it returns that the service's other endpoints take has the type and form they take for it. - It reads like real API output: no placeholder values (an example.com or other example.* host is one) and no commentary around the JSON. - Real-world facts are checked only where the arguments or the tool's description fix them, such as a @@ -162,6 +175,7 @@ tool_simulator_judge_prompt: |- - It answers a different request than the arguments make, or contradicts the tool's description. - It contradicts itself, an earlier response or the current time, or gives a result, score or reading for an event after the current time. - A computed value is wrong. + - It returns an ID or other value in a type or form the service's other endpoints don't take for it. - It holds placeholder values or commentary. - It is an error the call does not warrant. diff --git a/src/usersim/engine/probes/tool_calling/probe.py b/src/usersim/engine/probes/tool_calling/probe.py index 8c1bac3d..4287be4f 100644 --- a/src/usersim/engine/probes/tool_calling/probe.py +++ b/src/usersim/engine/probes/tool_calling/probe.py @@ -130,6 +130,26 @@ def _build_tool_context(tool_subset: list) -> str: return "\n".join(lines) if lines else "No tools available." +def _other_endpoints(tool_subset: list, tool_name: str) -> str: + """The offered tools other than ``tool_name``, one per line as ``- name(parameter: type, ...)``, or ``None.``. + + The tool simulator and its judge read them as the service's other endpoints, so an ID or other value a + response returns has the type and form the endpoints that take it accept. + """ + lines = [] + for tool_data in tool_subset: + spec = _function_spec(tool_data) + name = spec.get("name") + if not name or name == tool_name: + continue + properties = (spec.get("parameters") or {}).get("properties") or {} + parameters = ", ".join( + f"{parameter}: {(schema or {}).get('type', 'any')}" for parameter, schema in properties.items() + ) + lines.append(f"- {name}({parameters})") + return "\n".join(lines) if lines else "None." + + def _row_identity(data: dict) -> str: """The row's identity, which seeds its tool draw and the credentials its user holds. @@ -366,12 +386,14 @@ async def _judge_tool_response( credential_parameters: tuple[str, ...], caller: str = "", judge_alias: str = MODEL_JUDGE, + other_endpoints: str = "None.", ) -> tuple[bool, str] | None: """The ``judge_alias`` model's verdict on one simulated response, ``(passed, explanation)``; None when it can't be read.""" prompt = tool_simulator_judge_prompt().format( now=now, tool_spec=json.dumps(tool_spec, indent=2, default=str), tool_args=tool_args, + other_endpoints=other_endpoints, credentials=( "\n" + tool_simulator_judge_credentials().format( @@ -401,10 +423,13 @@ async def _simulate_tool_response( judge: bool = False, max_attempts: int = 2, judge_alias: str = MODEL_JUDGE, + other_endpoints: str = "None.", ) -> SimulatedResponse: """Use the strong frontier model to simulate a realistic API response. - The simulator sees what the service would: the call, the calls made + The simulator sees what the service would: the call, the service's other + endpoints (``other_endpoints``, from ``_other_endpoints``), whose + parameters the IDs and values it returns fit, the calls made earlier in the conversation with their responses (``_earlier_calls``), which it keeps consistent with, ``now``, the service's clock, which moves as the conversation goes on, after which no event has a result yet though @@ -433,6 +458,7 @@ async def _simulate_tool_response( prompt = tool_simulator_prompt().format( tool_spec=json.dumps(tool_spec, indent=2, default=str), tool_args=tool_args, + other_endpoints=other_endpoints, earlier_calls=earlier_calls, now=now, ) @@ -471,6 +497,7 @@ async def _simulate_tool_response( credential_parameters=credential_parameters, caller=caller, judge_alias=judge_alias, + other_endpoints=other_endpoints, ) except Exception as e: # a judge outage leaves the response standing, flagged logger.warning(" |-- %s raised on a simulated response: %s: %s", judge_alias, type(e).__name__, e) @@ -527,7 +554,7 @@ class ToolCallingProbe(ToolExecutionMixin, ToolCallingMixin, BaseProbe): label = "tool_calling" # Bump on any semantic change to the probe's prompts or task derivation. # One variant: the tool category is the row's ``toolset_category``. - prompt_version = "v1.11" + prompt_version = "v1.12" assets_root = Path(__file__).parent / "assets" # The toolset catalog: each row draws one toolset and reads its tools from # the ``tools`` column. The toolset is also the row's theme, so the probe @@ -813,6 +840,7 @@ async def execute_tool_call( judge=self.options.judge_responses, max_attempts=self.options.max_response_attempts, judge_alias=judge_alias, + other_endpoints=_other_endpoints(self.tool_subset, name), ) simulated_response = simulated.content self._record_simulation( diff --git a/src/usersim/engine/probes/tool_calling/prompts.py b/src/usersim/engine/probes/tool_calling/prompts.py index 46c83f98..46fb2e35 100644 --- a/src/usersim/engine/probes/tool_calling/prompts.py +++ b/src/usersim/engine/probes/tool_calling/prompts.py @@ -117,6 +117,13 @@ Tool call arguments: {tool_args} +The service's other endpoints: + +{other_endpoints} + +An ID or other value the response returns has the type and form these endpoints take for it, such as an +integer ID where they take an integer. + The calls this caller made earlier, each with the time it was made and what the service returned, are the service's own records: @@ -177,6 +184,11 @@ Tool call arguments: {tool_args} {credentials}{caller} +The service's other endpoints: + +{other_endpoints} + + The calls this caller made earlier, each with the time it was made and what the service returned: {earlier_calls} @@ -195,6 +207,7 @@ kind that moves with it, such as a live score, a job's progress, stock or a price. Anything planned for after the current time, such as a schedule, a listing, a forecast or a booking, is fine. - Every value the tool computes (a total, a conversion, a date difference, a formula) is correct for the arguments. +- An ID or other value it returns that the service's other endpoints take has the type and form they take for it. - It reads like real API output: no placeholder values (an example.com or other example.* host is one) and no commentary around the JSON. - Real-world facts are checked only where the arguments or the tool's description fix them, such as a @@ -205,6 +218,7 @@ - It answers a different request than the arguments make, or contradicts the tool's description. - It contradicts itself, an earlier response or the current time, or gives a result, score or reading for an event after the current time. - A computed value is wrong. +- It returns an ID or other value in a type or form the service's other endpoints don't take for it. - It holds placeholder values or commentary. - It is an error the call does not warrant. diff --git a/tests/probes/tool_calling/contract.py b/tests/probes/tool_calling/contract.py index a9e32353..28d9cb1d 100644 --- a/tests/probes/tool_calling/contract.py +++ b/tests/probes/tool_calling/contract.py @@ -24,7 +24,7 @@ CONTRACTS = { "tool_calling": ProbeContract( - trajectory_id="07f08aa06b2909b8", + trajectory_id="50ebb9bb4e3f8150", # A conversation with no tool calls completed its protocol, and the evaluator scores it. succeeds_on=None, parity=(ParityCase(1003, {"tools": [_WEATHER_TOOL]}),), diff --git a/tests/probes/tool_calling/test_probe.py b/tests/probes/tool_calling/test_probe.py index d6abbe43..38a654e9 100644 --- a/tests/probes/tool_calling/test_probe.py +++ b/tests/probes/tool_calling/test_probe.py @@ -28,6 +28,7 @@ _find_tool_spec, _format_now, _format_tools_for_api, + _other_endpoints, _simulate_tool_response, ) from usersim.engine.probes.tool_calling.prompts import ( @@ -62,7 +63,7 @@ def test_assistant_system_prompt_is_empty(self): assert ASSISTANT_SYSTEM_PROMPT == "" def test_tool_simulator_prompt_has_placeholders(self): - for p in ["{tool_spec}", "{tool_args}", "{earlier_calls}"]: + for p in ["{tool_spec}", "{tool_args}", "{other_endpoints}", "{earlier_calls}"]: assert p in TOOL_SIMULATOR_PROMPT def test_user_judge_prompt_has_placeholders(self): @@ -749,6 +750,51 @@ async def test_the_simulator_reads_no_records_for_a_lookup(self, sample_tools): assert "A User" not in prompt +def _tool(tool_name: str, **parameter_types: str) -> dict: + properties = {parameter: {"type": kind} for parameter, kind in parameter_types.items()} + return {"tool": {"type": "function", "function": {"name": tool_name, "parameters": {"properties": properties}}}} + + +class TestOtherEndpoints: + """The simulated service and its judge see the service's other endpoints, so an ID a response returns has the + type the endpoints that take it accept.""" + + def test_each_other_offered_tool_is_listed_with_its_parameter_types(self): + tools = [_tool("add_pet", name="string"), _tool("get_pet", pet_id="integer"), _tool("list_pets")] + + assert _other_endpoints(tools, "add_pet") == "- get_pet(pet_id: integer)\n- list_pets()" + + def test_a_tool_offered_alone_has_no_other_endpoints(self): + assert _other_endpoints([_tool("add_pet", name="string")], "add_pet") == "None." + + async def test_the_simulator_and_its_judge_read_the_probes_other_tools(self, sample_tools): + probe, _data, _cfg = _concrete_tool_probe(sample_tools) + prompts = [] + + async def fake_call_llm(models, alias, messages, **kwargs): + prompts.append(messages[0]["content"]) + return {"content": '{"temp": 22}'} + + async def fake_judge(models, alias, prompt): + prompts.append(prompt) + return "Fine.", "success", True, True + + tool_call = {"id": "c", "function": {"name": "get_weather", "arguments": '{"location": "Tokyo"}'}} + with ( + patch("usersim.engine.probes.tool_calling.probe.acall_llm", side_effect=fake_call_llm), + patch("usersim.engine.probes.tool_calling.probe.run_inline_judge_ex", side_effect=fake_judge), + ): + await probe.execute_tool_call( + "get_weather", {"location": "Tokyo"}, tool_call, ConversationState(), {}, turn_idx=0, call_idx=0 + ) + + expected = _other_endpoints(probe.tool_subset, "get_weather") + assert "- search_recipes(ingredient: string, cuisine: string)" in expected + assert len(prompts) == 2 + assert all(f"\n{expected}\n" in prompt for prompt in prompts) + assert all("- get_weather(" not in prompt for prompt in prompts) + + class TestCredentials: """The user holds the key a tool declares, and only a call carrying it reaches the simulated service.""" From 2d1b432d9633d031ed7328c3b139a4ed06eb7798 Mon Sep 17 00:00:00 2001 From: Yev Meyer Date: Tue, 17 Nov 2026 14:28:35 -0500 Subject: [PATCH 2/6] fix(probes): read tool_calling's place-bound times in local time The simulated service's clock is UTC. In the simulator's prompt and its judge's, opening hours, market sessions and other times tied to a place follow the local time there, converted from that UTC time, so whether a shop is open or a market is in session agrees with the place's local time. Signed-off-by: Yev Meyer --- .../engine/probes/tool_calling/README.md | 3 +- .../assets/tool_calling/README.md | 7 ++-- .../assets/tool_calling/prompts.yaml | 4 +++ .../engine/probes/tool_calling/prompts.py | 4 +++ tests/probes/tool_calling/test_probe.py | 36 +++++++++++++++++++ 5 files changed, 50 insertions(+), 4 deletions(-) diff --git a/src/usersim/engine/probes/tool_calling/README.md b/src/usersim/engine/probes/tool_calling/README.md index 17b7edfb..24272777 100644 --- a/src/usersim/engine/probes/tool_calling/README.md +++ b/src/usersim/engine/probes/tool_calling/README.md @@ -62,7 +62,8 @@ the dates in requests and in tool results agree. The `api_response_model`'s clock reads noon UTC on it at the user's first message and moves two minutes with each one after, so a live score or a job's progress can move between turns; an event after the clock has no result yet, while what is planned for -later, such as a schedule or a forecast, already exists. Each row +later, such as a schedule or a forecast, already exists. Opening hours, market +sessions and other times tied to a place follow the local time there. Each row records the date as `today` in `conversation_metadata`. The first user message the assistant sees opens with a line its app would attach, the date and the persona's location, such as `[2026-11-06 · Austin, Texas, USA]`; the simulated user is told the diff --git a/src/usersim/engine/probes/tool_calling/assets/tool_calling/README.md b/src/usersim/engine/probes/tool_calling/assets/tool_calling/README.md index 7dfa47ff..2e432967 100644 --- a/src/usersim/engine/probes/tool_calling/assets/tool_calling/README.md +++ b/src/usersim/engine/probes/tool_calling/assets/tool_calling/README.md @@ -124,9 +124,10 @@ toolsets_seed.parquet ── sample a toolset ──▶ assistant_model (model u each was made, which it keeps consistent with, and its clock, noon UTC on the conversation's date at the user's first message and two minutes later with each one after, up to 12:59, but none of - the conversation's messages. An event after the clock has no result yet, - while what is planned for later, such as a schedule, a listing or a - forecast, already exists; an identical call returns the same data, except + the conversation's messages. Opening hours, market sessions and other times + tied to a place follow the local time there. An event after the clock has no + result yet, while what is planned for later, such as a schedule, a listing + or a forecast, already exists; an identical call returns the same data, except that what moves with time, such as a live score, a job's progress, stock or a price, may have moved since it was made. A tool with a parameter naming one of the user's own things (a tracking, order, booking or reservation number, diff --git a/src/usersim/engine/probes/tool_calling/assets/tool_calling/prompts.yaml b/src/usersim/engine/probes/tool_calling/assets/tool_calling/prompts.yaml index 7b032599..b53473cf 100644 --- a/src/usersim/engine/probes/tool_calling/assets/tool_calling/prompts.yaml +++ b/src/usersim/engine/probes/tool_calling/assets/tool_calling/prompts.yaml @@ -86,6 +86,8 @@ tool_simulator_prompt: |- It is {now}. An event later than that has not happened, so it has no result, score or reading yet; what is planned for later, such as a schedule, showtime, listing, forecast, booking or price, already exists. + Opening hours, market sessions and other times tied to a place follow the local time there, converted + from that UTC time. Tool specification: {tool_spec} @@ -134,6 +136,8 @@ tool_simulator_judge_prompt: |- You are checking a simulated API response before an AI assistant sees it. It is {now}. + Opening hours, market sessions and other times tied to a place follow the local time there, converted + from that UTC time. Tool specification: {tool_spec} diff --git a/src/usersim/engine/probes/tool_calling/prompts.py b/src/usersim/engine/probes/tool_calling/prompts.py index 46fb2e35..3c9cfd85 100644 --- a/src/usersim/engine/probes/tool_calling/prompts.py +++ b/src/usersim/engine/probes/tool_calling/prompts.py @@ -110,6 +110,8 @@ It is {now}. An event later than that has not happened, so it has no result, score or reading yet; what is planned for later, such as a schedule, showtime, listing, forecast, booking or price, already exists. +Opening hours, market sessions and other times tied to a place follow the local time there, converted +from that UTC time. Tool specification: {tool_spec} @@ -177,6 +179,8 @@ _DEFAULT_TOOL_SIMULATOR_JUDGE = """You are checking a simulated API response before an AI assistant sees it. It is {now}. +Opening hours, market sessions and other times tied to a place follow the local time there, converted +from that UTC time. Tool specification: {tool_spec} diff --git a/tests/probes/tool_calling/test_probe.py b/tests/probes/tool_calling/test_probe.py index 38a654e9..88ed862f 100644 --- a/tests/probes/tool_calling/test_probe.py +++ b/tests/probes/tool_calling/test_probe.py @@ -654,6 +654,13 @@ async def fake_call_llm(models, alias, messages, **kwargs): assert "It is Friday, 2026-11-06, 12:02 UTC." in prompts[0] + async def test_the_simulator_and_its_judge_read_times_tied_to_a_place_in_its_local_time(self): + _result, api_prompts, judge_prompts = await _simulate_with_judge() + local = "times tied to a place follow the local time there, converted from that UTC time." + + assert local in " ".join(api_prompts[0].split()) + assert local in " ".join(judge_prompts[0].split()) + async def test_the_user_and_the_tool_simulator_share_the_runs_date(self, sample_tools): result, _assistant, user_inputs, _judge, api_inputs = await _run_concrete_tool_probe(sample_tools) @@ -750,6 +757,35 @@ async def test_the_simulator_reads_no_records_for_a_lookup(self, sample_tools): assert "A User" not in prompt +async def _simulate_with_judge(spec: dict | None = None, arguments: str = '{"location": "Tokyo"}'): + """One judged simulated response; returns it with the prompts the simulator and its judge read.""" + api_prompts: list[str] = [] + judge_prompts: list[str] = [] + + async def fake_call_llm(models, alias, messages, **kwargs): + api_prompts.append(messages[0]["content"]) + return {"content": '{"temp": 22}'} + + async def fake_judge(models, alias, prompt): + judge_prompts.append(prompt) + return "Fine.", "success", True, True + + tool_call = {"function": {"name": "get_weather", "arguments": arguments}} + with ( + patch("usersim.engine.probes.tool_calling.probe.acall_llm", side_effect=fake_call_llm), + patch("usersim.engine.probes.tool_calling.probe.run_inline_judge_ex", side_effect=fake_judge), + ): + result = await _simulate_tool_response( + {}, + spec or {"name": "get_weather", "parameters": {"type": "object"}}, + tool_call, + [], + now="Friday, 2026-11-06, 12:00 UTC", + judge=True, + ) + return result, api_prompts, judge_prompts + + def _tool(tool_name: str, **parameter_types: str) -> dict: properties = {parameter: {"type": kind} for parameter, kind in parameter_types.items()} return {"tool": {"type": "function", "function": {"name": tool_name, "parameters": {"properties": properties}}}} From d49ba416e584f0254ba4bf8641a0d4f58fa202da Mon Sep 17 00:00:00 2001 From: Yev Meyer Date: Tue, 17 Nov 2026 14:28:35 -0500 Subject: [PATCH 3/6] fix(probes): let tool_calling's random and generating tools return new items An identical call returns the same data, which also had a tool that returns random or newly generated items, such as a random image or a generated password, repeat its earlier result. Such a tool now returns new items each time, in the simulator's rules and in the judge's consistency criterion. Signed-off-by: Yev Meyer --- .../probes/tool_calling/assets/tool_calling/README.md | 4 +++- .../probes/tool_calling/assets/tool_calling/prompts.yaml | 6 ++++-- src/usersim/engine/probes/tool_calling/prompts.py | 6 ++++-- tests/probes/tool_calling/test_probe.py | 7 +++++++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/usersim/engine/probes/tool_calling/assets/tool_calling/README.md b/src/usersim/engine/probes/tool_calling/assets/tool_calling/README.md index 2e432967..b51b868a 100644 --- a/src/usersim/engine/probes/tool_calling/assets/tool_calling/README.md +++ b/src/usersim/engine/probes/tool_calling/assets/tool_calling/README.md @@ -129,7 +129,9 @@ toolsets_seed.parquet ── sample a toolset ──▶ assistant_model (model u result yet, while what is planned for later, such as a schedule, a listing or a forecast, already exists; an identical call returns the same data, except that what moves with time, such as a live score, a job's progress, stock or - a price, may have moved since it was made. A tool with a parameter naming one + a price, may have moved since it was made, and a tool that returns random or + newly generated items by design, such as a random image or a generated + password, returns new ones each time. A tool with a parameter naming one of the user's own things (a tracking, order, booking or reservation number, an invoice or a receipt) also gets the service's records on the person, their name and where they live, which that thing carries, while an argument diff --git a/src/usersim/engine/probes/tool_calling/assets/tool_calling/prompts.yaml b/src/usersim/engine/probes/tool_calling/assets/tool_calling/prompts.yaml index b53473cf..c39f920f 100644 --- a/src/usersim/engine/probes/tool_calling/assets/tool_calling/prompts.yaml +++ b/src/usersim/engine/probes/tool_calling/assets/tool_calling/prompts.yaml @@ -109,7 +109,8 @@ tool_simulator_prompt: |- An identical call returns the same data unless a call in between changed it, and anything an earlier response returned keeps its values; only what moves with time, such as a live score, a job's - progress, stock or a price, may have moved since then. + progress, stock or a price, may have moved since then. A tool that returns random or newly generated + items by design, such as a random image or a generated password, returns new ones each time. Write it as the real service would: - Links use the service's own domain or another realistic one, never example.com, another @@ -165,7 +166,8 @@ tool_simulator_judge_prompt: |- - The response is what this tool returns for these arguments: it concerns the entity, place, dates, units and ranges the arguments ask for, and its fields fit the tool's description. - It is consistent with itself, with the earlier calls' responses and with the current time: an identical call returns the same data unless a call in between changed it, or time has passed and the data is the - kind that moves with it, such as a live score, a job's progress, stock or a price. Anything planned for + kind that moves with it, such as a live score, a job's progress, stock or a price. A tool that returns + random or newly generated items by design returns new ones each time. Anything planned for after the current time, such as a schedule, a listing, a forecast or a booking, is fine. - Every value the tool computes (a total, a conversion, a date difference, a formula) is correct for the arguments. - An ID or other value it returns that the service's other endpoints take has the type and form they take for it. diff --git a/src/usersim/engine/probes/tool_calling/prompts.py b/src/usersim/engine/probes/tool_calling/prompts.py index 3c9cfd85..4fe6f7cb 100644 --- a/src/usersim/engine/probes/tool_calling/prompts.py +++ b/src/usersim/engine/probes/tool_calling/prompts.py @@ -133,7 +133,8 @@ An identical call returns the same data unless a call in between changed it, and anything an earlier response returned keeps its values; only what moves with time, such as a live score, a job's -progress, stock or a price, may have moved since then. +progress, stock or a price, may have moved since then. A tool that returns random or newly generated +items by design, such as a random image or a generated password, returns new ones each time. Write it as the real service would: - Links use the service's own domain or another realistic one, never example.com, another @@ -208,7 +209,8 @@ - The response is what this tool returns for these arguments: it concerns the entity, place, dates, units and ranges the arguments ask for, and its fields fit the tool's description. - It is consistent with itself, with the earlier calls' responses and with the current time: an identical call returns the same data unless a call in between changed it, or time has passed and the data is the - kind that moves with it, such as a live score, a job's progress, stock or a price. Anything planned for + kind that moves with it, such as a live score, a job's progress, stock or a price. A tool that returns + random or newly generated items by design returns new ones each time. Anything planned for after the current time, such as a schedule, a listing, a forecast or a booking, is fine. - Every value the tool computes (a total, a conversion, a date difference, a formula) is correct for the arguments. - An ID or other value it returns that the service's other endpoints take has the type and form they take for it. diff --git a/tests/probes/tool_calling/test_probe.py b/tests/probes/tool_calling/test_probe.py index 88ed862f..2a0658e4 100644 --- a/tests/probes/tool_calling/test_probe.py +++ b/tests/probes/tool_calling/test_probe.py @@ -791,6 +791,13 @@ def _tool(tool_name: str, **parameter_types: str) -> dict: return {"tool": {"type": "function", "function": {"name": tool_name, "parameters": {"properties": properties}}}} +async def test_a_tool_that_returns_random_or_generated_items_returns_new_ones_each_time(): + _result, api_prompts, judge_prompts = await _simulate_with_judge() + + assert "A tool that returns random or newly generated items by design" in " ".join(api_prompts[0].split()) + assert "random or newly generated items by design returns new ones each time" in " ".join(judge_prompts[0].split()) + + class TestOtherEndpoints: """The simulated service and its judge see the service's other endpoints, so an ID a response returns has the type the endpoints that take it accept.""" From bedbbac4e058f076d823195b338eceded91d5272 Mon Sep 17 00:00:00 2001 From: Yev Meyer Date: Tue, 17 Nov 2026 14:28:36 -0500 Subject: [PATCH 4/6] fix(probes): keep tool_calling's response judge off fields describing the response The response judge fails a value the tool computes when it is wrong. A field that only describes the response itself, such as a count of the items it lists or an offset derived from its other fields, is not grounds for failure, so the judge's attempts go to the values a call is about. Signed-off-by: Yev Meyer --- .../probes/tool_calling/assets/tool_calling/README.md | 10 ++++++---- .../tool_calling/assets/tool_calling/prompts.yaml | 2 ++ src/usersim/engine/probes/tool_calling/prompts.py | 2 ++ tests/probes/tool_calling/test_probe.py | 11 +++++++++++ 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/usersim/engine/probes/tool_calling/assets/tool_calling/README.md b/src/usersim/engine/probes/tool_calling/assets/tool_calling/README.md index b51b868a..b2da665e 100644 --- a/src/usersim/engine/probes/tool_calling/assets/tool_calling/README.md +++ b/src/usersim/engine/probes/tool_calling/assets/tool_calling/README.md @@ -153,10 +153,12 @@ toolsets_seed.parquet ── sample a toolset ──▶ assistant_model (model u assistant sees it: that it answers the call, agrees with the earlier calls' responses and the clock, gives no result for an event later than the clock while letting a schedule or forecast for later stand, - computes values correctly, returns IDs and values of the type and form the - service's other endpoints take, and holds no placeholder such as an - `example.com` link. It checks real-world facts only where the - arguments or the tool's description fix them. A rejected response is + computes values correctly (a field that only describes the response, such + as a count of the items it lists, is not grounds for rejecting it), returns + IDs and values of the type and form the service's other endpoints take, and + holds no placeholder such as an `example.com` link. It checks real-world + facts only where the arguments or the tool's description fix them. A + rejected response is rewritten with the judge's reason, within `max_response_attempts` (the probe's `judge_responses` setting turns this off). The judge is the models file's `api_response_judge_model` (the probe's `response_judge_model_alias` setting), so these checks can run on diff --git a/src/usersim/engine/probes/tool_calling/assets/tool_calling/prompts.yaml b/src/usersim/engine/probes/tool_calling/assets/tool_calling/prompts.yaml index c39f920f..f86be5e6 100644 --- a/src/usersim/engine/probes/tool_calling/assets/tool_calling/prompts.yaml +++ b/src/usersim/engine/probes/tool_calling/assets/tool_calling/prompts.yaml @@ -170,6 +170,8 @@ tool_simulator_judge_prompt: |- random or newly generated items by design returns new ones each time. Anything planned for after the current time, such as a schedule, a listing, a forecast or a booking, is fine. - Every value the tool computes (a total, a conversion, a date difference, a formula) is correct for the arguments. + - A field that only describes the response itself, such as a count of the items it lists or an offset + derived from its other fields, is not grounds for failure. - An ID or other value it returns that the service's other endpoints take has the type and form they take for it. - It reads like real API output: no placeholder values (an example.com or other example.* host is one) and no commentary around the JSON. diff --git a/src/usersim/engine/probes/tool_calling/prompts.py b/src/usersim/engine/probes/tool_calling/prompts.py index 4fe6f7cb..1f4f4d48 100644 --- a/src/usersim/engine/probes/tool_calling/prompts.py +++ b/src/usersim/engine/probes/tool_calling/prompts.py @@ -213,6 +213,8 @@ random or newly generated items by design returns new ones each time. Anything planned for after the current time, such as a schedule, a listing, a forecast or a booking, is fine. - Every value the tool computes (a total, a conversion, a date difference, a formula) is correct for the arguments. +- A field that only describes the response itself, such as a count of the items it lists or an offset + derived from its other fields, is not grounds for failure. - An ID or other value it returns that the service's other endpoints take has the type and form they take for it. - It reads like real API output: no placeholder values (an example.com or other example.* host is one) and no commentary around the JSON. diff --git a/tests/probes/tool_calling/test_probe.py b/tests/probes/tool_calling/test_probe.py index 2a0658e4..0e8023ad 100644 --- a/tests/probes/tool_calling/test_probe.py +++ b/tests/probes/tool_calling/test_probe.py @@ -798,6 +798,17 @@ async def test_a_tool_that_returns_random_or_generated_items_returns_new_ones_ea assert "random or newly generated items by design returns new ones each time" in " ".join(judge_prompts[0].split()) +async def test_the_response_judge_checks_computed_values_but_not_fields_describing_the_response(): + _result, _api_prompts, judge_prompts = await _simulate_with_judge() + rubric = " ".join(judge_prompts[0].split()) + + assert "Every value the tool computes (a total, a conversion, a date difference, a formula) is correct" in rubric + assert ( + "A field that only describes the response itself, such as a count of the items it lists or an offset derived " + "from its other fields, is not grounds for failure." in rubric + ) + + class TestOtherEndpoints: """The simulated service and its judge see the service's other endpoints, so an ID a response returns has the type the endpoints that take it accept.""" From dcceea5cd38a47342e61c60865021971553d57ad Mon Sep 17 00:00:00 2001 From: Yev Meyer Date: Tue, 17 Nov 2026 14:28:37 -0500 Subject: [PATCH 5/6] fix(probes): let tool_calling's turn judge pass justified refusals and real tool gaps The per-turn assistant judge fails a reply that says it cannot do something one of the assistant's tools does. Declining for a legal, safety or privacy reason, or saying accurately that no offered tool does what is asked, is not that failure. Signed-off-by: Yev Meyer --- .../probes/tool_calling/assets/tool_calling/README.md | 4 +++- .../probes/tool_calling/assets/tool_calling/prompts.yaml | 2 +- src/usersim/engine/probes/tool_calling/prompts.py | 2 +- tests/probes/tool_calling/test_probe.py | 9 +++++++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/usersim/engine/probes/tool_calling/assets/tool_calling/README.md b/src/usersim/engine/probes/tool_calling/assets/tool_calling/README.md index b2da665e..6c8a1ce9 100644 --- a/src/usersim/engine/probes/tool_calling/assets/tool_calling/README.md +++ b/src/usersim/engine/probes/tool_calling/assets/tool_calling/README.md @@ -171,7 +171,9 @@ toolsets_seed.parquet ── sample a toolset ──▶ assistant_model (model u `n_assistant_ungrounded`. The judge also sees the tools the assistant was offered, and fails a reply that says it can't do what one of them does, rather than asking the user for what the call is missing, or calls its - tools' results unreliable without a reason. It judges only what + tools' results unreliable without a reason; declining for a legal, safety + or privacy reason, or saying accurately that no offered tool does what is + asked, is not that failure. It judges only what the reply in front of it says: an earlier reply's error counts against that reply alone, unless this one repeats it. With `--max-assistant-attempts` above 1, the rejected turn is undone, tool calls included, and regenerated. diff --git a/src/usersim/engine/probes/tool_calling/assets/tool_calling/prompts.yaml b/src/usersim/engine/probes/tool_calling/assets/tool_calling/prompts.yaml index f86be5e6..bb4aac02 100644 --- a/src/usersim/engine/probes/tool_calling/assets/tool_calling/prompts.yaml +++ b/src/usersim/engine/probes/tool_calling/assets/tool_calling/prompts.yaml @@ -296,7 +296,7 @@ assistant_judge_prompt: |- - The response does not address the user's question or request. - The response is unintelligible, empty, or a non-sequitur that ignores the conversation context. - The response states a figure, name, date or other result that no tool response in the conversation contains, contradicts a tool response, or says it performed an action, such as a booking, a change or a lookup, that no tool call in the conversation performed. - - The response says it cannot look up or do something one of the assistant's tools does, rather than asking the user for what the call is missing, or calls results its tool calls returned unreliable without a reason the conversation shows. + - The response says it cannot look up or do something one of the assistant's tools does, rather than asking the user for what the call is missing, or calls results its tool calls returned unreliable without a reason the conversation shows. Declining for a legal, safety or privacy reason, or saying accurately that no offered tool does what is asked, is not this failure. diff --git a/src/usersim/engine/probes/tool_calling/prompts.py b/src/usersim/engine/probes/tool_calling/prompts.py index 1f4f4d48..ac43f394 100644 --- a/src/usersim/engine/probes/tool_calling/prompts.py +++ b/src/usersim/engine/probes/tool_calling/prompts.py @@ -348,7 +348,7 @@ - The response does not address the user's question or request. - The response is unintelligible, empty, or a non-sequitur that ignores the conversation context. - The response states a figure, name, date or other result that no tool response in the conversation contains, contradicts a tool response, or says it performed an action, such as a booking, a change or a lookup, that no tool call in the conversation performed. -- The response says it cannot look up or do something one of the assistant's tools does, rather than asking the user for what the call is missing, or calls results its tool calls returned unreliable without a reason the conversation shows. +- The response says it cannot look up or do something one of the assistant's tools does, rather than asking the user for what the call is missing, or calls results its tool calls returned unreliable without a reason the conversation shows. Declining for a legal, safety or privacy reason, or saying accurately that no offered tool does what is asked, is not this failure. diff --git a/tests/probes/tool_calling/test_probe.py b/tests/probes/tool_calling/test_probe.py index 0e8023ad..e250e4f7 100644 --- a/tests/probes/tool_calling/test_probe.py +++ b/tests/probes/tool_calling/test_probe.py @@ -598,6 +598,15 @@ def test_the_judge_expects_a_reply_to_ask_for_what_a_call_is_missing(self, sampl assert "tools does, rather than asking the user for what the call is missing, or calls results" in prompt + def test_declining_for_a_reason_or_naming_a_real_gap_in_the_tools_is_not_that_failure(self, sample_tools): + probe, _data, _cfg = _concrete_tool_probe(sample_tools) + prompt = " ".join(probe.format_assistant_judge_prompt("R", "H").split()) + + assert ( + "the conversation shows. Declining for a legal, safety or privacy reason, or saying accurately that no " + "offered tool does what is asked, is not this failure." in prompt + ) + def test_an_earlier_replys_error_counts_against_that_reply(self, sample_tools): probe, _data, _cfg = _concrete_tool_probe(sample_tools) prompt = " ".join(probe.format_assistant_judge_prompt("R", "H").split()) From 70d53ef63fdcc27b3bec7e4d57b73d01bf8081ea Mon Sep 17 00:00:00 2001 From: Yev Meyer Date: Tue, 17 Nov 2026 14:28:38 -0500 Subject: [PATCH 6/6] fix(probes): open tool_calling conversations with requests that can be acted on now The opening request's check also fails a request that can't be acted on yet, because it waits on something that hasn't happened, and one that needs a file or photo the user can't give as a link, so the simulated user writes it again. Signed-off-by: Yev Meyer --- src/usersim/engine/probes/tool_calling/README.md | 4 +++- .../tool_calling/assets/tool_calling/prompts.yaml | 2 ++ src/usersim/engine/probes/tool_calling/prompts.py | 2 ++ tests/probes/tool_calling/test_probe.py | 13 ++++++++++++- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/usersim/engine/probes/tool_calling/README.md b/src/usersim/engine/probes/tool_calling/README.md index 24272777..23acce81 100644 --- a/src/usersim/engine/probes/tool_calling/README.md +++ b/src/usersim/engine/probes/tool_calling/README.md @@ -16,7 +16,9 @@ the other probes. run. The toolset is the row's theme. - The simulated user writes requests the tools can serve, in the row's language, and holds any credential a tool declares, API key or password. The - check on the opening request fails one that no offered tool can do, so the + check on the opening request fails one that no offered tool can do, one that + can't be acted on yet because it waits on something that hasn't happened, + and one that needs a file or photo the user can't give as a link, so the user writes it again. The user asks a service about the records it holds, such as bookings or balances, rather than describing them, and gives what the assistant asks for that a real user would have, such as a link or a diff --git a/src/usersim/engine/probes/tool_calling/assets/tool_calling/prompts.yaml b/src/usersim/engine/probes/tool_calling/assets/tool_calling/prompts.yaml index bb4aac02..bcd639cd 100644 --- a/src/usersim/engine/probes/tool_calling/assets/tool_calling/prompts.yaml +++ b/src/usersim/engine/probes/tool_calling/assets/tool_calling/prompts.yaml @@ -264,6 +264,8 @@ tool_relevance_failure: | - The request can be fully answered from general knowledge or opinion alone, without needing any of the available tools. - The request asks for something none of the available tools can do. + - The request can't be acted on yet, because it waits on something that hasn't + happened, or it needs a file or photo the user can't give as a link. assistant_judge_prompt: |- You are an expert evaluator. Judge the assistant's response in this conversation. diff --git a/src/usersim/engine/probes/tool_calling/prompts.py b/src/usersim/engine/probes/tool_calling/prompts.py index ac43f394..21cb64fe 100644 --- a/src/usersim/engine/probes/tool_calling/prompts.py +++ b/src/usersim/engine/probes/tool_calling/prompts.py @@ -372,6 +372,8 @@ "- The request can be fully answered from general knowledge or opinion alone,\n" " without needing any of the available tools.\n" "- The request asks for something none of the available tools can do.\n" + "- The request can't be acted on yet, because it waits on something that hasn't\n" + " happened, or it needs a file or photo the user can't give as a link.\n" ) # ── Public templates (YAML overrides compiled-in defaults) ──────────────── diff --git a/tests/probes/tool_calling/test_probe.py b/tests/probes/tool_calling/test_probe.py index e250e4f7..fbd0819d 100644 --- a/tests/probes/tool_calling/test_probe.py +++ b/tests/probes/tool_calling/test_probe.py @@ -555,10 +555,21 @@ def test_the_opening_gate_fails_a_request_no_offered_tool_can_do(self, sample_to assert "and the available tools can do what it asks." in " ".join(rubric.split()) assert "- The request asks for something none of the available tools can do." in rubric + def test_the_opening_gate_fails_a_request_that_waits_on_something_or_needs_a_file(self, sample_tools): + probe, _data, _cfg = _concrete_tool_probe(sample_tools) + rubric = " ".join(probe.format_gate_prompt("Remind me once my interview is set.", "N/A").split()) + + assert ( + "- The request can't be acted on yet, because it waits on something that hasn't happened, or it needs a " + "file or photo the user can't give as a link." in rubric + ) + def test_a_follow_up_may_ask_for_what_no_offered_tool_does(self, sample_tools): probe, _data, _cfg = _concrete_tool_probe(sample_tools) + rubric = probe.format_gate_prompt("And a recipe?", "User: Hi") - assert "none of the available tools can do" not in probe.format_gate_prompt("And a recipe?", "User: Hi") + assert "none of the available tools can do" not in rubric + assert "can't be acted on yet" not in rubric def test_the_user_asks_about_records_a_service_holds(self, sample_tools): probe, _data, _cfg = _concrete_tool_probe(sample_tools)