How do I stop an agent responding to the last message incorrectly when I route back to them?
I'm trying to create a multi-agent setup. My first agent, which is used at start of chat, can answer KB questions and also perform a property search for the user based on asking them location questions. If a search is performed, I have the agent exit and pass to a flow that uses custom message steps to render the property information exactly how we want. At the end of these I want to pass back to the original agent so it can pick up the conversation again.
However, every time it goes back to the original agent, that agent decides it needs to perform a search for that particular property either using the API or the KB and tries to give information on that, which it can't do. It shouldn't be doing this as that has already been done in the conversation by my custom steps. How do I handle this? It should effectively be coming back to the original agent "fresh", where it can just ask if there's anything else it can do. Do I need to manually clear out some variables that it might be picking up?
This is effectively what happens (a little simplified but demos the issue):
General / Search Agent: Hello! I'm able to answer your general queries and look up properties based on your location. How can I help?
User: Can you find me properties in [location]?
General / Search Agent: Sure! Let me look for you
[General / Search Agent uses API tool and exits via Found Property path]
Custom Message: We've found this for you. This property X at Y, here are some further details....
[Routes now back to General / Search Agent as part of flow]
General / Search Agent: I can't find any specific details about X, but I can answer your general queries and look up properties based on your location. How can I help?
3 Replies
I will say in reality it does need to be more complex than this, I will have a General Agent and a Property Info agent that can answer questions on the specific property, that should pass back to the General Agent to answer general / search queries. However I hit upon this issue so I started simplifying to identify where the problem was, and right now I just have the General Agent and "dumb" message steps for the display.
Do I need to update my General / Search Agent prompt with further info on how to react based on how it was routed to, or conversation history?
if i understand your post correctly, you may be running into the same thing i did earlier, where the original agent is taking X from conversation history and reacting to that. for me, the key was to manually wipe conversation history, both _memory_ and vf_memory, before reentering that agent step. i also was wiping other variables that were populated by that agent step, as i needed it to re-collect them "fresh"
if you do decide you want to wipe _memory_ , then the bottom of this thread shows how i am doing it (huge thanks to @W. Williams (SFT) for the solution!) https://discord.com/channels/1079548823610871889/1415032139803656325/1415032139803656325
That's great, thank you! I did have some success telling it to ignore previous message if it was being routed to, but I suspect this will come in handy too