fix: remove duplicate provider trace logging and dead code (#9278)
Provider traces were being created twice per step: 1. Via `request_async_with_telemetry` / `log_provider_trace_async` in LLMClient 2. Via direct `create_provider_trace_async` calls in LettaAgent This caused duplicate records in provider_trace_metadata (Postgres) and llm_traces (ClickHouse) for every agent step. Changes: - Remove redundant direct `create_provider_trace_async` calls from letta_agent.py - Remove no-op `stream_async_with_telemetry` method (was just a pass-through to `stream_async`) - Update callers to use `stream_async` directly 🤖 Generated with [Letta Code](https://letta.com) Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
@@ -1490,7 +1490,7 @@ class LettaAgent(BaseAgent):
|
||||
# Attempt LLM request with telemetry wrapper
|
||||
return (
|
||||
request_data,
|
||||
await llm_client.stream_async_with_telemetry(request_data, agent_state.llm_config),
|
||||
await llm_client.stream_async(request_data, agent_state.llm_config),
|
||||
current_in_context_messages,
|
||||
new_in_context_messages,
|
||||
valid_tool_names,
|
||||
|
||||
@@ -127,14 +127,6 @@ class LLMClientBase:
|
||||
except Exception as e:
|
||||
logger.warning(f"Failed to log telemetry: {e}")
|
||||
|
||||
async def stream_async_with_telemetry(self, request_data: dict, llm_config: LLMConfig):
|
||||
"""Returns raw stream. Caller should log telemetry after processing via log_provider_trace_async().
|
||||
|
||||
Call set_telemetry_context() first to set agent_id, run_id, etc.
|
||||
After consuming the stream, call log_provider_trace_async() with the response data.
|
||||
"""
|
||||
return await self.stream_async(request_data, llm_config)
|
||||
|
||||
async def log_provider_trace_async(
|
||||
self,
|
||||
request_data: dict,
|
||||
|
||||
@@ -542,7 +542,7 @@ async def simple_summary(
|
||||
)
|
||||
|
||||
# AnthropicClient.stream_async sets request_data["stream"] = True internally.
|
||||
stream = await llm_client.stream_async_with_telemetry(req_data, summarizer_llm_config)
|
||||
stream = await llm_client.stream_async(req_data, summarizer_llm_config)
|
||||
async for _chunk in interface.process(stream):
|
||||
# We don't emit anything; we just want the fully-accumulated content.
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user