From 4428986a4914b2320aa1c7fd36ab61a0285a2380 Mon Sep 17 00:00:00 2001
From: dalagadenilesh <nileshdalagade88@gmail.com>
Date: Fri, 13 Feb 2026 17:50:47 +0530
Subject: [PATCH 1/3] fix: correct include_contents behavior in ADK web (fixes
 google#3535)

---
 src/google/adk/flows/llm_flows/contents.py | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/google/adk/flows/llm_flows/contents.py b/src/google/adk/flows/llm_flows/contents.py
index 4c3bed8991..4a949dc1c2 100644
--- a/src/google/adk/flows/llm_flows/contents.py
+++ b/src/google/adk/flows/llm_flows/contents.py
@@ -558,8 +558,9 @@ def _get_current_turn_contents(
   # Find the latest event that starts the current turn and process from there
   for i in range(len(events) - 1, -1, -1):
     event = events[i]
-    if _should_include_event_in_context(current_branch, event) and (
-        event.author == 'user' or _is_other_agent_reply(agent_name, event)
+    if (_should_include_event_in_context(current_branch, event)
+        and (event.author == "user" or _is_other_agent_reply(agent_name, event))
+        and not _is_direct_transfer(event)
     ):
       return _get_contents(
           current_branch,
@@ -571,6 +572,18 @@ def _get_current_turn_contents(
   return []
 
 
+def _is_direct_transfer(event : Event) -> bool:
+  "Weather the event is direct transfer event"
+  return bool(
+    event.actions.transfer_to_agent 
+    or (
+      event.content.parts 
+      and event.content.parts[0].function_call 
+      and event.content.parts[0].function_call.name == 'transfer_to_agent'
+    )
+  )
+
+
 def _is_other_agent_reply(current_agent_name: str, event: Event) -> bool:
   """Whether the event is a reply from another agent."""
   return bool(

From cb7fedab0131bd2e03e29a11013708af0c97cd9f Mon Sep 17 00:00:00 2001
From: dalagadenilesh <nileshdalagade88@gmail.com>
Date: Fri, 13 Feb 2026 19:03:30 +0530
Subject: [PATCH 2/3] fix: resolve issue of transfer_to_agents with multi-parts

---
 src/google/adk/flows/llm_flows/contents.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/google/adk/flows/llm_flows/contents.py b/src/google/adk/flows/llm_flows/contents.py
index 4a949dc1c2..d0cc7e4c7e 100644
--- a/src/google/adk/flows/llm_flows/contents.py
+++ b/src/google/adk/flows/llm_flows/contents.py
@@ -578,8 +578,14 @@ def _is_direct_transfer(event : Event) -> bool:
     event.actions.transfer_to_agent 
     or (
       event.content.parts 
-      and event.content.parts[0].function_call 
-      and event.content.parts[0].function_call.name == 'transfer_to_agent'
+      or (
+          event.content
+          and event.content.parts
+          and any(
+              p.function_call and p.function_call.name == 'transfer_to_agent'
+              for p in event.content.parts
+          )
+      )
     )
   )
 

From 3fd08238d14f81ee339c72d517d72fd397bf276f Mon Sep 17 00:00:00 2001
From: dalagadenilesh <nileshdalagade88@gmail.com>
Date: Fri, 13 Feb 2026 19:35:41 +0530
Subject: [PATCH 3/3] fix: Resolving multi-part transfer_to_agent

---
 src/google/adk/flows/llm_flows/contents.py | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/src/google/adk/flows/llm_flows/contents.py b/src/google/adk/flows/llm_flows/contents.py
index d0cc7e4c7e..b9edc09ea2 100644
--- a/src/google/adk/flows/llm_flows/contents.py
+++ b/src/google/adk/flows/llm_flows/contents.py
@@ -573,18 +573,15 @@ def _get_current_turn_contents(
 
 
 def _is_direct_transfer(event : Event) -> bool:
-  "Weather the event is direct transfer event"
+  "Check whether the event is a direct transfer event."
+  
   return bool(
-    event.actions.transfer_to_agent 
+    event.actions.transfer_to_agent
     or (
-      event.content.parts 
-      or (
-          event.content
-          and event.content.parts
-          and any(
-              p.function_call and p.function_call.name == 'transfer_to_agent'
-              for p in event.content.parts
-          )
+      event.content.parts
+      and any(
+          p.function_call and p.function_call.name == 'transfer_to_agent'
+          for p in event.content.parts
       )
     )
   )
