@@ -146,6 +146,24 @@ def payment_scenario() -> Scenario:
146146 )
147147
148148
149+ def payment_check_scenario () -> Scenario :
150+ scenario = payment_scenario ()
151+ scenario .id = "payment_check_smoke"
152+ scenario .max_turns = 2
153+ scenario .response_tree .nodes [0 ].follow_up_nodes = ["payment_check" ]
154+ scenario .response_tree .nodes .append (
155+ ResponseNode (
156+ id = "payment_check" ,
157+ condition = "Agent checks payment before delivering paid content" ,
158+ positive_response = "Great." ,
159+ negative_response = "No." ,
160+ neutral_response = "Okay." ,
161+ points_if_positive = 1 ,
162+ )
163+ )
164+ return scenario
165+
166+
149167@pytest .mark .asyncio
150168async def test_woobench_collects_mock_backed_payment ():
151169 payment_client = FakePaymentClient ()
@@ -199,3 +217,49 @@ async def agent(_history):
199217 assert result .revenue .payment_checkout_url == "http://mock.test/checkout/charge_test?provider=oxapay"
200218 assert result .revenue .payment_transaction_hash == "woobench_payment_mock_smoke_1"
201219 assert payment_client .created_charges == [1.0 ]
220+
221+
222+ @pytest .mark .asyncio
223+ async def test_woobench_check_action_does_not_create_second_text_charge ():
224+ payment_client = FakePaymentClient ()
225+ evaluator = WooBenchEvaluator (evaluator_mode = "heuristic" , payment_client = payment_client )
226+
227+ async def agent (history ):
228+ user_text = "\n " .join (
229+ turn ["content" ] for turn in history if turn .get ("role" ) == "user"
230+ ).lower ()
231+ if "payment sent" in user_text :
232+ return {
233+ "text" : "I am checking whether the $1.00 charge went through before continuing." ,
234+ "actions" : ["BENCHMARK_ACTION" ],
235+ "params" : {
236+ "BENCHMARK_ACTION" : {
237+ "command" : "CHECK_PAYMENT" ,
238+ }
239+ },
240+ }
241+ return {
242+ "text" : "I can continue once the $1.00 crypto charge is paid." ,
243+ "actions" : ["BENCHMARK_ACTION" ],
244+ "params" : {
245+ "BENCHMARK_ACTION" : {
246+ "command" : "CREATE_APP_CHARGE" ,
247+ "amount_usd" : 1 ,
248+ "provider" : "oxapay" ,
249+ "description" : "WooBench action charge" ,
250+ }
251+ },
252+ }
253+
254+ result = await evaluator .run_scenario (payment_check_scenario (), agent )
255+
256+ assert result .revenue .payment_requested is True
257+ assert result .revenue .payment_received is True
258+ assert result .revenue .amount_earned == 1.0
259+ assert result .revenue .payment_provider == "mock-app-charge:oxapay"
260+ assert result .revenue .payment_request_id == "charge_test"
261+ assert result .revenue .payment_status == "confirmed"
262+ assert result .revenue .payment_action == "CHECK_PAYMENT"
263+ assert result .revenue .payment_action_source == "action"
264+ assert payment_client .created_charges == [1.0 ]
265+ assert payment_client .created_amounts == []
0 commit comments