Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
chore: move ttft logging for new agent loop (#2465)
cthomas3c34253997c7
diff --git a/letta/agents/letta_agent.py b/letta/agents/letta_agent.pyindex fd9468785..062e800f2 100644--- a/letta/agents/letta_agent.py+++ b/letta/agents/letta_agent.py@@ -314,6 +314,10 @@ class LettaAgent(BaseAgent):actor=self.actor,)usage = LettaUsageStatistics()+ first_chunk, ttft_span = True, None+ if request_start_timestamp_ns is not None:+ ttft_span = tracer.start_span("time_to_first_token", start_time=request_start_timestamp_ns)+ ttft_span.set_attributes({f"llm_config.{k}": v for k, v in agent_state.llm_config.model_dump().items() if v is not None})for _ in range(max_steps):step_id = generate_step_id()@@ -354,11 +358,6 @@ class LettaAgent(BaseAgent):else:raise ValueError(f"Streaming not supported for {agent_state.llm_config}")- first_chunk, ttft_span = True, None- if request_start_timestamp_ns is not None:- ttft_span = tracer.start_span("time_to_first_token", start_time=request_start_timestamp_ns)- ttft_span.set_attributes({f"llm_config.{k}": v for k, v in agent_state.llm_config.model_dump().items() if v is not None})-async for chunk in interface.process(stream):# Measure time to first tokenif first_chunk and ttft_span is not None: