Skip to content

Commit 0362598

Browse files
committed
fix: handle missing checkpointer in get_pending_mutation and reject_mutation
1 parent 7ce3e40 commit 0362598

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

workspace_secretary/assistant/graph.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,11 @@ def get_pending_mutation(thread_id: str) -> Optional[dict[str, Any]]:
365365
config = {"configurable": {"thread_id": thread_id}}
366366

367367
# Get current state from checkpointer
368-
state = graph.get_state(config)
368+
try:
369+
state = graph.get_state(config)
370+
except ValueError:
371+
# No checkpointer set
372+
return None
369373

370374
if state and state.values:
371375
messages = state.values.get("messages", [])
@@ -379,22 +383,28 @@ def get_pending_mutation(thread_id: str) -> Optional[dict[str, Any]]:
379383
return None
380384

381385

382-
def reject_mutation(thread_id: str, reason: str = "User declined") -> AssistantState:
386+
def reject_mutation(
387+
thread_id: str, reason: str = "User declined"
388+
) -> Optional[AssistantState]:
383389
"""Reject a pending mutation and add rejection message.
384390
385391
Args:
386392
thread_id: Thread identifier
387393
reason: Rejection reason to add to conversation
388394
389395
Returns:
390-
Updated state with rejection message
396+
Updated state with rejection message, or None if no checkpointer
391397
"""
392398
graph = get_graph()
393399

394400
config = {"configurable": {"thread_id": thread_id}}
395401

396402
# Get current state
397-
state = graph.get_state(config)
403+
try:
404+
state = graph.get_state(config)
405+
except ValueError:
406+
# No checkpointer set
407+
return None
398408

399409
if state and state.values:
400410
messages = list(state.values.get("messages", []))

0 commit comments

Comments
 (0)