@@ -4065,38 +4065,6 @@ def _run_inline_workflow(self, initial_prompt):
40654065
40664066 return results [- 1 ].get ("output" , "" ) if results else ""
40674067
4068- def _execute_agent_with_budget_handling (self , agent , method_name , * args , ** kwargs ):
4069- """
4070- Execute an agent method with graceful BudgetExceededError handling.
4071-
4072- Args:
4073- agent: The agent instance
4074- method_name: Name of the method to call ('start' or 'chat')
4075- *args, **kwargs: Arguments to pass to the method
4076-
4077- Returns:
4078- The result of the agent method call
4079-
4080- Raises:
4081- SystemExit: On BudgetExceededError with clean error message
4082- Exception: Re-raises any other exceptions
4083- """
4084- try :
4085- method = getattr (agent , method_name )
4086- return method (* args , ** kwargs )
4087- except Exception as e :
4088- # Handle BudgetExceededError gracefully
4089- from praisonaiagents .errors import BudgetExceededError
4090-
4091- if isinstance (e , BudgetExceededError ):
4092- from rich import print as rich_print
4093- # Single-line error message with actionable guidance
4094- rich_print (f"[red]Budget limit exceeded: { e !s} - Set max_budget parameter (e.g., Agent(max_budget=1.00))[/red]" )
4095- sys .exit (1 )
4096- else :
4097- # Re-raise other exceptions
4098- raise
4099-
41004068 def _extract_cli_config_for_yaml (self ):
41014069 """
41024070 Extract CLI configuration that should be passed to YAML processing.
@@ -4643,26 +4611,26 @@ def level_based_approve(function_name, arguments, risk_level):
46434611 from rich .panel import Panel
46444612
46454613 with Live (Panel (Spinner ("dots" , text = "Generating..." ), border_style = "cyan" ), refresh_per_second = 10 , transient = True ):
4646- result = self . _execute_agent_with_budget_handling ( auto_rag , ' chat' , prompt )
4614+ result = auto_rag . chat ( prompt )
46474615 else :
4648- result = self . _execute_agent_with_budget_handling ( auto_rag , ' chat' , prompt )
4616+ result = auto_rag . chat ( prompt )
46494617 else :
46504618 # Resolve display mode from CLI flags
46514619 display_mode = self ._resolve_display_mode ()
46524620
46534621 if display_mode == 'silent' :
46544622 # -qq: No output at all, exit code only
46554623 if hasattr (agent , 'start' ):
4656- result = self . _execute_agent_with_budget_handling ( agent , ' start' , prompt )
4624+ result = agent . start ( prompt )
46574625 else :
4658- result = self . _execute_agent_with_budget_handling ( agent , ' chat' , prompt )
4626+ result = agent . chat ( prompt )
46594627
46604628 elif display_mode == 'quiet' :
46614629 # -q: Result only, no spinners or status
46624630 if hasattr (agent , 'start' ):
4663- result = self . _execute_agent_with_budget_handling ( agent , ' start' , prompt )
4631+ result = agent . start ( prompt )
46644632 else :
4665- result = self . _execute_agent_with_budget_handling ( agent , ' chat' , prompt )
4633+ result = agent . chat ( prompt )
46664634 if result is not None :
46674635 output = getattr (result , 'output' , None ) or (str (result ) if result else None )
46684636 if output :
@@ -4674,31 +4642,31 @@ def level_based_approve(function_name, arguments, risk_level):
46744642 from praisonaiagents .output .status import enable_status_output , disable_status_output
46754643 enable_status_output (show_timestamps = True , show_metrics = True )
46764644 if hasattr (agent , 'start' ):
4677- result = self . _execute_agent_with_budget_handling ( agent , ' start' , prompt )
4645+ result = agent . start ( prompt )
46784646 else :
4679- result = self . _execute_agent_with_budget_handling ( agent , ' chat' , prompt )
4647+ result = agent . chat ( prompt )
46804648 disable_status_output ()
46814649 except ImportError :
46824650 if hasattr (agent , 'start' ):
4683- result = self . _execute_agent_with_budget_handling ( agent , ' start' , prompt )
4651+ result = agent . start ( prompt )
46844652 else :
4685- result = self . _execute_agent_with_budget_handling ( agent , ' chat' , prompt )
4653+ result = agent . chat ( prompt )
46864654
46874655 elif display_mode == 'debug' :
46884656 # -vv: SDK TraceOutput with markdown rendering
46894657 try :
46904658 from praisonaiagents .output .trace import enable_trace_output , disable_trace_output
46914659 enable_trace_output (use_markdown = True )
46924660 if hasattr (agent , 'start' ):
4693- result = self . _execute_agent_with_budget_handling ( agent , ' start' , prompt )
4661+ result = agent . start ( prompt )
46944662 else :
4695- result = self . _execute_agent_with_budget_handling ( agent , ' chat' , prompt )
4663+ result = agent . chat ( prompt )
46964664 disable_trace_output ()
46974665 except ImportError :
46984666 if hasattr (agent , 'start' ):
4699- result = self . _execute_agent_with_budget_handling ( agent , ' start' , prompt )
4667+ result = agent . start ( prompt )
47004668 else :
4701- result = self . _execute_agent_with_budget_handling ( agent , ' chat' , prompt )
4669+ result = agent . chat ( prompt )
47024670
47034671 elif display_mode == 'jsonl' :
47044672 # --output jsonl: JSONL structured output for CI/CD
@@ -4720,9 +4688,9 @@ def level_based_approve(function_name, arguments, risk_level):
47204688
47214689 start_time = time .time ()
47224690 if hasattr (agent , 'start' ):
4723- result = self . _execute_agent_with_budget_handling ( agent , ' start' , prompt )
4691+ result = agent . start ( prompt )
47244692 else :
4725- result = self . _execute_agent_with_budget_handling ( agent , ' chat' , prompt )
4693+ result = agent . chat ( prompt )
47264694
47274695 # Emit final result
47284696 reason = getattr (result , 'completion_reason' , None ) if hasattr (result , 'completion_reason' ) else 'complete'
@@ -4741,9 +4709,9 @@ def level_based_approve(function_name, arguments, risk_level):
47414709 import json as json_mod
47424710 start_time = time .time ()
47434711 if hasattr (agent , 'start' ):
4744- result = self . _execute_agent_with_budget_handling ( agent , ' start' , prompt )
4712+ result = agent . start ( prompt )
47454713 else :
4746- result = self . _execute_agent_with_budget_handling ( agent , ' chat' , prompt )
4714+ result = agent . chat ( prompt )
47474715
47484716 output = result .output if hasattr (result , 'output' ) else str (result )
47494717 envelope = {
@@ -4764,15 +4732,15 @@ def level_based_approve(function_name, arguments, risk_level):
47644732 flow = track_workflow ()
47654733 flow .start ()
47664734 if hasattr (agent , 'start' ):
4767- result = self . _execute_agent_with_budget_handling ( agent , ' start' , prompt )
4735+ result = agent . start ( prompt )
47684736 else :
4769- result = self . _execute_agent_with_budget_handling ( agent , ' chat' , prompt )
4737+ result = agent . chat ( prompt )
47704738 flow .stop ()
47714739 except ImportError :
47724740 if hasattr (agent , 'start' ):
4773- result = self . _execute_agent_with_budget_handling ( agent , ' start' , prompt )
4741+ result = agent . start ( prompt )
47744742 else :
4775- result = self . _execute_agent_with_budget_handling ( agent , ' chat' , prompt )
4743+ result = agent . chat ( prompt )
47764744
47774745 elif display_mode == 'editor' :
47784746 # --output editor: User-friendly step-by-step format
@@ -4782,9 +4750,9 @@ def level_based_approve(function_name, arguments, risk_level):
47824750
47834751 # Run agent
47844752 if hasattr (agent , 'start' ):
4785- result = self . _execute_agent_with_budget_handling ( agent , ' start' , prompt )
4753+ result = agent . start ( prompt )
47864754 else :
4787- result = self . _execute_agent_with_budget_handling ( agent , ' chat' , prompt )
4755+ result = agent . chat ( prompt )
47884756
47894757 # SDK callbacks (interaction, llm_content) handle display —
47904758 # no explicit editor.output() needed here.
@@ -4806,15 +4774,15 @@ def level_based_approve(function_name, arguments, risk_level):
48064774 from praisonaiagents .output .status import enable_status_output , disable_status_output
48074775 enable_status_output (show_timestamps = False , show_metrics = False )
48084776 if hasattr (agent , 'start' ):
4809- result = self . _execute_agent_with_budget_handling ( agent , ' start' , prompt )
4777+ result = agent . start ( prompt )
48104778 else :
4811- result = self . _execute_agent_with_budget_handling ( agent , ' chat' , prompt )
4779+ result = agent . chat ( prompt )
48124780 disable_status_output ()
48134781 except ImportError :
48144782 if hasattr (agent , 'start' ):
4815- result = self . _execute_agent_with_budget_handling ( agent , ' start' , prompt )
4783+ result = agent . start ( prompt )
48164784 else :
4817- result = self . _execute_agent_with_budget_handling ( agent , ' chat' , prompt )
4785+ result = agent . chat ( prompt )
48184786
48194787 # ===== POST-PROCESSING WITH NEW FEATURES =====
48204788
@@ -4892,7 +4860,7 @@ def level_based_approve(function_name, arguments, risk_level):
48924860Now, { final_instruction .lower ()} :"""
48934861
48944862 final_agent = PraisonAgent (** final_agent_config )
4895- result = self . _execute_agent_with_budget_handling ( final_agent , ' start' , final_prompt )
4863+ result = final_agent . start ( final_prompt )
48964864 print (f"\n [bold green]✅ Final agent processing complete[/bold green]\n " )
48974865
48984866 # Save output if --save is enabled
0 commit comments