Skip to content

Commit f0204a7

Browse files
authored
Merge branch 'main' into release/v1.31.0
2 parents 61cca7e + 48b7a64 commit f0204a7

18 files changed

Lines changed: 164 additions & 22 deletions

File tree

src/google/adk/agents/common_configs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class AgentRefConfig(BaseModel):
118118
my_custom_agent = LlmAgent(
119119
name="my_custom_agent",
120120
instruction="You are a helpful custom agent.",
121-
model="gemini-2.0-flash",
121+
model="gemini-2.5-flash",
122122
)
123123
```
124124

src/google/adk/agents/config_schemas/AgentConfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2461,7 +2461,7 @@
24612461
}
24622462
],
24632463
"default": null,
2464-
"description": "Optional. LlmAgent.model. Provide a model name string (e.g. \"gemini-2.0-flash\"). If not set, the model will be inherited from the ancestor or fall back to the system default (gemini-2.5-flash unless overridden via LlmAgent.set_default_model). To construct a model instance from code, use model_code.",
2464+
"description": "Optional. LlmAgent.model. Provide a model name string (e.g. \"gemini-2.5-flash\"). If not set, the model will be inherited from the ancestor or fall back to the system default (gemini-2.5-flash unless overridden via LlmAgent.set_default_model). To construct a model instance from code, use model_code.",
24652465
"title": "Model"
24662466
},
24672467
"instruction": {

src/google/adk/agents/llm_agent_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class LlmAgentConfig(BaseAgentConfig):
5555
default=None,
5656
description=(
5757
'Optional. LlmAgent.model. Provide a model name string (e.g.'
58-
' "gemini-2.0-flash"). If not set, the model will be inherited from'
58+
' "gemini-2.5-flash"). If not set, the model will be inherited from'
5959
' the ancestor or fall back to the system default (gemini-2.5-flash'
6060
' unless overridden via LlmAgent.set_default_model). To construct a'
6161
' model instance from code, use model_code.'

src/google/adk/flows/llm_flows/base_llm_flow.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -720,19 +720,21 @@ async def _receive_from_model(
720720
) -> AsyncGenerator[Event, None]:
721721
"""Receive data from model and process events using BaseLlmConnection."""
722722

723-
def get_author_for_event(llm_response):
723+
def get_author_for_event(llm_response: LlmResponse) -> str:
724724
"""Get the author of the event.
725725
726-
When the model returns transcription, the author is "user". Otherwise, the
727-
author is the agent name(not 'model').
726+
When the model returns input transcription, the author is set to "user".
727+
Otherwise, the author is the agent name (not 'model').
728728
729729
Args:
730730
llm_response: The LLM response from the LLM call.
731+
732+
Returns:
733+
The author of the event as a string, either "user" or the agent's name.
731734
"""
732-
if (
733-
llm_response
734-
and llm_response.content
735-
and llm_response.content.role == 'user'
735+
if llm_response and (
736+
llm_response.input_transcription
737+
or (llm_response.content and llm_response.content.role == 'user')
736738
):
737739
return 'user'
738740
else:

src/google/adk/flows/llm_flows/contents.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,28 @@ def _get_current_turn_contents(
572572

573573
def _is_other_agent_reply(current_agent_name: str, event: Event) -> bool:
574574
"""Whether the event is a reply from another agent."""
575+
# In live/bidi mode, all events from any agents, including the current
576+
# agent, will be marked as other agent's reply. When agent transfers,
577+
# the conversation history will be sent to the Live API. If the current
578+
# agent previously used `transfer_to_agent` to transfer to another agent,
579+
# when the conversation is sent back to the current agent, the history will
580+
# contain a `transfer_to_agent` function call event from the current agent.
581+
# The Live API marks anything after the function response as model response.
582+
# This will confuse the model and cause the model to not respond.
583+
#
584+
# E.g. when the conversation is transferred from agent A to agent B, then
585+
# back to agent A, the history in the last transfer will be:
586+
# User: "Some message that triggers transfer to agent B"
587+
# Model: transfer_to_agent(B)
588+
# User: transfer_to_agent(B) response
589+
# User: "Some message that triggers transfer to agent A"
590+
# User: "For context: [agent B] called transfer_to_agent(A)"
591+
# User: "For context: [agent B] tool transfer_to_agent(A) returned result:"
592+
#
593+
# In this case, the last three events are marked as model response by the
594+
# Live API, instead of user input.
595+
if event.live_session_id:
596+
return event.author != 'user'
575597
return bool(
576598
current_agent_name
577599
and event.author != current_agent_name

src/google/adk/tools/mcp_tool/mcp_toolset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class McpToolset(BaseToolset):
8282
8383
# Use in an agent
8484
agent = LlmAgent(
85-
model='gemini-2.0-flash',
85+
model='gemini-2.5-flash',
8686
name='enterprise_assistant',
8787
instruction='Help user accessing their file systems',
8888
tools=[toolset],

src/google/adk/tools/skill_toolset.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ async def run_async(
165165
agent_name = tool_context.agent_name
166166
state_key = f"_adk_activated_skill_{agent_name}"
167167

168-
activated_skills = list(tool_context.state.get(state_key, []))
168+
activated_skills = list(tool_context.state.get(state_key) or [])
169169
if skill_name not in activated_skills:
170170
activated_skills.append(skill_name)
171171
tool_context.state[state_key] = activated_skills
@@ -732,7 +732,6 @@ async def run_async(
732732
"error_code": "SKILL_NOT_FOUND",
733733
}
734734

735-
script = None
736735
if file_path.startswith("scripts/"):
737736
script = skill.resources.get_script(file_path[len("scripts/") :])
738737
else:
@@ -845,7 +844,7 @@ async def _resolve_additional_tools_from_state(
845844

846845
agent_name = readonly_context.agent_name
847846
state_key = f"_adk_activated_skill_{agent_name}"
848-
activated_skills = readonly_context.state.get(state_key, [])
847+
activated_skills = readonly_context.state.get(state_key) or []
849848

850849
if not activated_skills:
851850
return []

src/google/adk/utils/instructions_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ async def build_instruction(
5151
)
5252
5353
agent = Agent(
54-
model="gemini-2.0-flash",
54+
model="gemini-2.5-flash",
5555
name="agent",
5656
instruction=build_instruction,
5757
)

src/google/adk/utils/model_name_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def extract_model_name(model_string: str) -> str:
4141
4242
Args:
4343
model_string: Either a simple model name like "gemini-2.5-pro" or a
44-
path-based model name like "projects/.../models/gemini-2.0-flash-001"
44+
path-based model name like "projects/.../models/gemini-2.5-flash"
4545
4646
Returns:
4747
The extracted model name (e.g., "gemini-2.5-pro")

tests/integration/fixture/ecommerce_customer_service_agent/agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ def get_user_id_from_cookie() -> str:
288288

289289

290290
root_agent = Agent(
291-
model="gemini-2.0-flash-001",
291+
model="gemini-2.5-flash",
292292
name="Ecommerce_Customer_Service",
293293
instruction="""
294294
You are an intelligent customer service assistant for an e-commerce platform. Your goal is to accurately understand user queries and use the appropriate tools to fulfill requests. Follow these guidelines:

0 commit comments

Comments
 (0)