Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
fix: patch the streaming issue in the openai client for when inner_thoughts_in_kwargs is off [LET-4146] (#4350)
Charles Packere3eb59835366
diff --git a/letta/agents/letta_agent.py b/letta/agents/letta_agent.pyindex 49a50cb1d..a5b4d4ec7 100644--- a/letta/agents/letta_agent.py+++ b/letta/agents/letta_agent.py@@ -1021,6 +1021,7 @@ class LettaAgent(BaseAgent):is_openai_proxy=agent_state.llm_config.provider_name == "lmstudio_openai",messages=current_in_context_messages + new_in_context_messages,tools=request_data.get("tools", []),+ put_inner_thoughts_in_kwarg=agent_state.llm_config.put_inner_thoughts_in_kwargs,)else:raise ValueError(f"Streaming not supported for {agent_state.llm_config}")diff --git a/letta/interfaces/openai_streaming_interface.py b/letta/interfaces/openai_streaming_interface.pyindex 08f23e0fa..8a4d968fc 100644--- a/letta/interfaces/openai_streaming_interface.py+++ b/letta/interfaces/openai_streaming_interface.py@@ -35,13 +35,14 @@ class OpenAIStreamingInterface:is_openai_proxy: bool = False,messages: Optional[list] = None,tools: Optional[list] = None,+ put_inner_thoughts_in_kwarg: bool = True,):self.use_assistant_message = use_assistant_messageself.assistant_message_tool_name = DEFAULT_MESSAGE_TOOLself.assistant_message_tool_kwarg = DEFAULT_MESSAGE_TOOL_KWARGself.optimistic_json_parser: OptimisticJSONParser = OptimisticJSONParser()- self.function_args_reader = JSONInnerThoughtsExtractor(wait_for_first_key=True) # TODO: pass in kwarg+ self.function_args_reader = JSONInnerThoughtsExtractor(wait_for_first_key=put_inner_thoughts_in_kwarg)self.function_name_buffer = Noneself.function_args_buffer = Noneself.function_id_buffer = None