Spaces:
Paused
Paused
Update graph_upgraded.py
Browse files- graph_upgraded.py +21 -32
graph_upgraded.py
CHANGED
|
@@ -514,22 +514,36 @@ def apply_upgrades():
|
|
| 514 |
try:
|
| 515 |
from langgraph.graph import StateGraph, END
|
| 516 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 517 |
# Create BRAND NEW graph
|
| 518 |
new_workflow = StateGraph(AgentState)
|
| 519 |
|
| 520 |
-
# Add all nodes (
|
| 521 |
new_workflow.add_node("memory_retriever", run_memory_retrieval)
|
| 522 |
new_workflow.add_node("intent_agent", run_intent_agent)
|
| 523 |
new_workflow.add_node("pm_agent", run_pm_agent)
|
| 524 |
-
new_workflow.add_node("pragmatist_agent", run_pragmatist_agent)
|
| 525 |
-
new_workflow.add_node("governance_agent", run_governance_agent)
|
| 526 |
new_workflow.add_node("experimenter_agent", run_experimenter_agent)
|
| 527 |
-
new_workflow.add_node("compliance_agent", run_compliance_agent)
|
| 528 |
new_workflow.add_node("synthesis_agent", run_synthesis_agent)
|
| 529 |
new_workflow.add_node("qa_agent", run_qa_agent)
|
| 530 |
-
new_workflow.add_node("observer_agent", run_observer_agent)
|
| 531 |
new_workflow.add_node("archivist_agent", run_archivist_agent)
|
| 532 |
-
new_workflow.add_node("knowledge_curator_agent", run_knowledge_curator_agent)
|
| 533 |
new_workflow.add_node("disclaimer_agent", run_disclaimer_agent)
|
| 534 |
|
| 535 |
log.info("✅ All nodes added to new graph")
|
|
@@ -576,32 +590,7 @@ def apply_upgrades():
|
|
| 576 |
new_workflow.add_edge("compliance_agent", "synthesis_agent")
|
| 577 |
new_workflow.add_edge("synthesis_agent", "qa_agent")
|
| 578 |
|
| 579 |
-
# QA conditional routing (
|
| 580 |
-
def should_continue(state: AgentState):
|
| 581 |
-
"""Decide next step after QA"""
|
| 582 |
-
# Budget check first
|
| 583 |
-
if state.get("budget_exceeded"):
|
| 584 |
-
return "disclaimer_agent"
|
| 585 |
-
|
| 586 |
-
# Parse rework cycles
|
| 587 |
-
try:
|
| 588 |
-
rework = int(state.get("rework_cycles", 0))
|
| 589 |
-
max_loops = int(state.get("max_loops", 0))
|
| 590 |
-
except Exception:
|
| 591 |
-
rework = state.get("rework_cycles", 0) or 0
|
| 592 |
-
max_loops = state.get("max_loops", 0) or 0
|
| 593 |
-
|
| 594 |
-
# If approved → success path
|
| 595 |
-
if state.get("approved"):
|
| 596 |
-
return "observer_agent"
|
| 597 |
-
|
| 598 |
-
# If exceeded rework limit → disclaimer
|
| 599 |
-
if rework > max_loops:
|
| 600 |
-
return "disclaimer_agent"
|
| 601 |
-
|
| 602 |
-
# Otherwise → loop back to PM for revision
|
| 603 |
-
return "pm_agent"
|
| 604 |
-
|
| 605 |
new_workflow.add_conditional_edges(
|
| 606 |
"qa_agent",
|
| 607 |
should_continue,
|
|
|
|
| 514 |
try:
|
| 515 |
from langgraph.graph import StateGraph, END
|
| 516 |
|
| 517 |
+
# Import the missing agent functions from base graph
|
| 518 |
+
from graph import (
|
| 519 |
+
run_memory_retrieval,
|
| 520 |
+
run_intent_agent,
|
| 521 |
+
run_pm_agent,
|
| 522 |
+
run_experimenter_agent,
|
| 523 |
+
run_synthesis_agent,
|
| 524 |
+
run_qa_agent,
|
| 525 |
+
run_archivist_agent,
|
| 526 |
+
run_disclaimer_agent,
|
| 527 |
+
should_continue,
|
| 528 |
+
should_run_experiment
|
| 529 |
+
)
|
| 530 |
+
|
| 531 |
# Create BRAND NEW graph
|
| 532 |
new_workflow = StateGraph(AgentState)
|
| 533 |
|
| 534 |
+
# Add all nodes (using imported functions and local upgraded ones)
|
| 535 |
new_workflow.add_node("memory_retriever", run_memory_retrieval)
|
| 536 |
new_workflow.add_node("intent_agent", run_intent_agent)
|
| 537 |
new_workflow.add_node("pm_agent", run_pm_agent)
|
| 538 |
+
new_workflow.add_node("pragmatist_agent", run_pragmatist_agent) # Local upgraded
|
| 539 |
+
new_workflow.add_node("governance_agent", run_governance_agent) # Local upgraded
|
| 540 |
new_workflow.add_node("experimenter_agent", run_experimenter_agent)
|
| 541 |
+
new_workflow.add_node("compliance_agent", run_compliance_agent) # Local upgraded
|
| 542 |
new_workflow.add_node("synthesis_agent", run_synthesis_agent)
|
| 543 |
new_workflow.add_node("qa_agent", run_qa_agent)
|
| 544 |
+
new_workflow.add_node("observer_agent", run_observer_agent) # Local upgraded
|
| 545 |
new_workflow.add_node("archivist_agent", run_archivist_agent)
|
| 546 |
+
new_workflow.add_node("knowledge_curator_agent", run_knowledge_curator_agent) # Local upgraded
|
| 547 |
new_workflow.add_node("disclaimer_agent", run_disclaimer_agent)
|
| 548 |
|
| 549 |
log.info("✅ All nodes added to new graph")
|
|
|
|
| 590 |
new_workflow.add_edge("compliance_agent", "synthesis_agent")
|
| 591 |
new_workflow.add_edge("synthesis_agent", "qa_agent")
|
| 592 |
|
| 593 |
+
# QA conditional routing (use imported should_continue)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 594 |
new_workflow.add_conditional_edges(
|
| 595 |
"qa_agent",
|
| 596 |
should_continue,
|