Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
ci: use experimental for send message tests (#2290)
cthomas012e1cab4d53
diff --git a/letta/agents/letta_agent.py b/letta/agents/letta_agent.pyindex 367605a80..3ec862b15 100644--- a/letta/agents/letta_agent.py+++ b/letta/agents/letta_agent.py@@ -132,7 +132,16 @@ class LettaAgent(BaseAgent):# TODO: make into a real errorraise ValueError("No tool calls found in response, model must make a tool call")tool_call = response.choices[0].message.tool_calls[0]- reasoning = [TextContent(text=response.choices[0].message.content)] # reasoning placed into content for legacy reasons+ if response.choices[0].message.reasoning_content:+ reasoning = [+ ReasoningContent(+ reasoning=response.choices[0].message.reasoning_content,+ is_native=True,+ signature=response.choices[0].message.reasoning_content_signature,+ )+ ]+ else:+ reasoning = [TextContent(text=response.choices[0].message.content)] # reasoning placed into content for legacy reasonspersisted_messages, should_continue = await self._handle_ai_response(tool_call, agent_state, tool_rules_solver, response.usage, reasoning_content=reasoning@@ -230,7 +239,16 @@ class LettaAgent(BaseAgent):# TODO: make into a real errorraise ValueError("No tool calls found in response, model must make a tool call")tool_call = response.choices[0].message.tool_calls[0]- reasoning = [TextContent(text=response.choices[0].message.content)] # reasoning placed into content for legacy reasons+ if response.choices[0].message.reasoning_content:+ reasoning = [+ ReasoningContent(+ reasoning=response.choices[0].message.reasoning_content,+ is_native=True,+ signature=response.choices[0].message.reasoning_content_signature,+ )+ ]+ else:+ reasoning = [TextContent(text=response.choices[0].message.content)] # reasoning placed into content for legacy reasonspersisted_messages, should_continue = await self._handle_ai_response(tool_call, agent_state, tool_rules_solver, response.usage, reasoning_content=reasoning, step_id=step_iddiff --git a/letta/interfaces/openai_streaming_interface.py b/letta/interfaces/openai_streaming_interface.pyindex 3d1fabe5d..eea1b3b2c 100644--- a/letta/interfaces/openai_streaming_interface.py+++ b/letta/interfaces/openai_streaming_interface.py@@ -78,8 +78,8 @@ class OpenAIStreamingInterface:# track usageif chunk.usage:- self.input_tokens += len(chunk.usage.prompt_tokens)- self.output_tokens += len(chunk.usage.completion_tokens)+ self.input_tokens += chunk.usage.prompt_tokens+ self.output_tokens += chunk.usage.completion_tokensif chunk.choices:choice = chunk.choices[0]diff --git a/letta/llm_api/openai_client.py b/letta/llm_api/openai_client.pyindex 639a550d9..e6ac37a22 100644--- a/letta/llm_api/openai_client.py+++ b/letta/llm_api/openai_client.py@@ -261,7 +261,9 @@ class OpenAIClient(LLMClientBase):Performs underlying asynchronous streaming request to OpenAI and returns the async stream iterator."""client = AsyncOpenAI(**self._prepare_client_kwargs(llm_config))- response_stream: AsyncStream[ChatCompletionChunk] = await client.chat.completions.create(**request_data, stream=True)+ response_stream: AsyncStream[ChatCompletionChunk] = await client.chat.completions.create(+ **request_data, stream=True, stream_options={"include_usage": True}+ )return response_streamdef handle_llm_error(self, e: Exception) -> Exception: