diff --git a/alembic/versions/341068089f14_add_preserve_on_migration_to_block.py b/alembic/versions/341068089f14_add_preserve_on_migration_to_block.py new file mode 100644 index 00000000..aba81f47 --- /dev/null +++ b/alembic/versions/341068089f14_add_preserve_on_migration_to_block.py @@ -0,0 +1,31 @@ +"""add preserve_on_migration to block + +Revision ID: 341068089f14 +Revises: 348214cbc081 +Create Date: 2025-05-29 10:39:44.494643 + +""" + +from typing import Sequence, Union + +import sqlalchemy as sa + +from alembic import op + +# revision identifiers, used by Alembic. +revision: str = "341068089f14" +down_revision: Union[str, None] = "348214cbc081" +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.add_column("block", sa.Column("preserve_on_migration", sa.Boolean(), nullable=False)) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column("block", "preserve_on_migration") + # ### end Alembic commands ### diff --git a/letta/orm/block.py b/letta/orm/block.py index 271a9baa..ae895763 100644 --- a/letta/orm/block.py +++ b/letta/orm/block.py @@ -35,6 +35,7 @@ class Block(OrganizationMixin, SqlalchemyBase): is_template: Mapped[bool] = mapped_column( doc="whether the block is a template (e.g. saved human/persona options as baselines for other templates)", default=False ) + preserve_on_migration: Mapped[bool] = mapped_column(doc="preserve the block on template migration", default=False) value: Mapped[str] = mapped_column(doc="Text content of the block for the respective section of core memory.") limit: Mapped[BigInteger] = mapped_column(Integer, default=CORE_MEMORY_BLOCK_CHAR_LIMIT, doc="Character limit of the block.") metadata_: Mapped[Optional[dict]] = mapped_column(JSON, default={}, doc="arbitrary information related to the block.") diff --git a/letta/schemas/block.py b/letta/schemas/block.py index ea2e96cc..8d3da3b9 100644 --- a/letta/schemas/block.py +++ b/letta/schemas/block.py @@ -21,6 +21,7 @@ class BaseBlock(LettaBase, validate_assignment=True): # template data (optional) template_name: Optional[str] = Field(None, description="Name of the block if it is a template.", alias="name") is_template: bool = Field(False, description="Whether the block is a template (e.g. saved human/persona options).") + preserve_on_migration: bool = Field(False, description="Preserve the block on template migration.") # context window label label: Optional[str] = Field(None, description="Label of the block (e.g. 'human', 'persona') in the context window.")