From a0175056bde7240ea12ea459148955c2c799381b Mon Sep 17 00:00:00 2001 From: Mark Randall Havens Date: Thu, 12 Mar 2026 21:11:11 +0000 Subject: [PATCH] Fix final state extraction for LangGraph --- opus_orchestrator/langgraph_workflow.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/opus_orchestrator/langgraph_workflow.py b/opus_orchestrator/langgraph_workflow.py index 552d9b0..44a4ae5 100644 --- a/opus_orchestrator/langgraph_workflow.py +++ b/opus_orchestrator/langgraph_workflow.py @@ -492,17 +492,15 @@ Write ~{plan.word_count_target} words. Begin with chapter title. config = {"configurable": {"thread_id": thread_id}} - # LangGraph stream returns dict of node_name -> state + # LangGraph stream - accumulate final state + result_state = initial_state for node_output in self.graph.stream(initial_state, config): - # Get the state (last output is final) + # node_output is {node_name: state} for key, state in node_output.items(): - if isinstance(state, OpusGraphState): - final_state = state + if hasattr(state, 'stage'): # It's an OpusGraphState + result_state = state - if final_state: - return final_state - - return initial_state + return result_state def run_opus(