66- Snapshot escalation (enable/disable, custom step sizes)
77- Retry configuration (timeouts, max attempts)
88- Vision fallback settings
9+ - Pre-step verification (skip if predicates pass)
10+ - Recovery navigation (track last good URL)
911
1012Usage:
1113 export OPENAI_API_KEY="sk-..."
2224from predicate .agents import (
2325 PlannerExecutorAgent ,
2426 PlannerExecutorConfig ,
27+ RecoveryNavigationConfig ,
2528 RetryConfig ,
2629 SnapshotEscalationConfig ,
2730)
@@ -124,9 +127,45 @@ async def example_vision_fallback() -> None:
124127 print (f" vision.max_vision_calls: { config .vision .max_vision_calls } " )
125128
126129
130+ async def example_pre_step_verification () -> None :
131+ """Pre-step verification configuration."""
132+ print ("\n --- Example 7: Pre-step Verification ---" )
133+
134+ # Default: enabled (steps are skipped if predicates already pass)
135+ config_enabled = PlannerExecutorConfig (
136+ pre_step_verification = True , # Default
137+ )
138+ print (f" pre_step_verification (default): { config_enabled .pre_step_verification } " )
139+
140+ # Disabled: always execute steps even if predicates pass
141+ config_disabled = PlannerExecutorConfig (
142+ pre_step_verification = False ,
143+ )
144+ print (f" pre_step_verification (disabled): { config_disabled .pre_step_verification } " )
145+ print (" When disabled, all steps are executed even if already satisfied" )
146+
147+
148+ async def example_recovery_navigation () -> None :
149+ """Recovery navigation configuration."""
150+ print ("\n --- Example 8: Recovery Navigation ---" )
151+
152+ config = PlannerExecutorConfig (
153+ recovery = RecoveryNavigationConfig (
154+ enabled = True ,
155+ max_recovery_attempts = 3 ,
156+ track_successful_urls = True ,
157+ ),
158+ )
159+
160+ print (f" recovery.enabled: { config .recovery .enabled } " )
161+ print (f" recovery.max_recovery_attempts: { config .recovery .max_recovery_attempts } " )
162+ print (f" recovery.track_successful_urls: { config .recovery .track_successful_urls } " )
163+ print (" Tracks last_known_good_url for recovery when agent gets off-track" )
164+
165+
127166async def example_full_custom () -> None :
128167 """Full custom configuration with all options."""
129- print ("\n --- Example 7 : Full Custom Config ---" )
168+ print ("\n --- Example 9 : Full Custom Config ---" )
130169
131170 config = PlannerExecutorConfig (
132171 # Snapshot escalation
@@ -148,6 +187,13 @@ async def example_full_custom() -> None:
148187 enabled = True ,
149188 max_vision_calls = 3 ,
150189 ),
190+ # Recovery navigation
191+ recovery = RecoveryNavigationConfig (
192+ enabled = True ,
193+ max_recovery_attempts = 2 ,
194+ ),
195+ # Pre-step verification
196+ pre_step_verification = True ,
151197 # Planner settings
152198 planner_max_tokens = 3000 ,
153199 planner_temperature = 0.0 ,
@@ -164,11 +210,13 @@ async def example_full_custom() -> None:
164210 print (f" Escalation: { config .snapshot .limit_base } -> ... -> { config .snapshot .limit_max } " )
165211 print (f" Max replans: { config .retry .max_replans } " )
166212 print (f" Vision enabled: { config .vision .enabled } " )
213+ print (f" Pre-step verification: { config .pre_step_verification } " )
214+ print (f" Recovery enabled: { config .recovery .enabled } " )
167215
168216
169217async def example_run_with_config () -> None :
170218 """Run agent with custom config."""
171- print ("\n --- Example 8 : Run Agent with Custom Config ---" )
219+ print ("\n --- Example 10 : Run Agent with Custom Config ---" )
172220
173221 openai_key = os .getenv ("OPENAI_API_KEY" )
174222 if not openai_key :
@@ -229,6 +277,8 @@ async def main() -> None:
229277 await example_custom_limits ()
230278 await example_retry_config ()
231279 await example_vision_fallback ()
280+ await example_pre_step_verification ()
281+ await example_recovery_navigation ()
232282 await example_full_custom ()
233283 await example_run_with_config ()
234284
0 commit comments