@@ -52,6 +52,57 @@ def test_go_example_scenarios_with_http_stub(mode, scenario, monkeypatch, capsys
5252 assert outputs ["cleanup" ] == "completed"
5353
5454
55+ @pytest .mark .parametrize ("mode" , ["forward" , "managed" ])
56+ @pytest .mark .parametrize (
57+ "case,expected_error" ,
58+ [
59+ ("cached_skill" , None ),
60+ ("missing_first_turn_tool" , "No actual tool execution" ),
61+ ("wrong_skill_value" , "missing expected values" ),
62+ ],
63+ )
64+ def test_resource_scenarios_allow_cached_skill_but_still_verify_tools_and_values (
65+ mode , case , expected_error , monkeypatch
66+ ):
67+ config = Config (mode , "test-token" , f"https://api.test/api/v1/{ mode } " , timeout = 2 , poll_interval = 0 )
68+ run = Run (config )
69+ service = ExampleService (mode )
70+ original_send = service .send
71+ replies = []
72+
73+ def send (session_id , event ):
74+ start = len (service .events [session_id ])
75+ user_event = original_send (session_id , event )
76+ reply = service .events [session_id ][start + 1 :]
77+ second_turn = len (replies ) == 1
78+ if second_turn or case == "missing_first_turn_tool" :
79+ reply = [item for item in reply if item ["type" ] not in ("agent.tool_use" , "agent.mcp_tool_use" )]
80+ if second_turn and case == "wrong_skill_value" :
81+ for item in reply :
82+ if item ["type" ] == "agent.message" :
83+ item ["content" ] = [{"type" : "text" , "text" : "incorrect skill value" }]
84+ service .events [session_id ][start + 1 :] = reply
85+ replies .append (reply )
86+ return user_event
87+
88+ monkeypatch .setattr (service , "send" , send )
89+ cls , scenarios = (Forward , FORWARD_SCENARIOS ) if mode == "forward" else (Managed , MANAGED_SCENARIOS )
90+ with cls (** config .client_options (), http_client = httpx .Client (transport = httpx .MockTransport (service ))) as client :
91+ try :
92+ if expected_error is None :
93+ scenarios ["resources" ](client , run )
94+ assert len (replies ) == 2
95+ assert any (item ["type" ] == "agent.tool_use" for item in replies [0 ])
96+ assert not any (item ["type" ] == "agent.tool_use" for item in replies [1 ])
97+ else :
98+ with pytest .raises (AssertionError , match = expected_error ):
99+ scenarios ["resources" ](client , run )
100+ finally :
101+ run .cleanup ()
102+ assert not run .cleanups
103+ assert not service .mounts
104+
105+
55106def test_turn_assertions_require_final_assistant_output_and_successful_idle ():
56107 result = TurnResult ()
57108 for event in [
0 commit comments