diff --git a/letta/schemas/letta_request.py b/letta/schemas/letta_request.py index 123d817c..f1f8f450 100644 --- a/letta/schemas/letta_request.py +++ b/letta/schemas/letta_request.py @@ -11,6 +11,10 @@ class LettaRequest(BaseModel): # Flags to support the use of AssistantMessage message types + use_assistant_message: bool = Field( + default=True, + description="Whether the server should parse specific tool call arguments (default `send_message`) as `AssistantMessage` objects.", + ) assistant_message_tool_name: str = Field( default=DEFAULT_MESSAGE_TOOL, description="The name of the designated message tool.", diff --git a/letta/server/rest_api/routers/v1/agents.py b/letta/server/rest_api/routers/v1/agents.py index 96d29777..5ab19348 100644 --- a/letta/server/rest_api/routers/v1/agents.py +++ b/letta/server/rest_api/routers/v1/agents.py @@ -493,6 +493,7 @@ async def send_message( stream_steps=False, stream_tokens=False, # Support for AssistantMessage + use_assistant_message=request.use_assistant_message, assistant_message_tool_name=request.assistant_message_tool_name, assistant_message_tool_kwarg=request.assistant_message_tool_kwarg, ) @@ -638,6 +639,7 @@ async def send_message_to_agent( chat_completion_mode: bool = False, timestamp: Optional[datetime] = None, # Support for AssistantMessage + use_assistant_message: bool = True, assistant_message_tool_name: str = DEFAULT_MESSAGE_TOOL, assistant_message_tool_kwarg: str = DEFAULT_MESSAGE_TOOL_KWARG, ) -> Union[StreamingResponse, LettaResponse]: @@ -668,7 +670,7 @@ async def send_message_to_agent( stream_tokens = False # Create a new interface per request - letta_agent.interface = StreamingServerInterface() + letta_agent.interface = StreamingServerInterface(use_assistant_message) streaming_interface = letta_agent.interface if not isinstance(streaming_interface, StreamingServerInterface): raise ValueError(f"Agent has wrong type of interface: {type(streaming_interface)}")