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.

use LLMError instead of ValueError (#5389)

Ari Webb1d3e2d14d6b1
diff --git a/letta/agents/letta_agent_v2.py b/letta/agents/letta_agent_v2.py
index 0070dee14..bddf96cf6 100644
--- a/letta/agents/letta_agent_v2.py
+++ b/letta/agents/letta_agent_v2.py
@@ -470,7 +470,7 @@ class LettaAgentV2(BaseAgentV2):
# Handle the AI response with the extracted data
if tool_call is None and llm_adapter.tool_call is None:
self.stop_reason = LettaStopReason(stop_reason=StopReasonType.no_tool_call.value)
- raise ValueError("No tool calls found in response, model must make a tool call")
+ raise LLMError("No tool calls found in response, model must make a tool call")
# TODO: how should be associate input messages with runs?
## Set run_id on input messages before persisting
diff --git a/tests/integration_test_send_message.py b/tests/integration_test_send_message.py
index 2380bda04..fce27cfcf 100644
--- a/tests/integration_test_send_message.py
+++ b/tests/integration_test_send_message.py
@@ -31,6 +31,7 @@ from letta_client.types import (
UserMessage,
)
+from letta.errors import LLMError
from letta.helpers.reasoning_helper import is_reasoning_completely_disabled
from letta.llm_api.openai_client import is_openai_reasoning_model
from letta.log import get_logger
@@ -1018,7 +1019,7 @@ def test_agent_loop_error(
agent_state = client.agents.modify(agent_id=agent_state.id, llm_config=llm_config)
with patch("letta.agents.letta_agent_v2.LettaAgentV2.step") as mock_step:
- mock_step.side_effect = ValueError("No tool calls found in response, model must make a tool call")
+ mock_step.side_effect = LLMError("No tool calls found in response, model must make a tool call")
with pytest.raises(ApiError):
client.agents.messages.create(