2424from predicate import AsyncPredicateBrowser
2525from predicate .agent_runtime import AgentRuntime
2626from predicate .agents import (
27+ CheckoutDetectionConfig ,
2728 ModalDismissalConfig ,
2829 PlannerExecutorAgent ,
2930 PlannerExecutorConfig ,
@@ -309,9 +310,55 @@ async def example_modal_dismissal() -> None:
309310 print (f" Multilingual: { len (config_multilingual .modal .dismiss_patterns )} patterns" )
310311
311312
313+ async def example_checkout_detection () -> None :
314+ """Checkout page detection configuration."""
315+ print ("\n --- Example 10: Checkout Detection ---" )
316+ print ("Auto-detect checkout pages and trigger continuation replanning" )
317+
318+ # Default: enabled with common checkout patterns
319+ config_default = PlannerExecutorConfig ()
320+ print (f" Default enabled: { config_default .checkout .enabled } " )
321+ print (f" Default URL patterns: { config_default .checkout .url_patterns [:5 ]} ..." )
322+
323+ # Disable checkout detection
324+ config_disabled = PlannerExecutorConfig (
325+ checkout = CheckoutDetectionConfig (enabled = False ),
326+ )
327+ print (f" Disabled: checkout.enabled={ config_disabled .checkout .enabled } " )
328+
329+ # Custom patterns for German e-commerce sites
330+ config_german = PlannerExecutorConfig (
331+ checkout = CheckoutDetectionConfig (
332+ url_patterns = (
333+ "/warenkorb" , # Cart
334+ "/kasse" , # Checkout
335+ "/zahlung" , # Payment
336+ "/bestellung" , # Order
337+ "/anmelden" , # Sign-in
338+ ),
339+ element_patterns = (
340+ "zur kasse" , # To checkout
341+ "warenkorb" , # Shopping cart
342+ "jetzt kaufen" , # Buy now
343+ "anmelden" , # Sign in
344+ ),
345+ ),
346+ )
347+ print (f" German URL patterns: { config_german .checkout .url_patterns [:3 ]} ..." )
348+
349+ # Disable replan trigger (just detect, don't act)
350+ config_detect_only = PlannerExecutorConfig (
351+ checkout = CheckoutDetectionConfig (
352+ enabled = True ,
353+ trigger_replan = False , # Only detect, don't trigger continuation
354+ ),
355+ )
356+ print (f" Detect-only: trigger_replan={ config_detect_only .checkout .trigger_replan } " )
357+
358+
312359async def example_full_custom () -> None :
313360 """Full custom configuration with all options."""
314- print ("\n --- Example 10 : Full Custom Config ---" )
361+ print ("\n --- Example 11 : Full Custom Config ---" )
315362
316363 config = PlannerExecutorConfig (
317364 # Snapshot escalation with scroll-after-escalation
@@ -347,6 +394,11 @@ async def example_full_custom() -> None:
347394 enabled = True ,
348395 max_attempts = 2 ,
349396 ),
397+ # Checkout detection (continue workflow on checkout pages)
398+ checkout = CheckoutDetectionConfig (
399+ enabled = True ,
400+ trigger_replan = True ,
401+ ),
350402 # Pre-step verification
351403 pre_step_verification = True ,
352404 # Planner settings
@@ -369,11 +421,12 @@ async def example_full_custom() -> None:
369421 print (f" Pre-step verification: { config .pre_step_verification } " )
370422 print (f" Recovery enabled: { config .recovery .enabled } " )
371423 print (f" Modal dismissal: { config .modal .enabled } " )
424+ print (f" Checkout detection: { config .checkout .enabled } " )
372425
373426
374427async def example_run_with_config () -> None :
375428 """Run agent with custom config."""
376- print ("\n --- Example 11 : Run Agent with Custom Config ---" )
429+ print ("\n --- Example 12 : Run Agent with Custom Config ---" )
377430
378431 openai_key = os .getenv ("OPENAI_API_KEY" )
379432 if not openai_key :
@@ -438,6 +491,7 @@ async def main() -> None:
438491 await example_pre_step_verification ()
439492 await example_recovery_navigation ()
440493 await example_modal_dismissal ()
494+ await example_checkout_detection ()
441495 await example_full_custom ()
442496 await example_run_with_config ()
443497
0 commit comments