Messages appear missing in content sent to model
Describe the bug
Some historical messages sent via agent engine stream_query does not appear in the content sent to the LLM. It is unclear what determines when a customer's message is included. This disrupts the continuity of the conversation.
To Reproduce This happens intermittently.
Code for send message:
from vertexai import agent_engines
remote_app: Union[AgentEngine, StreamQueryable] = agent_engines.get(
"687722532941332480"
)
def send_message(customer_id: str, session_id: str, message: str):
events = remote_app.stream_query(
user_id=customer_id,
session_id=session_id,
message=message,
)
return events
During the conversation where I observe the messages missing from the content, there were no agent transfer, it was a part of the conversation where the user was talking to one single agent. I have not looked at the branch related logic in ADK yet but this seems to be unexpected.
Expected behavior All messages sent via stream_query for us represents what user's messages to the bot, which is presented as a single entity, despite being implemented with a multi-agent system. I expect the agents to be able to see an uninterrupted sequence of conversation between the user and the bot.
Screenshots Unfortunately the conversation I am observing is confidential.
Additional Information
We use the following code to update the existing agent, and that seems to correlate with the timing of issues like these.
from vertexai import agent_engines
agent_engines.update
Here is an example of a broken conversation and the content passed to the LLM with gaps (in screen shot) that is causing this. The messages in the middle such as "july 20 to 29" are not in the content at all, which indicates that it is not a ordering issue.
User: I would like to start fresh, I want a trip to chicago
Sub-Agent: Okay, I can help you with that! To start, when are you planning to travel to Chicago and for how long?
User: july 20 to 29
Sub-Agent: Okay, I have memorized that you want to travel to Chicago from July 20 to 29. How many adults and children will be travelling? If children, please provide their ages.
User: 2, 1
Sub-Agent: Could you please clarify the dates you're planning to travel to Chicago? I need to know the month and day for both the start and end dates. For example, July 22 to July 29.
User: july 20 to 29
Sub-Agent: Okay, I have memorized that you want to travel to Chicago from July 20 to 29. How many adults and children will be travelling? If children, please provide their ages.
User: 2, 1 kid age 1
Sub-Agent: Now I need the dates for your trip and the year.
Hi @chen-kai-lin-ascend , can this issue be reproduced locally, or it is only happening when deployed to Agent Engine?
Hi @DeanChensj , This was happening when deployed to agent engine with 0.5.0, not locally. I am testing to see if I can reproduce it with 1.0.0.
Can confirm that this is happening in 1.0.0.
The case today does involve sub-agent transferring. I used a modified version of this sample: https://github.com/google/adk-samples/tree/main/python/agents/travel-concierge.
What I observed:
- I was talking to the inspiration agent and was transferred to the another sub-agent, at this point it can still see the conversation between the user and the inspiration agent.
- Later on there are more switching back and forth between the sub-agent and then a whole section of conversation disappeared from the content as LLM input.
During this time there was also a deployment.
Apologies for the lack of isolation of cause on this. I can do some more testing tomorrow.
@DeanChensj
Another observation is that the content stopped at a point that coincide with the 100th event in the session, and when I make this request:
events = session_service.api_client.request(
http_method="GET",
path=f"reasoningEngines/{REASONING_ENGINE_ID}/sessions/{8053118380703481856}/events",
request_dict={},
)
I only get 100 events. I suspect there is a cap on this api that likely backs the event that generates the content.
Thanks @chen-kai-lin-ascend , this is super helpful information, can confirm that this is because that we have a page size of 100. We will fix it on our end.