Agent Executing Tool endlessly
Describe the bug I'm having a logic to insert json data into database and for some reason the agent is executing it again and again and never ending resulting in multiple duplicate entries in the DB.
Code Below
def create_record(transaction_log: dict) -> str:
"""
Creates a new record in the TrackerTable with the given transaction_log.
Returns a simple success message to prevent further processing.
"""
if not isinstance(transaction_log, dict):
return "Error: Invalid input format. Expected a dictionary."
print('entering insert tool')
try:
# Create the data dictionary with all required fields
data = {
"transaction_id": str(uuid.uuid4()),
"created_at": datetime.now().isoformat(),
"transaction_amount": transaction_log.get("transaction_amount"),
"transaction_category": transaction_log.get("transaction_category"),
"transaction_description": transaction_log.get("transaction_description"),
"transaction_status": transaction_log.get("transaction_status"),
"transaction_date": transaction_log.get("transaction_date")
}
# Insert into database
supabase.table("TrackerTable").insert(data).execute()
print('Successfully inserted record')
return "SUCCESS: Transaction recorded successfully. No further action needed."
except Exception as e:
error_msg = f"Error inserting record: {str(e)}"
print(error_msg)
return f"ERROR: {error_msg}"
insert_tool = FunctionTool(func=create_record)
database_updater_agent = LlmAgent(
name="database_updater_agent",
description="call create_record function through insert_tool to insert the transaction_log into the database.",
instruction="""
Use the transaction_log to call create_record via insert_tool.
After the tool returns a response, show that to the user exactly as-is.
Do NOT call any other tools again.
Do NOT repeat or re-enter the function.
Just return the tool result once and finish.
""",
model=LiteLlm(model="ollama/llama3.1:8b"),
tools=[insert_tool]
)
# Create the root agent
root_agent = SequentialAgent(
name="transaction_logger_agent",
sub_agents=[transaction_categorizer_agent, database_updater_agent],
description="A sequential agent that first categorizes transactions and then updates the database.",
)
This happened to me too just today!
I felt this was because I added include_contents=none but if that was not the case we have a big problem.
I was also using sequential agent!
I am using the 1.4.1 version, which one are you on @msbarathraj
@kanlanc , I'm using 1.4.2 Is it because of the sequential agent? Lemme try with normal agents and see how it works
@msbarathraj @kanlanc could you attach some logs of the agent, e.g. the output for adk web command, to help us debug the issue?
Am also facing the issue. I am using sequential agent with 3 tools. 2nd tool is async and its running multiple times. Causing response to delayed. Did we find any fix for this?
Version - 1.4.1
As documented here: https://google.github.io/adk-docs/agents/models/#using-ollama_chat-provider. To fix this behavior, the prefix ollama_chat should be used instead ollama. By example: ollama_chat/llama3.1:8b
I am facing the same issue too with gemini-2.0-flash and gemini-2.5-flash using the latest adk version
This should be fixed. Please retry with latest version. if you continue to see this, please re-open.