https://retellai.com/?utm_source=discord&utm_medium=seo logo
The agent sometimes repeats itself when hanging up...
# ❓・ai-evy-support
a
Thanks for tagging me @carlo_98907. I'll look through relevant sources and get back to you shortly.
### Answer Based on the available sources, this is a known issue where agents repeat themselves, particularly when using custom LLMs and tool calls [(1) ]() . One community member shared a potential solution for custom LLM implementations . They identified that the issue occurs when yielding a message in function calls that matches function schema arguments . Their fix involves: 1. Adding the yielded message to the prompt manually in the
prepare_prompt
method after yielding a
func_result
object 2. Checking before streaming the agent response whether the previous function call was the problematic one 3. Verifying if the message before it is an assistant message with the exact message yielded in the function call 4. If conditions match, preventing the loop from yielding a response
Copy code
python
if chunk.choices[0].delta.content:
                output += chunk.choices[0].delta.content
                if '*' in chunk.choices[0].delta.content:
                    chunk.choices[0].delta.content = chunk.choices[0].delta.content.replace('*', '')
                
                if not should_stay_quite(prompt) :
                    response = ResponseResponse(
                        response_id=request.response_id,
                        content=chunk.choices[0].delta.content,
                        content_complete=False,
                        end_call=False,
                    )
                    yield response
Another case mentioned that repetition issues can sometimes be resolved by switching from custom voices to default voices, as it might be related to temporary voice provider outages [(2) ]() . If you're experiencing this with the built-in Retell LLM rather than a custom implementation, I'd recommend reaching out to support for further assistance.
​ To learn more, see the sources I considered: [[1] LLM repeating itself](https://discord.com/channels/1186424376300679209/1236379563353968681) [[2] Agent_error](https://discord.com/channels/1186424376300679209/1423757670933987489) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.