Skip to content

Commit 32500f4

Browse files
committed
Add disallowTransferToParent check to parent agent transfer condition
Only allow transfer to parent agent when both conditions are met: - Parent agent exists (agent.parentAgent() != null) - Transfer to parent is allowed (!agent.disallowTransferToParent()) This prevents unwanted transfers to parent agents when explicitly disabled. Aligns Java implementation with Python version for consistency.
1 parent 9e3723b commit 32500f4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

core/src/main/java/com/google/adk/flows/llmflows/AgentTransfer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ private String buildTargetAgentsInstructions(LlmAgent agent, List<BaseAgent> tra
8787
"If another agent is better for answering the question according to its description, call"
8888
+ " `transferToAgent` function to transfer the question to that agent. When"
8989
+ " transferring, do not generate any text other than the function call.\n");
90-
if (agent.parentAgent() != null) {
90+
if (agent.parentAgent() != null && !agent.disallowTransferToParent()) {
9191
sb.append("Your parent agent is ");
9292
sb.append(agent.parentAgent().name());
9393
sb.append(

0 commit comments

Comments
 (0)