Files
lgesuellip 7ab956faa7 backend: Convert checkpointer.alist to async generator to fix async iteration in aget_state_history
## PR Description

This PR converts `checkpointer.alist` into an async generator by using async for and yield inside the function. With this change, `alist` immediately returns an async iterator, allowing `agent.aget_state_history()` to iterate over it directly without needing to await the coroutine.

## Relevant issues

https://github.com/langchain-ai/opengpts/issues/377

## Type

🐛 Bug Fix

## Changes

- Modified `checkpointer.alist` to use an async generator pattern python

## Tests
Tested the flow by calling `get_thread_history()` which internally calls `agent.aget_state_history()`, confirming that the async iteration now functions as expected without errors.

Thank you Team!
2025-02-21 16:01:28 +00:00
..
2025-01-29 16:51:41 -05:00
2025-01-29 16:51:41 -05:00
2024-03-15 12:02:33 +02:00
2024-05-06 14:59:22 +04:00
2024-05-06 14:59:22 +04:00
2025-01-29 16:51:41 -05:00
2025-01-29 16:51:41 -05:00
2025-01-29 16:51:41 -05:00

backend

Database Migrations

Migration 5 - Checkpoint Management Update

This migration introduces a significant change to thread checkpoint management:

Changes

  • Transitions from single-table pickle storage to a robust multi-table checkpoint management system
  • Implements LangGraph's latest checkpoint architecture for improved state persistence
  • Preserves existing checkpoint data by renaming checkpoints table to old_checkpoints
  • Introduces three new tables for better checkpoint management:
    • checkpoints: Core checkpoint metadata
    • checkpoint_blobs: Actual checkpoint data storage (compatible with LangGraph state serialization)
    • checkpoint_writes: Tracks checkpoint write operations
  • Adds runtime initialization via ensure_setup() in the lifespan event

Impact

  • Breaking Change: Historical threads/checkpoints (pre-migration) will not be accessible in the UI
  • Previous checkpoint data remains preserved but inaccessible in the new system
  • Designed to work seamlessly with LangGraph's state persistence requirements

Migration Details

  • Up Migration: Safely preserves existing data by renaming the table
  • Down Migration: Restores original table structure if needed
  • New checkpoint management tables are automatically created at application startup