Skip to content

Commit 2062aa3

Browse files
authored
Merge branch 'main' into live-error-toast
2 parents db5ea6b + 5c069cc commit 2062aa3

File tree

12 files changed

+95
-37
lines changed

12 files changed

+95
-37
lines changed

CONTRIBUTING.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,22 @@ This project follows
2525

2626
## Contribution process
2727

28+
### Requirement for PRs
29+
30+
- All PRs, other than small documentation or typo fixes, should have a Issue assoicated. If not, please create one.
31+
- Small, focused PRs. Keep changes minimal—one concern per PR.
32+
- For bug fixes or features, please provide logs or screenshot after the fix is applied to help reviewers better understand the fix.
33+
- Please add corresponding testing for your code change if it's not covered by existing tests.
34+
35+
### Large or Complex Changes
36+
For substantial features or architectural revisions:
37+
38+
- Open an Issue First: Outline your proposal, including design considerations and impact.
39+
- Gather Feedback: Discuss with maintainers and the community to ensure alignment and avoid duplicate work
40+
2841
### Code reviews
2942

3043
All submissions, including submissions by project members, require review. We
3144
use GitHub pull requests for this purpose. Consult
3245
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
33-
information on using pull requests.
46+
information on using pull requests.

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,27 @@ debugging, versioning, and deployment anywhere – from your laptop to the cloud
4545

4646
## 🚀 Installation
4747

48-
You can install the ADK using `pip`:
48+
### Stable Release (Recommended)
49+
50+
You can install the latest stable version of ADK using `pip`:
4951

5052
```bash
5153
pip install google-adk
5254
```
5355

56+
The release cadence is weekly.
57+
58+
This version is recommended for most users as it represents the most recent official release.
59+
60+
### Development Version
61+
Bug fixes and new features are merged into the main branch on GitHub first. If you need access to changes that haven't been included in an official PyPI release yet, you can install directly from the main branch:
62+
63+
```bash
64+
pip install git+https://github.com/google/adk-python.git@main
65+
```
66+
67+
Note: The development version is built directly from the latest code commits. While it includes the newest fixes and features, it may also contain experimental changes or bugs not present in the stable release. Use it primarily for testing upcoming changes or accessing critical fixes before they are officially released.
68+
5469
## 📚 Documentation
5570

5671
Explore the full documentation for detailed guides on building, evaluating, and
@@ -121,7 +136,9 @@ for how they can work together.
121136

122137
## 🤝 Contributing
123138

