Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

fix: override validation for group for agentfile import (#9248)

Kian Jones025eeaa363f7
diff --git a/fern/openapi.json b/fern/openapi.json
index eda5a6770..dace1b4af 100644
--- a/fern/openapi.json
+++ b/fern/openapi.json
@@ -31940,6 +31940,50 @@
"required": ["manager_agent_id"],
"title": "DynamicManager"
},
+ "DynamicManagerSchema": {
+ "properties": {
+ "manager_type": {
+ "type": "string",
+ "const": "dynamic",
+ "title": "Manager Type",
+ "description": "",
+ "default": "dynamic"
+ },
+ "manager_agent_id": {
+ "type": "string",
+ "title": "Manager Agent Id",
+ "description": ""
+ },
+ "termination_token": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Termination Token",
+ "description": "",
+ "default": "DONE!"
+ },
+ "max_turns": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Max Turns",
+ "description": ""
+ }
+ },
+ "type": "object",
+ "required": ["manager_agent_id"],
+ "title": "DynamicManagerSchema"
+ },
"DynamicManagerUpdate": {
"properties": {
"manager_type": {
@@ -33993,16 +34037,11 @@
"properties": {
"agent_ids": {
"items": {
- "type": "string",
- "maxLength": 42,
- "minLength": 42,
- "pattern": "^agent-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
- "description": "The ID of the agent in the format 'agent-<uuid4>'",
- "examples": ["agent-123e4567-e89b-42d3-8456-426614174000"]
+ "type": "string"
},
"type": "array",
"title": "Agent Ids",
- "description": ""
+ "description": "List of agent IDs in this group"
},
"description": {
"type": "string",
@@ -34015,16 +34054,16 @@
"$ref": "#/components/schemas/RoundRobinManager"
},
{
- "$ref": "#/components/schemas/SupervisorManager"
+ "$ref": "#/components/schemas/SupervisorManagerSchema"
},
{
- "$ref": "#/components/schemas/DynamicManager"
+ "$ref": "#/components/schemas/DynamicManagerSchema"
},
{
- "$ref": "#/components/schemas/SleeptimeManager"
+ "$ref": "#/components/schemas/SleeptimeManagerSchema"
},
{
- "$ref": "#/components/schemas/VoiceSleeptimeManager"
+ "$ref": "#/components/schemas/VoiceSleeptimeManagerSchema"
}
],
"title": "Manager Config",
@@ -34035,11 +34074,11 @@
"discriminator": {
"propertyName": "manager_type",
"mapping": {
- "dynamic": "#/components/schemas/DynamicManager",
+ "dynamic": "#/components/schemas/DynamicManagerSchema",
"round_robin": "#/components/schemas/RoundRobinManager",
- "sleeptime": "#/components/schemas/SleeptimeManager",
- "supervisor": "#/components/schemas/SupervisorManager",
- "voice_sleeptime": "#/components/schemas/VoiceSleeptimeManager"
+ "sleeptime": "#/components/schemas/SleeptimeManagerSchema",
+ "supervisor": "#/components/schemas/SupervisorManagerSchema",
+ "voice_sleeptime": "#/components/schemas/VoiceSleeptimeManagerSchema"
}
}
},
@@ -34057,18 +34096,12 @@
},
"shared_block_ids": {
"items": {
- "type": "string",
- "maxLength": 42,
- "minLength": 42,
- "pattern": "^block-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
- "description": "The ID of the block in the format 'block-<uuid4>'",
- "examples": ["block-123e4567-e89b-42d3-8456-426614174000"]
+ "type": "string"
},
"type": "array",
"title": "Shared Block Ids",
- "description": "",
- "default": [],
- "deprecated": true
+ "description": "List of shared block IDs",
+ "default": []
},
"hidden": {
"anyOf": [
@@ -41711,6 +41744,37 @@
"required": ["manager_agent_id"],
"title": "SleeptimeManager"
},
+ "SleeptimeManagerSchema": {
+ "properties": {
+ "manager_type": {
+ "type": "string",
+ "const": "sleeptime",
+ "title": "Manager Type",
+ "description": "",
+ "default": "sleeptime"
+ },
+ "manager_agent_id": {
+ "type": "string",
+ "title": "Manager Agent Id",
+ "description": ""
+ },
+ "sleeptime_agent_frequency": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Sleeptime Agent Frequency",
+ "description": ""
+ }
+ },
+ "type": "object",
+ "required": ["manager_agent_id"],
+ "title": "SleeptimeManagerSchema"
+ },
"SleeptimeManagerUpdate": {
"properties": {
"manager_type": {
@@ -43054,6 +43118,25 @@
"required": ["manager_agent_id"],
"title": "SupervisorManager"
},
+ "SupervisorManagerSchema": {
+ "properties": {
+ "manager_type": {
+ "type": "string",
+ "const": "supervisor",
+ "title": "Manager Type",
+ "description": "",
+ "default": "supervisor"
+ },
+ "manager_agent_id": {
+ "type": "string",
+ "title": "Manager Agent Id",
+ "description": ""
+ }
+ },
+ "type": "object",
+ "required": ["manager_agent_id"],
+ "title": "SupervisorManagerSchema"
+ },
"SupervisorManagerUpdate": {
"properties": {
"manager_type": {
@@ -46071,6 +46154,49 @@
"required": ["manager_agent_id"],
"title": "VoiceSleeptimeManager"
},
+ "VoiceSleeptimeManagerSchema": {
+ "properties": {
+ "manager_type": {
+ "type": "string",
+ "const": "voice_sleeptime",
+ "title": "Manager Type",
+ "description": "",
+ "default": "voice_sleeptime"
+ },
+ "manager_agent_id": {
+ "type": "string",
+ "title": "Manager Agent Id",
+ "description": ""
+ },
+ "max_message_buffer_length": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Max Message Buffer Length",
+ "description": ""
+ },
+ "min_message_buffer_length": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Min Message Buffer Length",
+ "description": ""
+ }
+ },
+ "type": "object",
+ "required": ["manager_agent_id"],
+ "title": "VoiceSleeptimeManagerSchema"
+ },
"VoiceSleeptimeManagerUpdate": {
"properties": {
"manager_type": {
diff --git a/letta/schemas/agent_file.py b/letta/schemas/agent_file.py
index ccbdd7f9b..2e35f30bb 100644
--- a/letta/schemas/agent_file.py
+++ b/letta/schemas/agent_file.py
@@ -1,5 +1,5 @@
from datetime import datetime
-from typing import Any, Dict, List, Optional
+from typing import Annotated, Any, Dict, List, Literal, Optional, Union
from openai.types.chat.chat_completion_message_tool_call import ChatCompletionMessageToolCall as OpenAIToolCall
from pydantic import BaseModel, Field
@@ -9,7 +9,13 @@ from letta.schemas.agent import AgentState, CreateAgent
from letta.schemas.block import Block, CreateBlock
from letta.schemas.enums import MessageRole, PrimitiveType
from letta.schemas.file import FileAgent, FileAgentBase, FileMetadata, FileMetadataBase
-from letta.schemas.group import Group, GroupCreate
+from letta.schemas.group import (
+ Group,
+ GroupCreate,
+ ManagerConfig,
+ ManagerType,
+ RoundRobinManager,
+)
from letta.schemas.letta_message import ApprovalReturn
from letta.schemas.mcp import MCPServer
from letta.schemas.message import Message, MessageCreate, ToolReturn
@@ -195,12 +201,52 @@ class AgentSchema(CreateAgent):
)
+# Agentfile-specific manager configs that use plain str instead of validated AgentId
+# These allow importing agentfiles with simple IDs like "agent-0"
+
+
+class SupervisorManagerSchema(ManagerConfig):
+ manager_type: Literal[ManagerType.supervisor] = Field(ManagerType.supervisor, description="")
+ manager_agent_id: str = Field(..., description="")
+
+
+class DynamicManagerSchema(ManagerConfig):
+ manager_type: Literal[ManagerType.dynamic] = Field(ManagerType.dynamic, description="")
+ manager_agent_id: str = Field(..., description="")
+ termination_token: Optional[str] = Field("DONE!", description="")
+ max_turns: Optional[int] = Field(None, description="")
+
+
+class SleeptimeManagerSchema(ManagerConfig):
+ manager_type: Literal[ManagerType.sleeptime] = Field(ManagerType.sleeptime, description="")
+ manager_agent_id: str = Field(..., description="")
+ sleeptime_agent_frequency: Optional[int] = Field(None, description="")
+
+
+class VoiceSleeptimeManagerSchema(ManagerConfig):
+ manager_type: Literal[ManagerType.voice_sleeptime] = Field(ManagerType.voice_sleeptime, description="")
+ manager_agent_id: str = Field(..., description="")
+ max_message_buffer_length: Optional[int] = Field(None, description="")
+ min_message_buffer_length: Optional[int] = Field(None, description="")
+
+
+ManagerConfigSchemaUnion = Annotated[
+ Union[RoundRobinManager, SupervisorManagerSchema, DynamicManagerSchema, SleeptimeManagerSchema, VoiceSleeptimeManagerSchema],
+ Field(discriminator="manager_type"),
+]
+
+
class GroupSchema(GroupCreate):
"""Group with human-readable ID for agent file"""
__id_prefix__ = PrimitiveType.GROUP.value
id: str = Field(..., description="Human-readable identifier for this group in the file")
+ # Override validated ID fields from GroupCreate to accept simple IDs like "agent-0"
+ agent_ids: List[str] = Field(..., description="List of agent IDs in this group")
+ shared_block_ids: List[str] = Field([], description="List of shared block IDs")
+ manager_config: ManagerConfigSchemaUnion = Field(RoundRobinManager(), description="")
+
@classmethod
def from_group(cls, group: Group) -> "GroupSchema":
"""Convert Group to GroupSchema"""