Commit Graph

2245 Commits

Author SHA1 Message Date
Drew Afromsky dd0851ac74 fix: Update expected UsageMetadataChunk in LiteLLM tests
Close #4680

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 877646178
2026-03-02 17:10:43 -08:00
George Weale 5770cd3776 feat: Add streaming support for Anthropic models
Refactor ToolResultBlockParam content handling to use json.dumps for dict/list results.
Implement _generate_content_streaming to handle Anthropic's streaming API

Close #3250

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 877613612
2026-03-02 15:47:59 -08:00
Haiyuan Cao 80c5a24555 feat: Enhance BQ plugin with fork safety, auto views, and trace continuity
- **Fork-safety (#4636):** Adds PID tracking to `BigQueryAgentAnalyticsPlugin` so that forked child processes detect stale gRPC channels and re-initialize instead of deadlocking. Uses the standard `os.getpid()` pattern (same as SQLAlchemy, gRPC-python).
- **Auto-create views (#4639):** After ensuring the `agent_events` table exists, automatically creates 15 per-event-type BigQuery views (`v_llm_request`, `v_tool_completed`, etc.) that unnest JSON columns into typed, queryable columns. Controlled by `BigQueryLoggerConfig.create_views` (default `True`), idempotent via `CREATE OR REPLACE VIEW`.
- **Trace-ID continuity & o11y alignment (#4645):** Fixes trace_id fracture between early events (USER_MESSAGE_RECEIVED, INVOCATION_STARTING) and later events (AGENT_STARTING onwards) when no ambient OTel span exists. Also aligns BQ rows with Cloud Trace span IDs when o11y is active.
- **Span-ID consistency under ambient OTel (#4640 review):** Fixes `*_STARTING` / `*_COMPLETED` events producing mismatched span IDs when an ambient OTel span is active. Completion callbacks now check for ambient spans and defer to `_resolve_ids` Layer 2 instead of overriding with plugin-synthetic IDs.
- **Stack leak safety (#4640 review):** Adds `TraceManager.clear_stack()` and makes `ensure_invocation_span()` clear stale records from *different* invocations, preventing span stack leaks across invocations. Uses `_active_invocation_id_ctx` to distinguish stale leak vs same-invocation re-entry.
- **Root agent name staleness fix:** `init_trace()` now refreshes `_root_agent_name_ctx` unconditionally on each invocation (previously set-once-on-None). `after_run_callback` resets it alongside other invocation cleanup.
- **Exception-safe cleanup:** `after_run_callback` uses `try/finally` to guarantee invocation state (`clear_stack`, `_active_invocation_id_ctx`, `_root_agent_name_ctx`) is always reset, even if `_log_event` raises.
- **`on_tool_error_callback` span fix:** Previously discarded the span_id from `pop_span()`, causing TOOL_ERROR events to get the wrong span. Now captures and uses the popped span_id.

Co-authored-by: Haiyuan Cao <haiyuan@google.com>
PiperOrigin-RevId: 877580395
2026-03-02 14:32:15 -08:00
Xiang (Sean) Zhou c59afc21cb refactor: extract reusable functions from hitl and auth preprocessor
Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com>
PiperOrigin-RevId: 877578253
2026-03-02 14:27:27 -08:00
Google Team Member 8e79a12d6b fix: Make invocation_context optional in convert_event_to_a2a_message
PiperOrigin-RevId: 877565033
2026-03-02 13:59:36 -08:00
Google Team Member 72f3e7e1e0 fix: update Bigtable query tools to async functions
PiperOrigin-RevId: 877558234
2026-03-02 13:43:49 -08:00
Xiang (Sean) Zhou b4bad26720 chore: Update pydantic versions
Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com>
PiperOrigin-RevId: 877553194
2026-03-02 13:33:15 -08:00
Google Team Member f324fa2d62 fix: Propagate file names during A2A to/from Genai Part conversion
This change updates the part_converter to ensure that the name field in a2a_types.FileWithUri and a2a_types.FileWithBytes is correctly mapped to the display_name field in genai_types.FileData and genai_types.Blob, respectively, during conversions between A2A and Genai Part types. Tests are updated to verify this propagation in both directions.

PiperOrigin-RevId: 877507283
2026-03-02 11:51:12 -08:00
Xuan Yang 90f28deea5 chore: Allow custom parameter names for ToolContext injection
Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 877502827
2026-03-02 11:41:29 -08:00
Shruti Nair 9c45166281 feat: execute-type param addition in GkeCodeExecutor
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/4111 from SHRUTI6991:execute-type/param-addition b1ec403e0927767d17c11cb9e894f6ccb4f08dd2
PiperOrigin-RevId: 877476098
2026-03-02 10:50:43 -08:00
George Weale 89df5fcf88 feat: Enable output schema with tools for LiteLlm models
LiteLlm provides built-in handling for tool and response format compatibility across different providers, allowing output schemas to be used reliably with tools for any LiteLlm instance

Close #3969

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 877471153
2026-03-02 10:40:16 -08:00
Xuan Yang f9c104faf7 fix: Preserve thought_signature in FunctionCall conversions between GenAI and A2A
Close: https://github.com/google/adk-python/issues/4311

Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 877465519
2026-03-02 10:29:06 -08:00
dependabot[bot] a61c7e3880 chore(deps): bump flask from 3.1.1 to 3.1.3 in /contributing/samples/authn-adk-all-in-one in the pip group across 1 directory
Merge https://github.com/google/adk-python/pull/4571

Bumps the pip group with 1 update in the /contributing/samples/authn-adk-all-in-one directory: [flask](https://github.com/pallets/flask).

Updates `flask` from 3.1.1 to 3.1.3
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/pallets/flask/releases">flask's releases</a>.</em></p>
<blockquote>
<h2>3.1.3</h2>
<p>This is the Flask 3.1.3 security fix release, which fixes a security issue but does not otherwise change behavior and should not result in breaking changes compared to the latest feature release.</p>
<p>PyPI: <a href="https://pypi.org/project/Flask/3.1.3/">https://pypi.org/project/Flask/3.1.3/</a>
Changes: <a href="https://flask.palletsprojects.com/page/changes/#version-3-1-3">https://flask.palletsprojects.com/page/changes/#version-3-1-3</a></p>
<ul>
<li>The session is marked as accessed for operations that only access the keys but not the values, such as <code>in</code> and <code>len</code>. <a href="https://github.com/pallets/flask/security/advisories/GHSA-68rp-wp8r-4726">GHSA-68rp-wp8r-4726</a></li>
</ul>
<h2>3.1.2</h2>
<p>This is the Flask 3.1.2 fix release, which fixes bugs but does not otherwise change behavior and should not result in breaking changes compared to the latest feature release.</p>
<p>PyPI: <a href="https://pypi.org/project/Flask/3.1.2/">https://pypi.org/project/Flask/3.1.2/</a>
Changes: <a href="https://flask.palletsprojects.com/page/changes/#version-3-1-2">https://flask.palletsprojects.com/page/changes/#version-3-1-2</a>
Milestone: <a href="https://github.com/pallets/flask/milestone/38?closed=1">https://github.com/pallets/flask/milestone/38?closed=1</a></p>
<ul>
<li><code>stream_with_context</code> does not fail inside async views. <a href="https://redirect.github.com/pallets/flask/issues/5774">#5774</a></li>
<li>When using <code>follow_redirects</code> in the test client, the final state of <code>session</code> is correct. <a href="https://redirect.github.com/pallets/flask/issues/5786">#5786</a></li>
<li>Relax type hint for passing bytes IO to <code>send_file</code>. <a href="https://redirect.github.com/pallets/flask/issues/5776">#5776</a></li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/pallets/flask/blob/main/CHANGES.rst">flask's changelog</a>.</em></p>
<blockquote>
<h2>Version 3.1.3</h2>
<p>Released 2026-02-18</p>
<ul>
<li>The session is marked as accessed for operations that only access the keys
but not the values, such as <code>in</code> and <code>len</code>. :ghsa:<code>68rp-wp8r-4726</code></li>
</ul>
<h2>Version 3.1.2</h2>
<p>Released 2025-08-19</p>
<ul>
<li><code>stream_with_context</code> does not fail inside async views. :issue:<code>5774</code></li>
<li>When using <code>follow_redirects</code> in the test client, the final state
of <code>session</code> is correct. :issue:<code>5786</code></li>
<li>Relax type hint for passing bytes IO to <code>send_file</code>. :issue:<code>5776</code></li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/pallets/flask/commit/22d924701a6ae2e4cd01e9a15bbaf3946094af65"><code>22d9247</code></a> release version 3.1.3</li>
<li><a href="https://github.com/pallets/flask/commit/089cb86dd22bff589a4eafb7ab8e42dc357623b4"><code>089cb86</code></a> Merge commit from fork</li>
<li><a href="https://github.com/pallets/flask/commit/c17f379390731543eea33a570a47bd4ef76a54fa"><code>c17f379</code></a> request context tracks session access</li>
<li><a href="https://github.com/pallets/flask/commit/27be9338405382445a7cb01151e084559b98d602"><code>27be933</code></a> start version 3.1.3</li>
<li><a href="https://github.com/pallets/flask/commit/4e652d3f68b90d50aa2301d3b7e68c3fafd9251d"><code>4e652d3</code></a> Abort if the instance folder cannot be created (<a href="https://redirect.github.com/pallets/flask/issues/5903">#5903</a>)</li>
<li><a href="https://github.com/pallets/flask/commit/3d03098a97ddc6a908aa4a50c2ef7381f8297d0a"><code>3d03098</code></a> Abort if the instance folder cannot be created</li>
<li><a href="https://github.com/pallets/flask/commit/407eb76b27884848383a37c7274654f0271e4bc4"><code>407eb76</code></a> document using gevent for async (<a href="https://redirect.github.com/pallets/flask/issues/5900">#5900</a>)</li>
<li><a href="https://github.com/pallets/flask/commit/ac5664d2281533eacafd64f5cc7d5edcdaccab60"><code>ac5664d</code></a> document using gevent for async</li>
<li><a href="https://github.com/pallets/flask/commit/4f79d5b59a56bc4356a97f2e81a35f98cb18d7b3"><code>4f79d5b</code></a> Increase required flit_core version to 3.11 (<a href="https://redirect.github.com/pallets/flask/issues/5865">#5865</a>)</li>
<li><a href="https://github.com/pallets/flask/commit/fe3b215d3ade4db68262dae1a3cdc464a1fc524f"><code>fe3b215</code></a> Increase required flit_core version to 3.11</li>
<li>Additional commits viewable in <a href="https://github.com/pallets/flask/compare/3.1.1...3.1.3">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=flask&package-manager=pip&previous-version=3.1.1&new-version=3.1.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore <dependency name> major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will remove the ignore condition of the specified dependency and ignore conditions
You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/google/adk-python/network/alerts).

</details>

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/4571 from google:dependabot/pip/contributing/samples/authn-adk-all-in-one/pip-81068183c6 6f577df16cb78beec2d26d873761173811f6ef5b
PiperOrigin-RevId: 877461954
2026-03-02 10:21:29 -08:00
George Weale 6a929af718 fix: Prevent splitting of SSE events with artifactDelta for function resume requests
When handling a /run_sse request that includes a functionCallEventId, do not split events that contain both content and artifactDelta

Close #4487

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 877435561
2026-03-02 09:25:22 -08:00
nikkie 991abd44e9 chore: escape Click's wrapping
Escape Click’s Wrapping in `adk deploy agent_engine` example

Merge https://github.com/google/adk-python/pull/4337

### Link to Issue or Description of Change

**2. Or, if no issue exists, describe the change:**

**Problem:**
`adk deploy agent_engine` help message loses newlines in docstring formatting

<img width="749" height="257" alt="スクリーンショット 2026-01-31 13 29 18" src="https://github.com/user-attachments/assets/ede7d9e7-609d-4412-acce-c80e24ec1e2f" />

**Solution:**

Add `\b` on a line by itself before the formatted block

### Testing Plan

This is format improvement of help message, so I think there is no need to add test case.

**Unit Tests:**

- [ ] I have added or updated unit tests for my change.
- [x] All unit tests pass locally.

```
% pytest tests/unittests/cli  # Python 3.13.8
======================= 260 passed, 140 warnings in 7.73s ========================
```

**Manual End-to-End (E2E) Tests:**

Ran `adk deploy agent_engine --help`, then saw

```
  Example:

      # With Express Mode API Key
      adk deploy agent_engine --api_key=[api_key] my_agent

      # With Google Cloud Project and Region
      adk deploy agent_engine --project=[project] --region=[region]
        --display_name=[app_name] my_agent
```

### Checklist

- [x] I have read the [CONTRIBUTING.md](https://github.com/google/adk-python/blob/main/CONTRIBUTING.md) document.
- [x] I have performed a self-review of my own code.
- [x] I have commented my code, particularly in hard-to-understand areas.
- [x] I have added tests that prove my fix is effective or that my feature works.
- [x] New and existing unit tests pass locally with my changes.
- [x] I have manually tested my changes end-to-end.
- [x] Any dependent changes have been merged and published in downstream modules.

### Additional context

Same solution as #4258

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/4337 from ftnext:escape-wrapping-deploy-agent-engine-example 09440380dd5b1e14a48151eba1b808def8ae3b6a
PiperOrigin-RevId: 877205878
2026-03-01 22:32:15 -08:00
nikkie eb55eb7e7f fix: typo in A2A EXPERIMENTAL warning
Merge https://github.com/google/adk-python/pull/4462

**Please ensure you have read the [contribution guide](https://github.com/google/adk-python/blob/main/CONTRIBUTING.md) before creating a pull request.**

### Link to Issue or Description of Change

**2. Or, if no issue exists, describe the change:**

**Problem:**
I found a typo: arethemselves

>/.../adk-python/src/google/adk/a2a/converters/event_converter.py:245: UserWarning: [EXPERIMENTAL] convert_a2a_message_to_event: ADK Implementation for A2A support (A2aAgentExecutor, RemoteA2aAgent and corresponding supporting components etc.) is in experimental mode and is subjected to breaking changes. A2A protocol and SDK arethemselves not experimental. Once it's stable enough the experimental mode will be removed. Your feedback is welcome.

**Solution:**
Just fix

### Testing Plan

This is typo fix

**Unit Tests:**

N/A

**Manual End-to-End (E2E) Tests:**

N/A

### Checklist

- [x] I have read the [CONTRIBUTING.md](https://github.com/google/adk-python/blob/main/CONTRIBUTING.md) document.
- [x] I have performed a self-review of my own code.
- [ ] I have commented my code, particularly in hard-to-understand areas.
- [ ] I have added tests that prove my fix is effective or that my feature works.
- [ ] New and existing unit tests pass locally with my changes.
- [ ] I have manually tested my changes end-to-end.
- [ ] Any dependent changes have been merged and published in downstream modules.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/4462 from ftnext:fix-typo-a2a-experimental-warning a117314eb524dd93351e17f2183eea080225e43e
PiperOrigin-RevId: 877095788
2026-03-01 14:52:34 -08:00
Shangjie Chen 8ddddc040c chore: Use factory method to create invocation context in the runner
Co-authored-by: Shangjie Chen <deanchen@google.com>
PiperOrigin-RevId: 876474267
2026-02-27 17:12:06 -08:00
Lusha Wang dff4c44040 fix: Update agent_engine_sandbox_code_executor in ADK
1. For prototyping and testing purposes, sandbox name can be provided, and it will be used for all requests across the lifecycle of an agent
2. If no sandbox name is provided, agent engine name will be provided, and we will automatically create one sandbox per session, and the sandbox has TTL set for a year.
If the sandbox stored in the session hits the TTL, it will not be in "STATE_RUNNING" so a new sandbox will be created.

Co-authored-by: Lusha Wang <lusha@google.com>
PiperOrigin-RevId: 876450610
2026-02-27 15:59:20 -08:00
Wei (Jack) Sun 1206addd6e chore: merge release v1.26.0 to main
Merge https://github.com/google/adk-python/pull/4637

Syncs version bump and CHANGELOG from release v1.26.0 to main.

Co-authored-by: Xuan Yang <xygoogle@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/4637 from google:release/v1.26.0 427a983b18088bdc22272d02714393b0a779ecdf
PiperOrigin-RevId: 875930970
2026-02-26 16:00:38 -08:00
Kathy Wu 8ad8bc9b69 fix: Add a script to the sample skills agent
Added a get_humidity script to demo the new RunSkillScript tool

Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 875901416
2026-02-26 14:50:02 -08:00
Ke Wang 8a3161202e feat(skill): Add BashTool
PiperOrigin-RevId: 875899505
2026-02-26 14:46:16 -08:00
George Weale ebbc114786 fix: Validate session before streaming instead of eagerly advancing the runner generator
Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 875892569
2026-02-26 14:30:42 -08:00
Xuan Yang d55afede1b chore: Stop auto-triggering Release Please after cherry-picks
Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 875867583
2026-02-26 13:33:37 -08:00
Kathy Wu b4610fe1c6 chore: Add README for integrations folder
Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 875836816
2026-02-26 12:24:24 -08:00
Keyur Joshi 7b7ddda46c feat: Add interface between optimization infra and LocalEvalService
details:
* Enables the use of ADK evaluations via LocalEvalService for optimizing agents.
* Provides flexibility in choosing eval sets and eval cases for training and validation.
* Converts ADK eval results into a compact format useful for whitebox agent optimization.

Co-authored-by: Keyur Joshi <keyurj@google.com>
PiperOrigin-RevId: 875818012
2026-02-26 11:40:37 -08:00