Add debug output for state tracking
This commit is contained in:
@@ -596,19 +596,24 @@ Write ~{plan.word_count_target} words.
|
|||||||
|
|
||||||
config = {"configurable": {"thread_id": thread_id}}
|
config = {"configurable": {"thread_id": thread_id}}
|
||||||
|
|
||||||
# FIX: Use stream_mode="values" to get full state objects
|
# Track final state - capture at each step
|
||||||
final_state = initial_state
|
final_state = initial_state
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Stream with values mode - each chunk IS the full state
|
# Stream with values mode - each chunk IS the full state
|
||||||
for chunk in self.graph.stream(initial_state, config, stream_mode="values"):
|
for chunk in self.graph.stream(initial_state, config, stream_mode="values"):
|
||||||
|
print(f"[STREAM] Got chunk type: {type(chunk)}")
|
||||||
if isinstance(chunk, OpusGraphState):
|
if isinstance(chunk, OpusGraphState):
|
||||||
final_state = chunk
|
final_state = chunk
|
||||||
# Print progress
|
# Track chapters as we go
|
||||||
if chunk.messages:
|
if chunk.chapters:
|
||||||
last_msg = chunk.messages[-1]
|
print(f"[STREAM] Chapters so far: {len(chunk.chapters)}, words: {sum(c.word_count for c in chunk.chapters.values())}")
|
||||||
if "Writing chapter" in last_msg or "COMPLETE" in last_msg:
|
elif isinstance(chunk, dict):
|
||||||
print(last_msg)
|
print(f"[STREAM] Got dict, keys: {chunk.keys()}")
|
||||||
|
# Try to reconstruct state
|
||||||
|
if 'chapters' in chunk and chunk.get('manuscript'):
|
||||||
|
final_state = OpusGraphState(**chunk)
|
||||||
|
print(f"[STREAM] Reconstructed from dict: {len(final_state.chapters)} chapters")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Stream error: {e}")
|
print(f"Stream error: {e}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user