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: pass llm_config to streaming interface for BYOK error tagging (#10204)

cthomas3cdecd8991c3
diff --git a/letta/adapters/simple_llm_stream_adapter.py b/letta/adapters/simple_llm_stream_adapter.py
index 4aba6b5d5..af6cf9e61 100644
--- a/letta/adapters/simple_llm_stream_adapter.py
+++ b/letta/adapters/simple_llm_stream_adapter.py
@@ -84,6 +84,7 @@ class SimpleLLMStreamAdapter(LettaLLMStreamAdapter):
requires_approval_tools=requires_approval_tools,
run_id=self.run_id,
step_id=step_id,
+ llm_config=self.llm_config,
)
elif self.llm_config.model_endpoint_type in [
ProviderType.openai,
diff --git a/letta/interfaces/anthropic_parallel_tool_call_streaming_interface.py b/letta/interfaces/anthropic_parallel_tool_call_streaming_interface.py
index bde3d6660..e9d4a5902 100644
--- a/letta/interfaces/anthropic_parallel_tool_call_streaming_interface.py
+++ b/letta/interfaces/anthropic_parallel_tool_call_streaming_interface.py
@@ -8,6 +8,7 @@ from typing import TYPE_CHECKING, Optional
if TYPE_CHECKING:
from opentelemetry.trace import Span
+ from letta.schemas.llm_config import LLMConfig
from letta.schemas.usage import LettaUsageStatistics
from anthropic import AsyncStream
@@ -79,10 +80,12 @@ class SimpleAnthropicStreamingInterface:
requires_approval_tools: list = [],
run_id: str | None = None,
step_id: str | None = None,
+ llm_config: "LLMConfig | None" = None,
):
self.json_parser: JSONParser = PydanticJSONParser()
self.run_id = run_id
self.step_id = step_id
+ self.llm_config = llm_config
# Premake IDs for database writes
self.letta_message_id = Message.generate_id()
@@ -284,7 +287,7 @@ class SimpleAnthropicStreamingInterface:
from letta.llm_api.anthropic_client import AnthropicClient
client = AnthropicClient()
- transformed_error = client.handle_llm_error(e)
+ transformed_error = client.handle_llm_error(e, llm_config=self.llm_config)
raise transformed_error
finally:
logger.info("AnthropicStreamingInterface: Stream processing complete.")
diff --git a/letta/llm_api/anthropic_client.py b/letta/llm_api/anthropic_client.py
index 46e6ea7c9..344c3000e 100644
--- a/letta/llm_api/anthropic_client.py
+++ b/letta/llm_api/anthropic_client.py
@@ -218,6 +218,7 @@ class AnthropicClient(LLMClientBase):
requires_approval_tools=[],
run_id=None,
step_id=None,
+ llm_config=llm_config,
)
# Get the streaming response
diff --git a/letta/services/summarizer/summarizer.py b/letta/services/summarizer/summarizer.py
index cd2cb5b19..d7945b824 100644
--- a/letta/services/summarizer/summarizer.py
+++ b/letta/services/summarizer/summarizer.py
@@ -835,6 +835,7 @@ async def _execute_summarizer_request(req_data: dict, req_messages_obj: list[Mes
requires_approval_tools=[],
run_id=None,
step_id=None,
+ llm_config=llm_config,
)
# AnthropicClient.stream_async sets request_data["stream"] = True internally.