Files
letta-server/alembic/versions/a1b2c3d4e5f7_add_blocks_conversations_table.py
Sarah Wooders b888c4c17a feat: allow for conversation-level isolation of blocks (#8684)
* feat: add conversation_id parameter to context endpoint [LET-6989]

Add optional conversation_id query parameter to retrieve_agent_context_window.
When provided, the endpoint uses messages from the specific conversation
instead of the agent's default message_ids.

👾 Generated with [Letta Code](https://letta.com)

Co-Authored-By: Letta <noreply@letta.com>

* chore: regenerate SDK after context endpoint update [LET-6989]

👾 Generated with [Letta Code](https://letta.com)

Co-Authored-By: Letta <noreply@letta.com>

* feat: add isolated blocks support for conversations

Allows conversations to have their own copies of specific memory blocks (e.g., todo_list) that override agent defaults, enabling conversation-specific state isolation.

👾 Generated with [Letta Code](https://letta.com)

Co-Authored-By: Letta <noreply@letta.com>

* undo

* update apis

* test

* cleanup

* fix tests

* simplify

* move override logic

* patch

---------

Co-authored-by: Letta <noreply@letta.com>
2026-01-19 15:54:39 -08:00

49 lines
1.6 KiB
Python

"""Add blocks_conversations table for conversation-isolated blocks
Revision ID: a1b2c3d4e5f7
Revises: cf3c4d025dbc
Create Date: 2026-01-14 02:22:00.000000
"""
from typing import Sequence, Union
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "a1b2c3d4e5f7"
down_revision: Union[str, None] = "cf3c4d025dbc"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# Create blocks_conversations junction table
op.create_table(
"blocks_conversations",
sa.Column("conversation_id", sa.String(), nullable=False),
sa.Column("block_id", sa.String(), nullable=False),
sa.Column("block_label", sa.String(), nullable=False),
sa.ForeignKeyConstraint(
["conversation_id"],
["conversations.id"],
ondelete="CASCADE",
),
sa.ForeignKeyConstraint(
["block_id"],
["block.id"],
ondelete="CASCADE",
),
sa.PrimaryKeyConstraint("conversation_id", "block_id", "block_label"),
sa.UniqueConstraint("conversation_id", "block_label", name="unique_label_per_conversation"),
sa.UniqueConstraint("conversation_id", "block_id", name="unique_conversation_block"),
)
op.create_index("ix_blocks_conversations_block_id", "blocks_conversations", ["block_id"], unique=False)
def downgrade() -> None:
op.drop_index("ix_blocks_conversations_block_id", table_name="blocks_conversations")
op.drop_table("blocks_conversations")