Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
feat: support filtering out approval messages for gemini (#2833)
cthomas694be7b13638
diff --git a/letta/agents/letta_agent_v2.py b/letta/agents/letta_agent_v2.pyindex 7d8b397cf..5d92da06f 100644--- a/letta/agents/letta_agent_v2.py+++ b/letta/agents/letta_agent_v2.py@@ -850,7 +850,7 @@ class LettaAgentV2(BaseAgentV2):tool_call_messages = create_letta_messages_from_llm_response(agent_id=agent_state.id,model=agent_state.llm_config.model,- function_name="",+ function_name=tool_call.function.name,function_arguments={},tool_execution_result=ToolExecutionResult(status="error"),tool_call_id=tool_call_id,diff --git a/letta/llm_api/google_vertex_client.py b/letta/llm_api/google_vertex_client.pyindex 62d93ee88..1958a241d 100644--- a/letta/llm_api/google_vertex_client.py+++ b/letta/llm_api/google_vertex_client.py@@ -272,7 +272,7 @@ class GoogleVertexClient(LLMClientBase):tool_names = []contents = self.add_dummy_model_messages(- [m.to_google_ai_dict() for m in messages],+ PydanticMessage.to_google_dicts_from_list(messages),)request_data = {diff --git a/letta/schemas/message.py b/letta/schemas/message.pyindex eadcbf41d..d66f3b70f 100644--- a/letta/schemas/message.py+++ b/letta/schemas/message.py@@ -1027,10 +1027,13 @@ class Message(BaseMessage):result = [m for m in result if m is not None]return result- def to_google_ai_dict(self, put_inner_thoughts_in_kwargs: bool = True) -> dict:+ def to_google_dict(self, put_inner_thoughts_in_kwargs: bool = True) -> dict | None:"""Go from Message class to Google AI REST message object"""+ if self.role == "approval" and self.tool_calls is None:+ return None+# type Content: https://ai.google.dev/api/rest/v1/Content / https://ai.google.dev/api/rest/v1beta/Content# parts[]: Part# role: str ('user' or 'model')@@ -1076,7 +1079,7 @@ class Message(BaseMessage):"parts": content_parts,}- elif self.role == "assistant":+ elif self.role == "assistant" or self.role == "approval":assert self.tool_calls is not None or text_content is not Nonegoogle_ai_message = {"role": "model", # NOTE: different@@ -1164,6 +1167,20 @@ class Message(BaseMessage):return google_ai_message+ @staticmethod+ def to_google_dicts_from_list(+ messages: List[Message],+ put_inner_thoughts_in_kwargs: bool = True,+ ):+ result = [+ m.to_google_dict(+ put_inner_thoughts_in_kwargs=put_inner_thoughts_in_kwargs,+ )+ for m in messages+ ]+ result = [m for m in result if m is not None]+ return result+@staticmethoddef generate_otid_from_id(message_id: str, index: int) -> str:"""