You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a agent that uses 'load_memory' to recall previous conversation. the 'load_memory' tool uses a arg 'query' to find relevent conversation. But multiple time the function call doesn't have any args.
root_agent=LlmAgent(
name="Supervisor",
model="gemini-2.0-flash",
description=(
"You are a supervisor agent that delegates survey modification tasks to other agents."
),
instruction=(
"You are a supervisor agent that delegates survey question modification tasks to other agents.""all queries are about survey discussed in the previous conversation.""use 'load_memory' with appropriate `query` when you want to access survey questions discussed in past conversation."
),
tools=[ask_query, load_memory],
)
session=session_service.create_session(
app_name=APP_NAME,
user_id=USER_ID,
session_id=SESSION_ID
)
news_list: list[str] = [
"What is the latest news in technology?",
"What are the top headlines in sports?",
...
]
session_service.append_event(session, Event(
invocation_id=SESSION_ID,
author="user",
content=Content(
parts=[
Part(
text=news
)
fornewsinnews_list
]
)
))
runner=Runner(
agent=root_agent,
app_name=APP_NAME,
session_service=session_service,
memory_service=memory_service
)
memory_service.add_session_to_memory(session)
on certain queries the load_memory gets successfully called with correct args. but sometime it doesn't
I am not sure if it's right way or not But I fixed this issue for myself by making query a required field in load_model declartion in file google/adk/tools/load_memory_tool.py:60
the updated class looks like:
class LoadMemoryTool(FunctionTool):
"""A tool that loads the memory for the current user."""
def __init__(self):
super().__init__(load_memory)
@override
def _get_declaration(self) -> types.FunctionDeclaration | None:
return types.FunctionDeclaration(
name=self.name,
description=self.description,
parameters=types.Schema(
type=types.Type.OBJECT,
properties={
'query': types.Schema(
type=types.Type.STRING,
)
},
required=['query'] // this makes the query mandatory field
),
)
@override
async def process_llm_request(
self,
*,
tool_context: ToolContext,
llm_request: LlmRequest,
) -> None:
await super().process_llm_request(
tool_context=tool_context, llm_request=llm_request
)
# Tell the model about the memory.
llm_request.append_instructions(["""
You have memory. You can use it to answer questions. If any questions need
you to look up the memory, you should call load_memory function with a query.
"""])
I have a agent that uses 'load_memory' to recall previous conversation. the 'load_memory' tool uses a arg 'query' to find relevent conversation. But multiple time the function call doesn't have any args.
on certain queries the load_memory gets successfully called with correct args. but sometime it doesn't
** successfull function call**:
** failed function call**:
How do i ensure that function call happens correctly or request again for correct function call?
The text was updated successfully, but these errors were encountered: