feat: add EventMessage and SummaryMessage (#5765)

* feat: add new message types for 1.0

* feat: add new message types for 1.0

* update apis

* update openapi

---------

Co-authored-by: jnjpng <jin@letta.com>
Co-authored-by: Letta Bot <noreply@letta.com>
This commit is contained in:
Sarah Wooders
2025-11-04 18:02:58 +00:00
committed by Caren Thomas
parent d33fd219db
commit caa79d7bc9
3 changed files with 279 additions and 4 deletions

View File

@@ -570,6 +570,8 @@ paths:
- $ref: '#/components/schemas/AssistantMessage'
- $ref: '#/components/schemas/ApprovalRequestMessage'
- $ref: '#/components/schemas/ApprovalResponseMessage'
- $ref: '#/components/schemas/SummaryMessage'
- $ref: '#/components/schemas/EventMessage'
- $ref: '#/components/schemas/LettaPing'
- $ref: '#/components/schemas/LettaStopReason'
- $ref: '#/components/schemas/LettaUsageStatistics'
@@ -1187,6 +1189,8 @@ paths:
- $ref: '#/components/schemas/ToolCallMessage'
- $ref: '#/components/schemas/ToolReturnMessage'
- $ref: '#/components/schemas/AssistantMessage'
- $ref: '#/components/schemas/SummaryMessage'
- $ref: '#/components/schemas/EventMessage'
- $ref: '#/components/schemas/LettaUsageStatistics'
/v1/messages/batches:
post:

View File

@@ -7221,6 +7221,12 @@
},
{
"$ref": "#/components/schemas/ApprovalResponseMessage"
},
{
"$ref": "#/components/schemas/SummaryMessage"
},
{
"$ref": "#/components/schemas/EventMessage"
}
],
"discriminator": {
@@ -7234,7 +7240,9 @@
"tool_return_message": "#/components/schemas/ToolReturnMessage",
"assistant_message": "#/components/schemas/AssistantMessage",
"approval_request_message": "#/components/schemas/ApprovalRequestMessage",
"approval_response_message": "#/components/schemas/ApprovalResponseMessage"
"approval_response_message": "#/components/schemas/ApprovalResponseMessage",
"summary": "#/components/schemas/SummaryMessage",
"event": "#/components/schemas/EventMessage"
}
},
"title": "Response Modify Message"
@@ -8621,6 +8629,12 @@
},
{
"$ref": "#/components/schemas/ApprovalResponseMessage"
},
{
"$ref": "#/components/schemas/SummaryMessage"
},
{
"$ref": "#/components/schemas/EventMessage"
}
],
"discriminator": {
@@ -8634,7 +8648,9 @@
"tool_return_message": "#/components/schemas/ToolReturnMessage",
"assistant_message": "#/components/schemas/AssistantMessage",
"approval_request_message": "#/components/schemas/ApprovalRequestMessage",
"approval_response_message": "#/components/schemas/ApprovalResponseMessage"
"approval_response_message": "#/components/schemas/ApprovalResponseMessage",
"summary": "#/components/schemas/SummaryMessage",
"event": "#/components/schemas/EventMessage"
}
},
"title": "Response Modify Group Message"
@@ -14760,6 +14776,12 @@
},
{
"$ref": "#/components/schemas/ApprovalResponseMessage"
},
{
"$ref": "#/components/schemas/SummaryMessage"
},
{
"$ref": "#/components/schemas/EventMessage"
}
],
"discriminator": {
@@ -14773,7 +14795,9 @@
"tool_return_message": "#/components/schemas/ToolReturnMessage",
"assistant_message": "#/components/schemas/AssistantMessage",
"approval_request_message": "#/components/schemas/ApprovalRequestMessage",
"approval_response_message": "#/components/schemas/ApprovalResponseMessage"
"approval_response_message": "#/components/schemas/ApprovalResponseMessage",
"summary": "#/components/schemas/SummaryMessage",
"event": "#/components/schemas/EventMessage"
}
}
},
@@ -23788,6 +23812,116 @@
"title": "EmbeddingConfig",
"description": "Configuration for embedding model connection and processing parameters."
},
"EventMessage": {
"properties": {
"id": {
"type": "string",
"title": "Id"
},
"date": {
"type": "string",
"format": "date-time",
"title": "Date"
},
"name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Name"
},
"message_type": {
"type": "string",
"const": "event",
"title": "Message Type",
"default": "event_message"
},
"otid": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Otid"
},
"sender_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Sender Id"
},
"step_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Step Id"
},
"is_err": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"title": "Is Err"
},
"seq_id": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Seq Id"
},
"run_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Run Id"
},
"event_type": {
"type": "string",
"const": "compaction",
"title": "Event Type"
},
"event_data": {
"additionalProperties": true,
"type": "object",
"title": "Event Data"
}
},
"type": "object",
"required": ["id", "date", "event_type", "event_data"],
"title": "EventMessage",
"description": "A message for notifying the developer that an event that has occured (e.g. a compaction). Events are NOT part of the context window."
},
"FeedbackType": {
"type": "string",
"enum": ["positive", "negative"],
@@ -32183,6 +32317,110 @@
"required": ["index", "text"],
"title": "SummarizedReasoningContentPart"
},
"SummaryMessage": {
"properties": {
"id": {
"type": "string",
"title": "Id"
},
"date": {
"type": "string",
"format": "date-time",
"title": "Date"
},
"name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Name"
},
"message_type": {
"type": "string",
"const": "summary",
"title": "Message Type",
"default": "summary_message"
},
"otid": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Otid"
},
"sender_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Sender Id"
},
"step_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Step Id"
},
"is_err": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"title": "Is Err"
},
"seq_id": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Seq Id"
},
"run_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Run Id"
},
"summary": {
"type": "string",
"title": "Summary"
}
},
"type": "object",
"required": ["id", "date", "summary"],
"title": "SummaryMessage",
"description": "A message representing a summary of the conversation. Sent to the LLM as a user or system message depending on the provider."
},
"SupervisorManager": {
"properties": {
"manager_type": {
@@ -36735,6 +36973,12 @@
},
{
"$ref": "#/components/schemas/ApprovalResponseMessage"
},
{
"$ref": "#/components/schemas/SummaryMessage"
},
{
"$ref": "#/components/schemas/EventMessage"
}
],
"discriminator": {
@@ -36748,7 +36992,9 @@
"tool_return_message": "#/components/schemas/ToolReturnMessage",
"assistant_message": "#/components/schemas/AssistantMessage",
"approval_request_message": "#/components/schemas/ApprovalRequestMessage",
"approval_response_message": "#/components/schemas/ApprovalResponseMessage"
"approval_response_message": "#/components/schemas/ApprovalResponseMessage",
"summary": "#/components/schemas/SummaryMessage",
"event": "#/components/schemas/EventMessage"
}
}
},

