Fix state return handling - support dict fallback
This commit is contained in:
@@ -612,15 +612,15 @@ Write ~{plan.word_count_target} words.
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Stream error: {e}")
|
print(f"Stream error: {e}")
|
||||||
|
|
||||||
# FIX: Fallback - pull directly from checkpointer
|
# FIX: Handle both OpusGraphState and dict from checkpointer
|
||||||
if not final_state.manuscript:
|
if hasattr(final_state, 'manuscript') and final_state.manuscript:
|
||||||
print("Pulling from checkpointer...")
|
pass # Already have state
|
||||||
try:
|
elif isinstance(final_state, dict) and final_state.get('manuscript'):
|
||||||
snapshot = self.graph.get_state(config)
|
# Convert dict back to state if needed
|
||||||
if snapshot and snapshot.values:
|
print(f"\n[RESULT] Chapters: {len(final_state.get('chapters', {}))}, Words: {final_state.get('total_word_count', 0)}")
|
||||||
final_state = snapshot.values
|
return OpusGraphState(**final_state)
|
||||||
except Exception as e:
|
else:
|
||||||
print(f"Checkpointer error: {e}")
|
print(f"\n[RESULT] No manuscript found in state")
|
||||||
|
|
||||||
print(f"\n[RESULT] Chapters: {len(final_state.chapters)}, Words: {final_state.total_word_count}")
|
print(f"\n[RESULT] Chapters: {len(final_state.chapters)}, Words: {final_state.total_word_count}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user