Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
feat: always create otid for request (#10057)
cthomas1bc726144cb8
diff --git a/fern/openapi.json b/fern/openapi.jsonindex 7aded188c..1c80d96a8 100644--- a/fern/openapi.json+++ b/fern/openapi.json@@ -28671,6 +28671,30 @@"description": "The message type to be created.","default": "approval"},+ "otid": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "title": "Otid",+ "description": "The offline threading id associated with this message"+ },+ "group_id": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "title": "Group Id",+ "description": "The multi-agent group that the message was sent in"+ },"approvals": {"anyOf": [{@@ -28738,18 +28762,6 @@"title": "Reason","description": "An optional explanation for the provided approval status","deprecated": true- },- "group_id": {- "anyOf": [- {- "type": "string"- },- {- "type": "null"- }- ],- "title": "Group Id",- "description": "The multi-agent group that the message was sent in"}},"type": "object",@@ -41586,6 +41598,30 @@"description": "The message type to be created.","default": "message"},+ "otid": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "title": "Otid",+ "description": "The offline threading id associated with this message"+ },+ "group_id": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "title": "Group Id",+ "description": "The multi-agent group that the message was sent in"+ },"role": {"type": "string","enum": ["user", "system", "assistant"],@@ -41619,18 +41655,6 @@"title": "Name","description": "The name of the participant."},- "otid": {- "anyOf": [- {- "type": "string"- },- {- "type": "null"- }- ],- "title": "Otid",- "description": "The offline threading id associated with this message"- },"sender_id": {"anyOf": [{@@ -41654,18 +41678,6 @@],"title": "Batch Item Id","description": "The id of the LLMBatchItem that this message is associated with"- },- "group_id": {- "anyOf": [- {- "type": "string"- },- {- "type": "null"- }- ],- "title": "Group Id",- "description": "The multi-agent group that the message was sent in"}},"type": "object",@@ -47850,6 +47862,30 @@"description": "The message type to be created.","default": "tool_return"},+ "otid": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "title": "Otid",+ "description": "The offline threading id associated with this message"+ },+ "group_id": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "title": "Group Id",+ "description": "The multi-agent group that the message was sent in"+ },"tool_returns": {"items": {"$ref": "#/components/schemas/letta__schemas__letta_message__ToolReturn"@@ -50872,6 +50908,30 @@"description": "The message type to be created.","default": "message"},+ "otid": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "title": "Otid",+ "description": "The offline threading id associated with this message"+ },+ "group_id": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "title": "Group Id",+ "description": "The multi-agent group that the message was sent in"+ },"role": {"$ref": "#/components/schemas/MessageRole","description": "The role of the participant."@@ -50903,18 +50963,6 @@"title": "Name","description": "The name of the participant."},- "otid": {- "anyOf": [- {- "type": "string"- },- {- "type": "null"- }- ],- "title": "Otid",- "description": "The offline threading id associated with this message"- },"sender_id": {"anyOf": [{@@ -50939,18 +50987,6 @@"title": "Batch Item Id","description": "The id of the LLMBatchItem that this message is associated with"},- "group_id": {- "anyOf": [- {- "type": "string"- },- {- "type": "null"- }- ],- "title": "Group Id",- "description": "The multi-agent group that the message was sent in"- },"id": {"type": "string","title": "Id",diff --git a/letta/schemas/letta_request.py b/letta/schemas/letta_request.pyindex d551cfcbf..513581908 100644--- a/letta/schemas/letta_request.py+++ b/letta/schemas/letta_request.py@@ -1,4 +1,3 @@-import uuidfrom typing import Any, Dict, List, Optional, Unionfrom pydantic import BaseModel, Field, HttpUrl, field_validator, model_validator@@ -147,7 +146,7 @@ class LettaRequest(BaseModel):# input can be either a string or List[LettaMessageContentUnion]if self.input is not None:# Both str and List[LettaMessageContentUnion] are valid content types for MessageCreate- self.messages = [MessageCreate(role=MessageRole.user, content=self.input, otid=str(uuid.uuid4()))]+ self.messages = [MessageCreate(role=MessageRole.user, content=self.input)]return selfdiff --git a/letta/schemas/message.py b/letta/schemas/message.pyindex 6368db2f1..9c9d6f677 100644--- a/letta/schemas/message.py+++ b/letta/schemas/message.py@@ -131,6 +131,14 @@ class MessageCreateType(str, Enum):class MessageCreateBase(BaseModel):type: MessageCreateType = Field(..., description="The message type to be created.")+ otid: Optional[str] = Field(default=None, description="The offline threading id associated with this message")+ group_id: Optional[str] = Field(default=None, description="The multi-agent group that the message was sent in")++ @model_validator(mode="after")+ def generate_otid_if_missing(self):+ if self.otid is None:+ self.otid = str(uuid.uuid4())+ return selfclass MessageCreate(MessageCreateBase):@@ -151,10 +159,8 @@ class MessageCreate(MessageCreateBase):json_schema_extra=get_letta_message_content_union_str_json_schema(),)name: Optional[str] = Field(default=None, description="The name of the participant.")- otid: Optional[str] = Field(default=None, description="The offline threading id associated with this message")sender_id: Optional[str] = Field(default=None, description="The id of the sender of the message, can be an identity id or agent id")batch_item_id: Optional[str] = Field(default=None, description="The id of the LLMBatchItem that this message is associated with")- group_id: Optional[str] = Field(default=None, description="The multi-agent group that the message was sent in")def model_dump(self, to_orm: bool = False, **kwargs) -> Dict[str, Any]:data = super().model_dump(**kwargs)@@ -172,7 +178,6 @@ class ApprovalCreate(MessageCreateBase):approve: Optional[bool] = Field(None, description="Whether the tool has been approved", deprecated=True)approval_request_id: Optional[str] = Field(None, description="The message ID of the approval request", deprecated=True)reason: Optional[str] = Field(None, description="An optional explanation for the provided approval status", deprecated=True)- group_id: Optional[str] = Field(default=None, description="The multi-agent group that the message was sent in")@model_validator(mode="after")def migrate_deprecated_fields(self):