@@ -36,32 +36,7 @@ def _arguments_match(observed: Any, expected: Any) -> bool:
3636 return observed == expected
3737
3838
39- def _build_alias_map (snapshot : dict | None ) -> dict [str , set [str ]]:
40- """Build a map from logical tool name → all known invocation aliases.
41-
42- Given the frozen agent config snapshot, every tool's name, external_id,
43- and invocation_names are treated as interchangeable identifiers for the
44- same underlying capability. This lets scenario controls reference a
45- logical alias (e.g. ``acme_get_order``) while the trace carries the
46- real OpenWebUI function name (e.g. ``acme_get_order``).
47- """
48- alias_map : dict [str , set [str ]] = {}
49- if not snapshot :
50- return alias_map
51- for tool in snapshot .get ("tools" , []):
52- if not isinstance (tool , dict ):
53- continue
54- ids = {
55- str (v )
56- for v in [tool .get ("name" ), tool .get ("external_id" ), * (tool .get ("invocation_names" ) or [])]
57- if v
58- }
59- for ident in ids :
60- alias_map .setdefault (ident , set ()).update (ids )
61- return alias_map
62-
63-
64- def tool_selection (trajectory : AgentTrajectory , expected : dict , snapshot : dict | None = None ) -> list [CheckResult ]:
39+ def tool_selection (trajectory : AgentTrajectory , expected : dict ) -> list [CheckResult ]:
6540 """Check tool calls against expected requirements."""
6641 calls = [s for s in trajectory .primary_steps if s .kind == "tool" ]
6742 # Runtime builtins (search_chats, get_current_timestamp, ...) are granted
@@ -72,18 +47,9 @@ def tool_selection(trajectory: AgentTrajectory, expected: dict, snapshot: dict |
7247 required = expected .get ("expected" , [])
7348 out = []
7449
75- alias_map = _build_alias_map (snapshot )
76-
77- def _resolve (name : str ) -> set [str ]:
78- """Return the set of span names that satisfy *name* (including itself)."""
79- if name in alias_map :
80- return alias_map [name ]
81- return {name }
82-
8350 for item in required :
8451 name = item .get ("name" )
85- acceptable_names = _resolve (name ) if name else set ()
86- matching = [step for step in calls if step .name in acceptable_names ]
52+ matching = [step for step in calls if step .name == name ]
8753 count = len (matching )
8854 # min_calls may be present as null — treat it as 1.
8955 lo , hi = item .get ("min_calls" ), item .get ("max_calls" )
@@ -137,12 +103,7 @@ def _resolve(name: str) -> set[str]:
137103
138104 forbidden = set (expected .get ("forbidden" , []))
139105 if forbidden :
140- # Expand forbidden names through the alias map so that forbidding a
141- # logical alias also catches all real invocation names.
142- expanded_forbidden : set [str ] = set ()
143- for fname in forbidden :
144- expanded_forbidden .update (_resolve (fname ))
145- bad = expanded_forbidden .intersection ({s .name for s in calls })
106+ bad = forbidden .intersection ({s .name for s in calls })
146107 out .append (
147108 result (
148109 "tool.forbidden" ,
0 commit comments