Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
feat: add new approval request message objects (#4291)
cthomas19197afd1e95
diff --git a/letta/schemas/letta_message.py b/letta/schemas/letta_message.pyindex 5f63077e1..16b6f23f3 100644--- a/letta/schemas/letta_message.py+++ b/letta/schemas/letta_message.py@@ -25,6 +25,8 @@ class MessageType(str, Enum):hidden_reasoning_message = "hidden_reasoning_message"tool_call_message = "tool_call_message"tool_return_message = "tool_return_message"+ approval_request_message = "approval_request_message"+ approval_response_message = "approval_response_message"class LettaMessage(BaseModel):@@ -249,6 +251,44 @@ class ToolReturnMessage(LettaMessage):stderr: Optional[List[str]] = None+class ApprovalRequestMessage(LettaMessage):+ """+ A message representing a request for approval to call a tool (generated by the LLM to trigger tool execution).++ Args:+ id (str): The ID of the message+ date (datetime): The date the message was created in ISO format+ name (Optional[str]): The name of the sender of the message+ tool_call (ToolCall): The tool call+ """++ message_type: Literal[MessageType.approval_request_message] = Field(+ default=MessageType.approval_request_message, description="The type of the message."+ )+ tool_call: ToolCall = Field(..., description="The tool call that has been requested by the llm to run")+++class ApprovalResponseMessage(LettaMessage):+ """+ A message representing a response form the user indicating whether a tool has been approved to run.++ Args:+ id (str): The ID of the message+ date (datetime): The date the message was created in ISO format+ name (Optional[str]): The name of the sender of the message+ approve: (bool) Whether the tool has been approved+ approval_request_id: The ID of the approval request+ reason: (Optional[str]) An optional explanation for the provided approval status+ """++ message_type: Literal[MessageType.approval_response_message] = Field(+ default=MessageType.approval_response_message, description="The type of the message."+ )+ approve: bool = Field(..., description="Whether the tool has been approved")+ approval_request_id: str = Field(..., description="The message ID of the approval request")+ reason: Optional[str] = Field(None, description="An optional explanation for the provided approval status")++class AssistantMessage(LettaMessage):"""A message sent by the LLM in response to user input. Used in the LLM context.