124-
We welcome contributions from the community! Whether it's bug reports, feature requests, documentation improvements, or code contributions, please see our [**Contributing Guidelines**](./CONTRIBUTING.md) to get started.
139+
We welcome contributions from the community! Whether it's bug reports, feature requests, documentation improvements, or code contributions, please see our
140+
- [General contribution guideline and flow](https://google.github.io/adk-docs/contributing-guide/#questions).
141+
- Then if you want to contribute code, please read [Code Contributing Guidelines](./CONTRIBUTING.md) to get started.
125142

126143
## 📄 License
127144

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ dependencies = [
3333
"google-cloud-secret-manager>=2.22.0", # Fetching secrets in RestAPI Tool
3434
"google-cloud-speech>=2.30.0", # For Audo Transcription
3535
"google-cloud-storage>=2.18.0, <3.0.0", # For GCS Artifact service
36-
"google-genai>=1.9.0", # Google GenAI SDK
36+
"google-genai>=1.11.0", # Google GenAI SDK
3737
"graphviz>=0.20.2", # Graphviz for graph rendering
3838
"mcp>=1.5.0;python_version>='3.10'", # For MCP Toolset
3939
"opentelemetry-api>=1.31.0", # OpenTelemetry

src/google/adk/auth/auth_credential.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ class OAuth2Auth(BaseModelWithConfig):
6666
redirect_uri: Optional[str] = None
6767
auth_response_uri: Optional[str] = None
6868
auth_code: Optional[str] = None
69-
token: Optional[Dict[str, Any]] = None
69+
access_token: Optional[str] = None
70+
refresh_token: Optional[str] = None
7071

7172

7273
class ServiceAccountCredential(BaseModelWithConfig):

src/google/adk/auth/auth_handler.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ def exchange_auth_token(
8282
or not auth_credential.oauth2
8383
or not auth_credential.oauth2.client_id
8484
or not auth_credential.oauth2.client_secret
85-
or auth_credential.oauth2.token
85+
or auth_credential.oauth2.access_token
86+
or auth_credential.oauth2.refresh_token
8687
):
8788
return self.auth_config.exchanged_auth_credential
8889

@@ -93,7 +94,7 @@ def exchange_auth_token(
9394
redirect_uri=auth_credential.oauth2.redirect_uri,
9495
state=auth_credential.oauth2.state,
9596
)
96-
token = client.fetch_token(
97+
tokens = client.fetch_token(
9798
token_endpoint,
9899
authorization_response=auth_credential.oauth2.auth_response_uri,
99100
code=auth_credential.oauth2.auth_code,
@@ -102,7 +103,10 @@ def exchange_auth_token(
102103

103104
updated_credential = AuthCredential(
104105
auth_type=AuthCredentialTypes.OAUTH2,
105-
oauth2=OAuth2Auth(token=dict(token)),
106+
oauth2=OAuth2Auth(
107+
access_token=tokens.get("access_token"),
108+
refresh_token=tokens.get("refresh_token"),
109+
),
106110
)
107111
return updated_credential
108112

src/google/adk/cli/cli_deploy.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
5555
EXPOSE {port}
5656
57-
CMD adk {command} --port={port} {trace_to_cloud_option} "/app/agents"
57+
CMD adk {command} --port={port} {session_db_option} {trace_to_cloud_option} "/app/agents"
5858
"""
5959

6060

@@ -85,6 +85,7 @@ def to_cloud_run(
8585
trace_to_cloud: bool,
8686
with_ui: bool,
8787
verbosity: str,
88+
session_db_url: str,
8889
):
8990
"""Deploys an agent to Google Cloud Run.
9091
@@ -112,6 +113,7 @@ def to_cloud_run(
112113
trace_to_cloud: Whether to enable Cloud Trace.
113114
with_ui: Whether to deploy with UI.
114115
verbosity: The verbosity level of the CLI.
116+
session_db_url: The database URL to connect the session.
115117
"""
116118
app_name = app_name or os.path.basename(agent_folder)
117119

@@ -144,6 +146,9 @@ def to_cloud_run(
144146
port=port,
145147
command='web' if with_ui else 'api_server',
146148
install_agent_deps=install_agent_deps,
149+
session_db_option=f'--session_db_url={session_db_url}'
150+
if session_db_url
151+
else '',
147152
trace_to_cloud_option='--trace_to_cloud' if trace_to_cloud else '',
148153
)
149154
dockerfile_path = os.path.join(temp_folder, 'Dockerfile')

src/google/adk/cli/cli_tools_click.py

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,13 @@ def cli_eval(
245245
@click.option(
246246
"--session_db_url",
247247
help=(
248-
"Optional. The database URL to store the session.\n\n - Use"
249-
" 'agentengine://<agent_engine_resource_id>' to connect to Vertex"
250-
" managed session service.\n\n - Use 'sqlite://<path_to_sqlite_file>'"
251-
" to connect to a SQLite DB.\n\n - See"
252-
" https://docs.sqlalchemy.org/en/20/core/engines.html#backend-specific-urls"
253-
" for more details on supported DB URLs."
248+
"""Optional. The database URL to store the session.
249+
250+
- Use 'agentengine://<agent_engine_resource_id>' to connect to Agent Engine sessions.
251+
252+
- Use 'sqlite://<path_to_sqlite_file>' to connect to a SQLite DB.
253+
254+
- See https://docs.sqlalchemy.org/en/20/core/engines.html#backend-specific-urls for more details on supported DB URLs."""
254255
),
255256
)
256257
@click.option(
@@ -366,12 +367,13 @@ async def _lifespan(app: FastAPI):
366367
@click.option(
367368
"--session_db_url",
368369
help=(
369-
"Optional. The database URL to store the session.\n\n - Use"
370-
" 'agentengine://<agent_engine_resource_id>' to connect to Vertex"
371-
" managed session service.\n\n - Use 'sqlite://<path_to_sqlite_file>'"
372-
" to connect to a SQLite DB.\n\n - See"
373-
" https://docs.sqlalchemy.org/en/20/core/engines.html#backend-specific-urls"
374-
" for more details on supported DB URLs."
370+
"""Optional. The database URL to store the session.
371+
372+
- Use 'agentengine://<agent_engine_resource_id>' to connect to Agent Engine sessions.
373+
374+
- Use 'sqlite://<path_to_sqlite_file>' to connect to a SQLite DB.
375+
376+
- See https://docs.sqlalchemy.org/en/20/core/engines.html#backend-specific-urls for more details on supported DB URLs."""
375377
),
376378
)
377379
@click.option(
@@ -541,6 +543,18 @@ def cli_api_server(
541543
default="WARNING",
542544
help="Optional. Override the default verbosity level.",
543545
)
546+
@click.option(
547+
"--session_db_url",
548+
help=(
549+
"""Optional. The database URL to store the session.
550+
551+
- Use 'agentengine://<agent_engine_resource_id>' to connect to Agent Engine sessions.
552+
553+
- Use 'sqlite://<path_to_sqlite_file>' to connect to a SQLite DB.
554+
555+
- See https://docs.sqlalchemy.org/en/20/core/engines.html#backend-specific-urls for more details on supported DB URLs."""
556+
),
557+
)
544558
@click.argument(
545559
"agent",
546560
type=click.Path(
@@ -558,6 +572,7 @@ def cli_deploy_cloud_run(
558572
trace_to_cloud: bool,
559573
with_ui: bool,
560574
verbosity: str,
575+
session_db_url: str,
561576
):
562577
"""Deploys an agent to Cloud Run.
563578
@@ -579,6 +594,7 @@ def cli_deploy_cloud_run(
579594
trace_to_cloud=trace_to_cloud,
580595
with_ui=with_ui,
581596
verbosity=verbosity,
597+
session_db_url=session_db_url,
582598
)
583599
except Exception as e:
584600
click.secho(f"Deploy failed: {e}", fg="red", err=True)

src/google/adk/cli/fast_api.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,12 @@ async def process_messages():
756756
except Exception as e:
757757
logger.exception("Error during live websocket communication: %s", e)
758758
traceback.print_exc()
759+
WEBSOCKET_INTERNAL_ERROR_CODE = 1011
760+
WEBSOCKET_MAX_BYTES_FOR_REASON = 123
761+
await websocket.close(
762+
code=WEBSOCKET_INTERNAL_ERROR_CODE,
763+
reason=str(e)[:WEBSOCKET_MAX_BYTES_FOR_REASON],
764+
)
759765
finally:
760766
for task in pending:
761767
task.cancel()

src/google/adk/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def generate_auth_token(
6969
HTTP bearer token cannot be generated, return the original credential.
7070
"""
7171

72-
if "access_token" not in auth_credential.oauth2.token:
72+
if not auth_credential.oauth2.access_token:
7373
return auth_credential
7474

7575
# Return the access token as a bearer token.
@@ -78,7 +78,7 @@ def generate_auth_token(
7878
http=HttpAuth(
7979
scheme="bearer",
8080
credentials=HttpCredentials(
81-
token=auth_credential.oauth2.token["access_token"]
81+
token=auth_credential.oauth2.access_token
8282
),
8383
),
8484
)
@@ -111,7 +111,7 @@ def exchange_credential(
111111
return auth_credential
112112

113113
# If access token is exchanged, exchange a HTTPBearer token.
114-
if auth_credential.oauth2.token:
114+
if auth_credential.oauth2.access_token:
115115
return self.generate_auth_token(auth_credential)
116116

117117
return None

tests/unittests/auth/test_auth_handler.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,8 @@ def oauth2_credentials_with_token():
126126
client_id="mock_client_id",
127127
client_secret="mock_client_secret",
128128
redirect_uri="https://example.com/callback",
129-
token={
130-
"access_token": "mock_access_token",
131-
"token_type": "bearer",
132-
"expires_in": 3600,
133-
"refresh_token": "mock_refresh_token",
134-
},
129+
access_token="mock_access_token",
130+
refresh_token="mock_refresh_token",
135131
),
136132
)
137133

@@ -458,7 +454,7 @@ def test_oauth_scheme(self, mock_exchange_token, auth_config_with_exchanged):
458454
"""Test with an OAuth auth scheme."""
459455
mock_exchange_token.return_value = AuthCredential(
460456
auth_type=AuthCredentialTypes.OAUTH2,
461-
oauth2=OAuth2Auth(token={"access_token": "exchanged_token"}),
457+
oauth2=OAuth2Auth(access_token="exchanged_token"),
462458
)
463459

464460
handler = AuthHandler(auth_config_with_exchanged)
@@ -573,6 +569,6 @@ def test_successful_token_exchange(self, auth_config_with_auth_code):
573569
handler = AuthHandler(auth_config_with_auth_code)
574570
result = handler.exchange_auth_token()
575571

576-
assert result.oauth2.token["access_token"] == "mock_access_token"
577-
assert result.oauth2.token["refresh_token"] == "mock_refresh_token"
572+
assert result.oauth2.access_token == "mock_access_token"
573+
assert result.oauth2.refresh_token == "mock_refresh_token"
578574
assert result.auth_type == AuthCredentialTypes.OAUTH2

0 commit comments

Comments
 (0)