JatinAutonomousLabs commited on
Commit
0e1cdba
·
verified ·
1 Parent(s): 06de9e0

Update graph.py

Browse files
Files changed (1) hide show
  1. graph.py +13 -2
graph.py CHANGED
@@ -893,15 +893,26 @@ def run_disclaimer_agent(state: AgentState):
893
  return {"draftResponse": final_response, "execution_path": path, "status_update": reason}
894
 
895
  def should_continue(state: AgentState):
896
- # NEW: Check for budget excess first
897
  if state.get("budget_exceeded"):
898
  return "disclaimer_agent"
 
 
 
 
 
 
 
 
899
  if state.get("approved"):
900
  return "archivist_agent"
901
- if ensure_int(state, "rework_cycles", 0) > ensure_int(state, "max_loops", 0):
 
902
  return "disclaimer_agent"
 
903
  return "pm_agent"
904
 
 
905
  def should_run_experiment(state: AgentState):
906
  pm = state.get('pmPlan', {}) or {}
907
  return "experimenter_agent" if pm.get('experiment_needed') else "synthesis_agent"
 
893
  return {"draftResponse": final_response, "execution_path": path, "status_update": reason}
894
 
895
  def should_continue(state: AgentState):
896
+ # Budget check first
897
  if state.get("budget_exceeded"):
898
  return "disclaimer_agent"
899
+ try:
900
+ rework = int(state.get("rework_cycles", 0))
901
+ max_loops_allowed = int(state.get("max_loops", 0))
902
+ except Exception:
903
+ rework = state.get("rework_cycles", 0) or 0
904
+ max_loops_allowed = state.get("max_loops", 0) or 0
905
+
906
+ # If approved -> archive
907
  if state.get("approved"):
908
  return "archivist_agent"
909
+ # If we have exceeded allowed reworks -> disclaimer
910
+ if rework > max_loops_allowed:
911
  return "disclaimer_agent"
912
+ # Default: return pm_agent so planner will create next plan
913
  return "pm_agent"
914
 
915
+
916
  def should_run_experiment(state: AgentState):
917
  pm = state.get('pmPlan', {}) or {}
918
  return "experimenter_agent" if pm.get('experiment_needed') else "synthesis_agent"