View File

@@ -368,6 +368,25 @@ class LettaPing(LettaMessage):
)
class SummaryMessage(LettaMessage):
"""
A message representing a summary of the conversation. Sent to the LLM as a user or system message depending on the provider.
"""
message_type: Literal["summary"] = "summary_message"
summary: str
class EventMessage(LettaMessage):
"""
A message for notifying the developer that an event that has occured (e.g. a compaction). Events are NOT part of the context window.
"""
message_type: Literal["event"] = "event_message"
event_type: Literal["compaction"]
event_data: dict
# NOTE: use Pydantic's discriminated unions feature: https://docs.pydantic.dev/latest/concepts/unions/#discriminated-unions
LettaMessageUnion = Annotated[
Union[
@@ -380,6 +399,8 @@ LettaMessageUnion = Annotated[
AssistantMessage,
ApprovalRequestMessage,
ApprovalResponseMessage,
SummaryMessage,
EventMessage,
],
Field(discriminator="message_type"),
]
@@ -397,6 +418,8 @@ def create_letta_message_union_schema():
{"$ref": "#/components/schemas/AssistantMessage"},
{"$ref": "#/components/schemas/ApprovalRequestMessage"},
{"$ref": "#/components/schemas/ApprovalResponseMessage"},
{"$ref": "#/components/schemas/SummaryMessage"},
{"$ref": "#/components/schemas/EventMessage"},
],
"discriminator": {
"propertyName": "message_type",
@@ -410,6 +433,8 @@ def create_letta_message_union_schema():
"assistant_message": "#/components/schemas/AssistantMessage",
"approval_request_message": "#/components/schemas/ApprovalRequestMessage",
"approval_response_message": "#/components/schemas/ApprovalResponseMessage",
"summary": "#/components/schemas/SummaryMessage",
"event": "#/components/schemas/EventMessage",
},
},
}