Hi @gebejaranod,
Welcome to Google Cloud Community!
I understand that you are trying to create a playbook wherein the conversational agent is forwarding the user’s query to an external API without enriching it with context from the ongoing conversation.
Here are some approaches that you can try to enhance the instruction prompt:
-
Ensure that the instruction prompt explicitly mentions analyzing the entire conversation history, not just the most recent message.
-
Include explicit patterns or examples of common references and how they should be resolved.
-
Fallback Mechanism: Before querying ${TOOL:general_tool}, confirm that the context replacement was successful. If the replacement is invalid or the tool returns an error or an empty response, provide a predefined fallback response, such as “I’m sorry, I couldn’t find an answer to your question using the available information.”
In addition, you may enhance the agent’s ability to handle implicit references by incorporating context-aware patterns. Include diverse examples in the prompt illustrating how to translate various common reference patterns (e.g., pronouns, relative quantifiers, temporal references like “last month,” elliptical constructions) into explicit, tool-ready queries. The more varied and comprehensive the examples, the better the agent’s performance will be.
Was this helpful? If so, please accept this answer as “Solution”. If you need additional assistance, reply here within 2 business days and I’ll be happy to help.