Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3b1f2ae
fix: Fix broken agent graphs
selcukgun Jun 6, 2025
9abb841
fix: Forwards `__annotations__` to the fake func for FunctionTool ins…
Jacksunwei Jun 6, 2025
ebf7899
Merge branch 'main' into fix-agent-transfer-error-handling
calvingiles Jun 6, 2025
309a656
refactor: extract credentail key building logic to auth_config
seanzhougoogle Jun 6, 2025
a097811
chore: Removes `LlmAgent.examples` field, which was already abandoned…
Jacksunwei Jun 6, 2025
8488ff0
feat: save and last run threshold and use it in next run evaluation
google-genai-bot Jun 6, 2025
4942f19
chore: Remove duplicated `model_config` attribute in EvalMetric class
jsondai Jun 6, 2025
ef8ec81
Policy matching update
calvingiles Jun 7, 2025
be71208
chore: Adds apache headers for samples
Jacksunwei Jun 7, 2025
13f98c3
fix: Correct help text formatting for `adk deploy agent_engine`
hangfei Jun 9, 2025
3ae6ce1
docs: Update code example in tool declaration to reflect BigQuery art…
google-genai-bot Jun 9, 2025
f38c08b
feat: Add DeepWiki badge to README
takashikik Jun 9, 2025
cf5d701
fix: Remove display_name for non-Vertex file uploads
ystory Jun 9, 2025
bf47a8b
fix: hide new eval metric behind flag
abchang123 Jun 9, 2025
0882000
chore: Adds decorators to mark classes or fucntions as working_in_pro…
Jacksunwei Jun 10, 2025
fa110c2
chore: refine doc string of global_instruction
seanzhougoogle Jun 10, 2025
8e438f2
refactor: Extract out platform specific code like threading
google-genai-bot Jun 10, 2025
aaf1f9b
feat: Add support for display_name and description when deploying to …
yeesian Jun 10, 2025
484b33e
chore: add rag agent for testing
abchang123 Jun 10, 2025
77f44a4
refactor: remove the examples filed of LlmAgent which are no longer n…
seanzhougoogle Jun 10, 2025
6c999ca
feat: Introduce write protected mode to BigQuery tools
google-genai-bot Jun 10, 2025
a9b616b
Merge branch 'main' into fix-agent-transfer-error-handling
calvingiles Jun 11, 2025
d0d1865
Merge branch 'main' into feature/approval-mechanism
calvingiles Jun 11, 2025
e272c56
Merge branch 'fix-agent-transfer-error-handling' into feature/approva…
calvingiles Jun 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
[![Python Unit Tests](https://github.com/google/adk-python/actions/workflows/python-unit-tests.yml/badge.svg)](https://github.com/google/adk-python/actions/workflows/python-unit-tests.yml)
[![r/agentdevelopmentkit](https://img.shields.io/badge/Reddit-r%2Fagentdevelopmentkit-FF4500?style=flat&logo=reddit&logoColor=white)](https://www.reddit.com/r/agentdevelopmentkit/)
[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/google/adk-python)

<html>
<h2 align="center">
Expand Down
8 changes: 7 additions & 1 deletion contributing/samples/bigquery/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@
from google.adk.agents import llm_agent
from google.adk.tools.bigquery import BigQueryCredentialsConfig
from google.adk.tools.bigquery import BigQueryToolset
from google.adk.tools.bigquery.config import BigQueryToolConfig
from google.adk.tools.bigquery.config import WriteMode
import google.auth

RUN_WITH_ADC = False


tool_config = BigQueryToolConfig(write_mode=WriteMode.ALLOWED)

if RUN_WITH_ADC:
# Initialize the tools to use the application default credentials.
application_default_credentials, _ = google.auth.default()
Expand All @@ -37,7 +41,9 @@
client_secret=os.getenv("OAUTH_CLIENT_SECRET"),
)

bigquery_toolset = BigQueryToolset(credentials_config=credentials_config)
bigquery_toolset = BigQueryToolset(
credentials_config=credentials_config, bigquery_tool_config=tool_config
)

# The variable name `root_agent` determines what your root agent is for the
# debug CLI
Expand Down
14 changes: 14 additions & 0 deletions contributing/samples/integration_connector_euc_agent/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from . import agent
51 changes: 51 additions & 0 deletions contributing/samples/rag_agent/agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os

from dotenv import load_dotenv
from google.adk.agents import Agent
from google.adk.tools.retrieval.vertex_ai_rag_retrieval import VertexAiRagRetrieval
from vertexai.preview import rag

load_dotenv()

ask_vertex_retrieval = VertexAiRagRetrieval(
name="retrieve_rag_documentation",
description=(
"Use this tool to retrieve documentation and reference materials for"
" the question from the RAG corpus,"
),
rag_resources=[
rag.RagResource(
# please fill in your own rag corpus
# e.g. projects/123/locations/us-central1/ragCorpora/456
rag_corpus=os.environ.get("RAG_CORPUS"),
)
],
similarity_top_k=1,
vector_distance_threshold=0.6,
)

root_agent = Agent(
model="gemini-2.0-flash-001",
name="root_agent",
instruction=(
"You are an AI assistant with access to specialized corpus of"
" documents. Your role is to provide accurate and concise answers to"
" questions based on documents that are retrievable using"
" ask_vertex_retrieval."
),
tools=[ask_vertex_retrieval],
)
14 changes: 14 additions & 0 deletions contributing/samples/session_state_agent/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from . import agent
7 changes: 1 addition & 6 deletions src/google/adk/agents/llm_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class LlmAgent(BaseAgent):
global_instruction: Union[str, InstructionProvider] = ''
"""Instructions for all the agents in the entire agent tree.

global_instruction ONLY takes effect in root agent.
ONLY the global_instruction in root agent will take effect.

For example: use global_instruction to make all agents have a stable identity
or personality.
Expand Down Expand Up @@ -204,11 +204,6 @@ class LlmAgent(BaseAgent):
"""
# Advance features - End

# TODO: remove below fields after migration. - Start
# These fields are added back for easier migration.
examples: Optional[ExamplesUnion] = None
# TODO: remove above fields after migration. - End

# Callbacks - Start
before_model_callback: Optional[BeforeModelCallback] = None
"""Callback or list of callbacks to be called before calling the LLM.
Expand Down
9 changes: 7 additions & 2 deletions src/google/adk/approval/approval_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,13 @@ def register_tool_policy(cls, policy: FunctionToolPolicy):
"""
if policy.policy_name is None:
raise ValueError("Policy name cannot be None")
if policy not in cls.tool_policies:
cls.tool_policies.append(policy)
for existing_policy in cls.tool_policies:
if existing_policy.policy_name != policy.policy_name:
continue
if existing_policy.actions != policy.actions:
continue
return
cls.tool_policies.append(policy)

@classmethod
def get_tool_policies(cls, tool_name: str) -> list[FunctionToolPolicy]:
Expand Down
27 changes: 2 additions & 25 deletions src/google/adk/auth/auth_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def exchange_auth_token(

def parse_and_store_auth_response(self, state: State) -> None:

credential_key = self.get_credential_key()
credential_key = "temp:" + self.auth_config.get_credential_key()

state[credential_key] = self.auth_config.exchanged_auth_credential
if not isinstance(
Expand All @@ -130,7 +130,7 @@ def _validate(self) -> None:
raise ValueError("auth_scheme is empty.")

def get_auth_response(self, state: State) -> AuthCredential:
credential_key = self.get_credential_key()
credential_key = "temp:" + self.auth_config.get_credential_key()
return state.get(credential_key, None)

def generate_auth_request(self) -> AuthConfig:
Expand Down Expand Up @@ -192,29 +192,6 @@ def generate_auth_request(self) -> AuthConfig:
exchanged_auth_credential=exchanged_credential,
)

def get_credential_key(self) -> str:
"""Generates a unique key for the given auth scheme and credential."""
auth_scheme = self.auth_config.auth_scheme
auth_credential = self.auth_config.raw_auth_credential
if auth_scheme.model_extra:
auth_scheme = auth_scheme.model_copy(deep=True)
auth_scheme.model_extra.clear()
scheme_name = (
f"{auth_scheme.type_.name}_{hash(auth_scheme.model_dump_json())}"
if auth_scheme
else ""
)
if auth_credential.model_extra:
auth_credential = auth_credential.model_copy(deep=True)
auth_credential.model_extra.clear()
credential_name = (
f"{auth_credential.auth_type.value}_{hash(auth_credential.model_dump_json())}"
if auth_credential
else ""
)

return f"temp:adk_{scheme_name}_{credential_name}"

def generate_auth_uri(
self,
) -> AuthCredential:
Expand Down
30 changes: 30 additions & 0 deletions src/google/adk/auth/auth_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import annotations

from .auth_credential import AuthCredential
from .auth_credential import BaseModelWithConfig
from .auth_schemes import AuthScheme
Expand Down Expand Up @@ -43,6 +45,34 @@ class AuthConfig(BaseModelWithConfig):
this field to guide the user through the OAuth2 flow and fill auth response in
this field"""

def get_credential_key(self):
"""Generates a hash key based on auth_scheme and raw_auth_credential. This
hash key can be used to store / retrieve exchanged_auth_credential in a
credentials store.
"""
auth_scheme = self.auth_scheme

if auth_scheme.model_extra:
auth_scheme = auth_scheme.model_copy(deep=True)
auth_scheme.model_extra.clear()
scheme_name = (
f"{auth_scheme.type_.name}_{hash(auth_scheme.model_dump_json())}"
if auth_scheme
else ""
)

auth_credential = self.raw_auth_credential
if auth_credential.model_extra:
auth_credential = auth_credential.model_copy(deep=True)
auth_credential.model_extra.clear()
credential_name = (
f"{auth_credential.auth_type.value}_{hash(auth_credential.model_dump_json())}"
if auth_credential
else ""
)

return f"adk_{scheme_name}_{credential_name}"


class AuthToolArguments(BaseModelWithConfig):
"""the arguments for the special long running function tool that is used to
Expand Down
Loading