https://retellai.com/?utm_source=discord&utm_medium=seo logo
I am creating a multi_prompt AI agent that uses th...
# ❓・ai-evy-support
g
@AI Evy I am creating a multi_prompt AI agent that uses the Claude 4.5 Haiku LLM that speaks only in Spanish. It is meant to send an email that changes its formatting based on the {{previous_agent_state}} default system variable. I have the same agent in English and it works as expected. However, if I try to do the same thing with Spanish, the agent has a hard time assigning the correct value of {{previous_agent_state}} to the formatting variable I have.
a
Thanks for tagging me @Goopa Snoops. I'll look through relevant sources and get back to you shortly.
### Answer --- This sounds like a multilingual prompt handling issue. Based on community experience, when working with non-English languages in multi-prompt agents, keeping your prompts written in English while instructing the agent to respond in Spanish tends to work better. [(1) ]() The reasoning is that LLMs may have an easier time switching from English to other languages than vice versa, due to training data distribution. Recommended approach: 1. Write your state prompts and transition logic in English 2. Add an explicit instruction like: "Respond to the user in Spanish" 3. Include example responses in Spanish within your prompt For the
{{previous_agent_state}}
variable assignment specifically, ensure your transition descriptions and any conditional logic referencing this variable are written in English, even if the agent's spoken output is in Spanish. If state transitions are still unreliable, you can try adding explicit, high-priority language in your prompt to ensure the transition function is called, such as treating it as a "make-or-break" action that must not be skipped or delayed. [(2) ]() Check out these potentially useful sources: - [Single/Multi Prompt Agent Overview]() - [Update Retell LLM]() Would you like me to provide a general answer on multilingual prompt engineering techniques?
​ To learn more, see the sources I considered: [[1] Discord message from @kiexperten_60638 on 2025-05-05](https://discord.com/channels/1186424376300679209/1294891368505937952/1368883583053201518) [[2] Multi prompt agent not always transitioning to the next state](https://discord.com/channels/1186424376300679209/1303504848196472893) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
g
@AI Evy It is responding as expected, but when it comes to assigning the correct value of {{previous_state_agent}} to the formatting variable I have in my tool to send emails. The tool call shows the wrong previous state.
a
Thanks for the follow-up, @Goopa Snoops. I'll get back to you soon.
### Answer --- The issue you're describing—where
{{previous_agent_state}}
is passing the wrong value to your email formatting tool—is likely related to how state transitions are being triggered and tracked in your multi-prompt agent. A few things to consider: 1. State transition reliability Multi-prompt agents can sometimes have inconsistent state transitions, especially if the transition logic isn't explicitly emphasized in the prompt. Community experience suggests adding high-priority, explicit language to ensure the transition function is called reliably. For example, treating the transition as a "make-or-break" action that must not be skipped or delayed can help. [(1) ]() 2. Tool call timing If your email tool is being called before the state transition completes, the
{{previous_agent_state}}
variable may still reflect an older state. Ensure that the state transition happens before the tool is invoked by structuring your prompt to confirm the transition first, then call the tool. 3. Prompt structure In multi-prompt agents, each state has its own
state_prompt
and
tools
, and transitions are defined via
edges
with
destination_state_name
and
description
. [(2) ]() Make sure your transition descriptions are clear and unambiguous so the LLM correctly identifies when to transition. 4. Language considerations Since you mentioned the English version works correctly, keep your transition logic and tool descriptions in English, even if the agent responds in Spanish. This can improve the LLM's ability to correctly interpret and execute state transitions and variable assignments. If the issue persists, I'd recommend testing with logging to verify exactly when the state transition occurs relative to when
your email tool is called. Check out these potentially useful sources: - [Single/Multi Prompt Agent Overview]() - [Create Retell LLM]() Would you like me to provide a general answer on debugging state transitions in multi-prompt agents?
​ To learn more, see the sources I considered: [[1] Multi prompt agent not always transitioning to the next state](https://discord.com/channels/1186424376300679209/1303504848196472893) [[2] Create Retell LLM](https://docs.retellai.com/api-references/create-retell-llm) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.