Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

fix: revert conditional tool return message creation (#1930)

cthomas22d72ca7131d
diff --git a/letta/server/rest_api/utils.py b/letta/server/rest_api/utils.py
index a6e449eb8..40471eab5 100644
--- a/letta/server/rest_api/utils.py
+++ b/letta/server/rest_api/utils.py
@@ -210,20 +210,20 @@ def create_letta_messages_from_llm_response(
# TODO: Use ToolReturnContent instead of TextContent
# TODO: This helps preserve ordering
- if function_response:
- tool_message = Message(
- role=MessageRole.tool,
- content=[TextContent(text=package_function_response(function_call_success, function_response))],
- organization_id=actor.organization_id,
- agent_id=agent_id,
- model=model,
- tool_calls=[],
- tool_call_id=tool_call_id,
- created_at=get_utc_time(),
- )
- if pre_computed_tool_message_id:
- tool_message.id = pre_computed_tool_message_id
- messages.append(tool_message)
+ tool_message = Message(
+ role=MessageRole.tool,
+ content=[TextContent(text=package_function_response(function_call_success, function_response))],
+ organization_id=actor.organization_id,
+ agent_id=agent_id,
+ model=model,
+ tool_calls=[],
+ tool_call_id=tool_call_id,
+ created_at=get_utc_time(),
+ name=function_name,
+ )
+ if pre_computed_tool_message_id:
+ tool_message.id = pre_computed_tool_message_id
+ messages.append(tool_message)
if add_heartbeat_request_system_message:
heartbeat_system_message = create_heartbeat_system_message(
diff --git a/tests/integration_test_chat_completions.py b/tests/integration_test_chat_completions.py
index 3c8a39839..46c555819 100644
--- a/tests/integration_test_chat_completions.py
+++ b/tests/integration_test_chat_completions.py
@@ -196,13 +196,15 @@ async def test_multiple_messages(disable_e2b_api_key, client, agent, endpoint):
stream = await async_client.chat.completions.create(**request.model_dump(exclude_none=True))
async with stream:
async for chunk in stream:
- print(chunk)
+ if chunk.choices and chunk.choices[0].delta.content:
+ print(chunk.choices[0].delta.content)
print("============================================")
request = _get_chat_request("What are you up to?")
stream = await async_client.chat.completions.create(**request.model_dump(exclude_none=True))
async with stream:
async for chunk in stream:
- print(chunk)
+ if chunk.choices and chunk.choices[0].delta.content:
+ print(chunk.choices[0].delta.content)
@pytest.mark.asyncio