I am seeing duplicate traces in langfuse to the ll...
# agents
f
I am seeing duplicate traces in langfuse to the llm node. I have setup the tracer provider similar to this example. is anyone else also seeing something similar? what is the possible fix?
anyone?
r
I don't know why that would happen. We tried to reproduce this without luck. We used this example https://github.com/livekit/agents/blob/main/examples/voice_agents/langfuse_trace.py Can you provide steps you use to get into this state?
f
I figured the cause. This is happening when there is a LLMFallbackAdapter added. I works fine when I remove the fallback,. Below is how I am adding the fallback.
Copy code
session = AgentSession(
        llm=LLMFallbackAdapter(
            llm=[
                llm_manager.create_llm(provider=LLMProvider.OPENAI, model=LLMModel.GPT_4O),
                llm_manager.create_llm(provider=LLMProvider.GEMINI, model=LLMModel.GEMINI_2_5_FLASH),
            ]
        ),
fn create_llm
Copy code
def create_llm(
        self, provider: LLMProvider = None, model: LLMModel = None
    ) -> Union[google.LLM, openai.LLM]:
        """Create and return an LLM instance for use in agent sessions.

        Args:
            provider: LLM provider to use (defaults to environment variables)
            model: LLM model to use (defaults to environment variables)

        Returns:
            LLM instance for the specified provider and model
        """
        if provider is None or model is None:
            env_manager = create_llm_manager_from_env()
            provider = provider or env_manager.default_provider
            model = model or env_manager.default_model

        if provider == LLMProvider.GEMINI:
            return self._create_gemini_llm(model)
        elif provider == LLMProvider.OPENAI:
            logger.info(f"================= Creating OpenAI LLM instance with model: {model.value}")
            return self._create_openai_llm(model)
        else:
            raise ValueError(f"Unsupported LLM provider: {provider}")
I checked that it is adding duplicates in all the cases and not just the ones where fallback was invoked. What could be the possible resolution for this?
r
Let me check with the team on this. Glad you figured out how to reproduce.
🙏 1
Here is the PR to address the issue you reported: https://github.com/livekit/agents/pull/3934
f
Thanks for super quick fix. when can we plan to release this?