From 25e893da14935da26ebd4b371082a6ea5121c5f7 Mon Sep 17 00:00:00 2001 From: Cameron Pfiffer Date: Wed, 3 Sep 2025 13:44:12 -0700 Subject: [PATCH] fix: correct messages API method from send to create (#4299) Updated documentation examples to use the correct API method: - Changed groups.messages.send() to groups.messages.create() - Changed agents.messages.send() to agents.messages.create() - Updated parameter format to use messages array with role/content Fixes inconsistent API usage across documentation and examples. --- .../notebooks/Agentic RAG with Letta.ipynb | 103 +----------------- 1 file changed, 4 insertions(+), 99 deletions(-) diff --git a/examples/notebooks/Agentic RAG with Letta.ipynb b/examples/notebooks/Agentic RAG with Letta.ipynb index a52516e5..c6fcc69c 100644 --- a/examples/notebooks/Agentic RAG with Letta.ipynb +++ b/examples/notebooks/Agentic RAG with Letta.ipynb @@ -857,106 +857,11 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": null, "id": "b339b7b1-3198-4fd9-9a53-7940dcc20437", "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - " \n", - "
\n", - " \n", - "
\n", - "
FUNCTION CALL
\n", - "
tavily_search_results({
  \"query\": \"Who founded OpenAI\",
  \"request_heartbeat\"
: true
})
\n", - "
\n", - " \n", - "
\n", - "
FUNCTION RETURN
\n", - "
{
  \"status\": \"Failed\",
  \"message\"
: \"Error calling function tavily_search_results: module langchain_community.tools has no attribute TavilySearchAPIWrapper\",
  \"time\"
: \"2024-11-13 05:40:04 PM PST-0800\"
}
\n", - "
\n", - " \n", - "
\n", - "
INTERNAL MONOLOGUE
\n", - "
The search function seems to have encountered an error. Let's attempt to answer the user's question another way.
\n", - "
\n", - " \n", - "
\n", - "
FUNCTION CALL
\n", - "
send_message({
  \"message\": \"OpenAI was founded by Elon Musk, Sam Altman, Greg Brockman, Ilya Sutskever, John Schulman and Wojciech Zaremba in December 2015. However, please note that Elon Musk is no longer associated with the organization.\"
})
\n", - "
\n", - " \n", - "
\n", - "
FUNCTION RETURN
\n", - "
{
  \"status\": \"OK\",
  \"message\"
: \"None\",
  \"time\"
: \"2024-11-13 05:40:09 PM PST-0800\"
}
\n", - "
\n", - "
\n", - "
\n", - "
\n", - "
USAGE STATISTICS
\n", - "
{
  \"completion_tokens\": 120,
  \"prompt_tokens\": 4737,
  \"total_tokens\": 4857,
  \"step_count\": 2
}
\n", - "
\n", - "
\n", - " " - ], - "text/plain": [ - "LettaResponse(messages=[FunctionCallMessage(id='message-31269f23-f32a-4267-ac85-b4548c56a1dd', date=datetime.datetime(2024, 11, 14, 1, 40, 4, 928751, tzinfo=datetime.timezone.utc), message_type='function_call', function_call=FunctionCall(name='tavily_search_results', arguments='{\\n \"query\": \"Who founded OpenAI\",\\n \"request_heartbeat\": true\\n}', function_call_id='call_EMmwx5mNy2vEttk97GDMjYwy')), FunctionReturn(id='message-a1e13057-6244-44c8-8ee5-2e057e5bed2d', date=datetime.datetime(2024, 11, 14, 1, 40, 4, 931214, tzinfo=datetime.timezone.utc), message_type='function_return', function_return='{\\n \"status\": \"Failed\",\\n \"message\": \"Error calling function tavily_search_results: module langchain_community.tools has no attribute TavilySearchAPIWrapper\",\\n \"time\": \"2024-11-13 05:40:04 PM PST-0800\"\\n}', status='error', function_call_id='call_EMmwx5mNy2vEttk97GDMjYwy'), InternalMonologue(id='message-0cb514d9-0874-43e8-b537-6bfcceeb9875', date=datetime.datetime(2024, 11, 14, 1, 40, 9, 498385, tzinfo=datetime.timezone.utc), message_type='internal_monologue', internal_monologue=\"The search function seems to have encountered an error. Let's attempt to answer the user's question another way.\"), FunctionCallMessage(id='message-0cb514d9-0874-43e8-b537-6bfcceeb9875', date=datetime.datetime(2024, 11, 14, 1, 40, 9, 498385, tzinfo=datetime.timezone.utc), message_type='function_call', function_call=FunctionCall(name='send_message', arguments='{\\n \"message\": \"OpenAI was founded by Elon Musk, Sam Altman, Greg Brockman, Ilya Sutskever, John Schulman and Wojciech Zaremba in December 2015. However, please note that Elon Musk is no longer associated with the organization.\"\\n}', function_call_id='call_MiF3dvSF7ImLBoOOwugKpZLy')), FunctionReturn(id='message-2e27c5ce-574e-4135-8486-f586a42b020c', date=datetime.datetime(2024, 11, 14, 1, 40, 9, 499244, tzinfo=datetime.timezone.utc), message_type='function_return', function_return='{\\n \"status\": \"OK\",\\n \"message\": \"None\",\\n \"time\": \"2024-11-13 05:40:09 PM PST-0800\"\\n}', status='success', function_call_id='call_MiF3dvSF7ImLBoOOwugKpZLy')], usage=LettaUsageStatistics(completion_tokens=120, prompt_tokens=4737, total_tokens=4857, step_count=2))" - ] - }, - "execution_count": 37, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "response = client.agents.messages.send(\n", - " agent_id=agent_state.id, \n", - " messages=[\n", - " MessageCreate(\n", - " role=\"user\",\n", - " content=\"Who founded OpenAI?\",\n", - " )\n", - " ],\n", - ")\n", - "response" - ] + "outputs": [], + "source": "response = client.agents.messages.create(\n agent_id=agent_state.id, \n messages=[\n MessageCreate(\n role=\"user\",\n content=\"Who founded OpenAI?\",\n )\n ],\n)\nresponse" } ], "metadata": { @@ -980,4 +885,4 @@ }, "nbformat": 4, "nbformat_minor": 5 -} +} \ No newline at end of file