feat: add new blocks field to agent model and deprecate memory field [LET-4424] (#5613)

feat: add new blocks field to agent model and deprecate memory field
This commit is contained in:
cthomas
2025-10-21 13:04:25 -07:00
committed by Caren Thomas
parent 99c7c41911
commit beaeddf54d
3 changed files with 423 additions and 3 deletions

View File

@@ -16629,6 +16629,410 @@
},
"required": ["blocks"]
},
"blocks": {
"type": "array",
"items": {
"type": "object",
"properties": {
"value": {
"type": "string"
},
"limit": {
"oneOf": [
{
"type": "number"
},
{}
]
},
"project_id": {
"oneOf": [
{
"type": "string"
},
{
"type": "string",
"format": "null",
"nullable": true
},
{
"type": "array",
"items": {
"oneOf": [
{
"type": "string"
},
{
"type": "string",
"format": "null",
"nullable": true
}
],
"nullable": true
}
},
{}
],
"nullable": true
},
"name": {
"oneOf": [
{
"type": "string"
},
{
"type": "string",
"format": "null",
"nullable": true
},
{
"type": "array",
"items": {
"oneOf": [
{
"type": "string"
},
{
"type": "string",
"format": "null",
"nullable": true
}
],
"nullable": true
}
},
{}
],
"nullable": true
},
"is_template": {
"oneOf": [
{
"type": "boolean"
},
{}
]
},
"base_template_id": {
"oneOf": [
{
"type": "string"
},
{
"type": "string",
"format": "null",
"nullable": true
},
{
"type": "array",
"items": {
"oneOf": [
{
"type": "string"
},
{
"type": "string",
"format": "null",
"nullable": true
}
],
"nullable": true
}
},
{}
],
"nullable": true
},
"deployment_id": {
"oneOf": [
{
"type": "string"
},
{
"type": "string",
"format": "null",
"nullable": true
},
{
"type": "array",
"items": {
"oneOf": [
{
"type": "string"
},
{
"type": "string",
"format": "null",
"nullable": true
}
],
"nullable": true
}
},
{}
],
"nullable": true
},
"entity_id": {
"oneOf": [
{
"type": "string"
},
{
"type": "string",
"format": "null",
"nullable": true
},
{
"type": "array",
"items": {
"oneOf": [
{
"type": "string"
},
{
"type": "string",
"format": "null",
"nullable": true
}
],
"nullable": true
}
},
{}
],
"nullable": true
},
"preserve_on_migration": {
"oneOf": [
{
"type": "boolean"
},
{
"type": "string",
"format": "null",
"nullable": true
},
{
"type": "array",
"items": {
"oneOf": [
{
"type": "boolean"
},
{
"type": "string",
"format": "null",
"nullable": true
}
],
"nullable": true
}
},
{}
],
"nullable": true
},
"label": {
"oneOf": [
{
"type": "string"
},
{
"type": "string",
"format": "null",
"nullable": true
},
{
"type": "array",
"items": {
"oneOf": [
{
"type": "string"
},
{
"type": "string",
"format": "null",
"nullable": true
}
],
"nullable": true
}
},
{}
],
"nullable": true
},
"read_only": {
"oneOf": [
{
"type": "boolean"
},
{}
]
},
"description": {
"oneOf": [
{
"type": "string"
},
{
"type": "string",
"format": "null",
"nullable": true
},
{
"type": "array",
"items": {
"oneOf": [
{
"type": "string"
},
{
"type": "string",
"format": "null",
"nullable": true
}
],
"nullable": true
}
},
{}
],
"nullable": true
},
"metadata": {
"oneOf": [
{
"nullable": true
},
{
"type": "string",
"format": "null",
"nullable": true
},
{
"type": "array",
"items": {
"oneOf": [
{
"nullable": true
},
{
"type": "string",
"format": "null",
"nullable": true
}
],
"nullable": true
}
},
{}
],
"nullable": true
},
"hidden": {
"oneOf": [
{
"type": "boolean"
},
{
"type": "string",
"format": "null",
"nullable": true
},
{
"type": "array",
"items": {
"oneOf": [
{
"type": "boolean"
},
{
"type": "string",
"format": "null",
"nullable": true
}
],
"nullable": true
}
},
{}
],
"nullable": true
},
"id": {
"oneOf": [
{
"type": "string"
},
{}
]
},
"created_by_id": {
"oneOf": [
{
"type": "string"
},
{
"type": "string",
"format": "null",
"nullable": true
},
{
"type": "array",
"items": {
"oneOf": [
{
"type": "string"
},
{
"type": "string",
"format": "null",
"nullable": true
}
],
"nullable": true
}
},
{}
],
"nullable": true
},
"last_updated_by_id": {
"oneOf": [
{
"type": "string"
},
{
"type": "string",
"format": "null",
"nullable": true
},
{
"type": "array",
"items": {
"oneOf": [
{
"type": "string"
},
{
"type": "string",
"format": "null",
"nullable": true
}
],
"nullable": true
}
},
{}
],
"nullable": true
}
},
"required": ["value"]
}
},
"tools": {
"type": "array",
"items": {
@@ -19485,6 +19889,7 @@
"llm_config",
"embedding_config",
"memory",
"blocks",
"tools",
"sources",
"tags"
@@ -22737,7 +23142,16 @@
},
"memory": {
"$ref": "#/components/schemas/Memory",
"description": "The in-context memory of the agent."
"description": "The in-context memory of the agent.",
"deprecated": true
},
"blocks": {
"items": {
"$ref": "#/components/schemas/Block"
},
"type": "array",
"title": "Blocks",
"description": "The memory blocks used by the agent."
},
"tools": {
"items": {
@@ -22962,6 +23376,7 @@
"llm_config",
"embedding_config",
"memory",
"blocks",
"tools",
"sources",
"tags"

View File

@@ -241,6 +241,7 @@ class Agent(SqlalchemyBase, OrganizationMixin, ProjectMixin, TemplateEntityMixin
"tools": [],
"sources": [],
"memory": Memory(blocks=[]),
"blocks": [],
"identity_ids": [],
"multi_agent_group": None,
"tool_exec_environment_variables": [],
@@ -262,6 +263,7 @@ class Agent(SqlalchemyBase, OrganizationMixin, ProjectMixin, TemplateEntityMixin
],
agent_type=self.agent_type,
),
"blocks": lambda: [b.to_pydantic() for b in self.core_memory],
"identity_ids": lambda: [i.id for i in self.identities],
"multi_agent_group": lambda: self.multi_agent_group,
"tool_exec_environment_variables": lambda: self.tool_exec_environment_variables,
@@ -334,6 +336,7 @@ class Agent(SqlalchemyBase, OrganizationMixin, ProjectMixin, TemplateEntityMixin
"tools": [],
"sources": [],
"memory": Memory(blocks=[]),
"blocks": [],
"identity_ids": [],
"multi_agent_group": None,
"tool_exec_environment_variables": [],
@@ -379,6 +382,7 @@ class Agent(SqlalchemyBase, OrganizationMixin, ProjectMixin, TemplateEntityMixin
],
agent_type=self.agent_type,
)
state["blocks"] = [m.to_pydantic() for m in memory]
state["identity_ids"] = [i.id for i in identities]
state["multi_agent_group"] = multi_agent_group
state["tool_exec_environment_variables"] = tool_exec_environment_variables

View File

@@ -6,7 +6,7 @@ from pydantic import BaseModel, ConfigDict, Field, field_validator, model_valida
from letta.constants import CORE_MEMORY_LINE_NUMBER_WARNING, DEFAULT_EMBEDDING_CHUNK_SIZE
from letta.errors import AgentExportProcessingError
from letta.schemas.block import CreateBlock
from letta.schemas.block import Block, CreateBlock
from letta.schemas.embedding_config import EmbeddingConfig
from letta.schemas.environment_variables import AgentEnvironmentVariable
from letta.schemas.file import FileStatus
@@ -85,7 +85,8 @@ class AgentState(OrmMetadataBase, validate_assignment=True):
description: Optional[str] = Field(None, description="The description of the agent.")
metadata: Optional[Dict] = Field(None, description="The metadata of the agent.")
memory: Memory = Field(..., description="The in-context memory of the agent.")
memory: Memory = Field(..., description="The in-context memory of the agent.", deprecated=True)
blocks: List[Block] = Field(..., description="The memory blocks used by the agent.")
tools: List[Tool] = Field(..., description="The tools used by the agent.")
sources: List[Source] = Field(..., description="The sources used by the agent.")
tags: List[str] = Field(..., description="The tags associated with the agent.")