Compare commits

..

1292 Commits

Author SHA1 Message Date
George Weale 6c67b6c0f4 fix: map LiteLLM thought parts to reasoning_content
- Treat Part(thought=True) as reasoning_content when building assistant messages.
- Add unit tests for thought-only and thought+text cases.

Close #4069

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 853790274
2026-01-08 10:10:13 -08:00
Xiang (Sean) Zhou 9b2bd411dd chore: Put user_id in the error message when session is not found
Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com>
PiperOrigin-RevId: 853771033
2026-01-08 09:19:31 -08:00
Xiang (Sean) Zhou 392dda1e0c chore: Update live multi agent sample with latest live models
Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com>
PiperOrigin-RevId: 853769664
2026-01-08 09:14:45 -08:00
Google Team Member a0b2aac108 fix: Add google-cloud-geminidataanalytics to dependencies
PiperOrigin-RevId: 853515315
2026-01-07 19:57:53 -08:00
Google Team Member 3cd3d56176 fix: Add google-cloud-geminidataanalytics to dependencies
PiperOrigin-RevId: 853504915
2026-01-07 19:19:24 -08:00
Google Team Member c34feb4c0e feat: add new conversational analytics api tool set
PiperOrigin-RevId: 853489874
2026-01-07 18:26:05 -08:00
Google Team Member aaf76a6a51 feat: add new conversational analytics api tool set
PiperOrigin-RevId: 853434500
2026-01-07 15:23:43 -08:00
Yifan Wang 45a25d780b chore: update adk web to match main branch
Co-authored-by: Yifan Wang <wanyif@google.com>
PiperOrigin-RevId: 853331843
2026-01-07 10:58:37 -08:00
George Weale 5912835c97 fix: Add checks for event content and parts before accessing
Close #3769

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 853327479
2026-01-07 10:48:14 -08:00
George Weale b30c2f4e13 fix: avoid local .adk storage in Cloud Run/GKE
Default session and artifact services to in-memory when running in Cloud Run/Kubernetes (or when agents_dir isn’t writable) to prevent startup failures from attempting to create .adk under read-only/unwritable container paths (e.g. /app/agents/.adk). Local development defaults are unchanged.

  - ADK_FORCE_LOCAL_STORAGE=1 to always use .adk defaults
  - ADK_DISABLE_LOCAL_STORAGE=1 to always avoid local storage

If local artifact initialization raises PermissionError, fall back to in-memory and log a warning

Close #3907

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 853315459
2026-01-07 10:18:11 -08:00
Xiang (Sean) Zhou d5bd8d939e chore: Clean up the invocation context initialization logic for LIVE
1. Removed dead code: The if not run_config.response_modalities: branch was never executed since run_live already sets the default (https://github.com/google/adk-python/blob/19de45b3250d09b9ec16c45788e7d472b3e588c2/src/google/adk/runners.py#L947-L948).
2. Simplified condition: Changed from checking 'TEXT' not in ... to 'AUDIO' in ...

Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com>
PiperOrigin-RevId: 853274401
2026-01-07 08:31:01 -08:00
Sasha Sobran 96c5db5a07 fix: use mode='json' in model_dump to serialize bytes correctly when using telemetry
fixes #4043

Co-authored-by: Sasha Sobran <asobran@google.com>
PiperOrigin-RevId: 853256045
2026-01-07 07:38:18 -08:00
Xuan Yang 10bdc078a4 chore: Add docstring for StreamingMode
Related: #3705

Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 853116282
2026-01-07 00:15:12 -08:00
Xiang (Sean) Zhou a4b914b09f fix: Set the default response modality to AUDIO only
Currently Live API only allow one response modality although the config is defined as a list.

Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com>
PiperOrigin-RevId: 853107710
2026-01-06 23:47:08 -08:00
Xiang (Sean) Zhou 19de45b325 fix: Honor the modalities parameter in adk api server for live API
Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com>
PiperOrigin-RevId: 853077949
2026-01-06 22:06:57 -08:00
George Weale b28721508a feat: make LlmAgent.model optional with a default fallback
LlmAgent now resolves model from ancestors or a system default (gemini-2.5-flash) when unset. Added LlmAgent.set_default_model() to override the default globally

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 853006116
2026-01-06 17:56:14 -08:00
George Weale 742c9265a2 fix: Validate app name in adk create command
The `adk create` command now checks if the provided agent name is a valid Python identifier. An invalid name, such as one containing hyphens, will raise a `click.BadParameter` error before any files are created.

Close #3977

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 853001295
2026-01-06 17:37:36 -08:00
Xiang (Sean) Zhou 9403a44f34 chore: Cleanup the workaround logic for streamlit
Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com>
PiperOrigin-RevId: 852995899
2026-01-06 17:18:49 -08:00
Liang Wu 35308d3809 chore: add min version of Google Auth to include fix
Context: https://github.com/googleapis/python-genai/commit/930c7ca7d5b696d3388fe16fb724184eb88c6a65. The GenAI SDK relies on Google Auth for the fix, and adding this as a direct dependency in ADK will decouple the release of ADK and GenAI SDK.

Co-authored-by: Liang Wu <wuliang@google.com>
PiperOrigin-RevId: 852990837
2026-01-06 17:01:16 -08:00
Xiang (Sean) Zhou ecc9f182e3 chore: remove unecessary event loop creation in LiveRequstQueue constructor
Before Python 3.10, asyncio.Queue() required a running event loop at creation time. This was deprecated in 3.8-3.9 and fully removed in 3.10. ADK requires Python 3.10+, thus remove this unecessary logic

Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com>
PiperOrigin-RevId: 852989791
2026-01-06 16:57:23 -08:00
George Weale 6dce7f8a8f fix: Add schema type sanitization to OpenAPI spec parser
This change introduces a `_sanitize_schema_types` method to the OpenAPI spec parser. This method recursively removes or filters out non-standard schema types (e.g., "Any", "Unknown") from the OpenAPI specification

Close #3704
Close #3108

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 852986491
2026-01-06 16:47:06 -08:00
Liang Wu ce64787c3e feat: Add database schema migration command and script
Final part of https://github.com/google/adk-python/discussions/3605.

This change introduces:
-   A new `adk migrate session` CLI command to run database schema upgrades.
-   A migration script to upgrade from the old Pickle-based session schema (v0) to the new JSON-based schema (v1).
-   A migration runner that orchestrates the upgrade process, handling sequential migrations and using temporary SQLite databases for intermediate steps if needed.
-   Unit tests for the v0 to v1 migration.

Co-authored-by: Liang Wu <wuliang@google.com>
PiperOrigin-RevId: 852983323
2026-01-06 16:36:45 -08:00
George Weale 0827d12ccd fix: Prevent .env files from overriding existing environment variables
This change modifies `load_dotenv_for_agent` to first capture the environment variables already set in the process. After loading the `.env` file with `override=True`, it restores the values of these initially set variables, ensuring that explicitly set environment variables are not overwritten by the `.env` file. A new environment variable, `ADK_DISABLE_LOAD_DOTENV`, is also introduced to completely skip the `.env` loading process

Close #4020
Close $4018

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 852981654
2026-01-06 16:31:24 -08:00
Liang Wu 8329fec0fc chore: Add disambiguation message to enterprise_search_tool
Co-authored-by: Liang Wu <wuliang@google.com>
PiperOrigin-RevId: 852969034
2026-01-06 15:56:22 -08:00
George Weale 1ace8fc678 fix: Filter out thought parts in lite_llm._get_content
Thought parts represent internal model reasoning and should not be included in the content sent back to the model in subsequent turns

Close #3948

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 852965417
2026-01-06 15:44:33 -08:00
George Weale 084fcfaba5 fix: Split SSE events with both content and artifactDelta in ADK Web Server
This change modifies the /run_sse endpoint to split events that contain both content and an artifactDelta. The original event is split into two separate SSE events: one containing only the content (with artifactDelta cleared) and another containing only the artifactDelta (with content cleared)

Close #4036

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 852945249
2026-01-06 14:51:37 -08:00
George Weale 1ae0e16b2c fix: Remove fallback to cached exchanged credential in _load_existing_credential
The _load_existing_credential method in CredentialManager will now only attempt to load credentials from the credential service and will no longer check the AuthConfig's exchanged_auth_credential cache.

Close #3772

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 852944533
2026-01-06 14:50:05 -08:00
George Weale 30d3411d60 fix: Prevent retry_on_errors from retrying asyncio.CancelledError
The retry_on_errors decorator in mcp_session_manager.py now catches asyncio.CancelledError and re-raises it immediately, ensuring that cancellation requests are not suppressed or retried

Close #4009

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 852468382
2026-01-05 14:58:26 -08:00
Xiang (Sean) Zhou 6f2c70fc33 chore: add docstring for BIDI streaming mode
BIDI streaming mode is not used currently.

Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com>
PiperOrigin-RevId: 852461564
2026-01-05 14:41:09 -08:00
George Weale fc4e3d6f60 fix: Fix double JSON encoding when saving eval set results
The `model_dump_json()` method already returns a JSON string, so wrapping it in `json.dumps()` was causing double encoding

Close #3993

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 852455534
2026-01-05 14:26:05 -08:00
Michael Jones bfed19cd78 feat: expose mcps streamable http custom httpx factory parameter
Merge https://github.com/google/adk-python/pull/3634

Reopen of https://github.com/google/adk-python/pull/2997 after the accepted changes in that PR were reverted by https://github.com/google/adk-python/commit/e15e19da05ee1b763228467e83f6f73e0eced4b5

---

This PR addresses https://github.com/google/adk-python/issues/3005 and https://github.com/google/adk-python/issues/2963 to allow control over the ssl cert used when connecting to an mcp server by exposing the `httpx_client_factory` parameter exposed when creating a `MCPSessionManager` in adk. Overlaps with https://github.com/google/adk-python/pull/2966 but I don't believe that that PR's implementation will work. `streamablehttp_client` needs a client factory, not a client.

## testing plan

Adds test checking that `streamablehttp_client` uses the custom httpx factory. Could also test that a factory which obeys the `McpHttpClientFactory` protocol produces valid behavior when the session is opened?

## related issues

#2227 and #2881 both request _slightly different_ options to control the ssl certs used internally by adk. I think exposing a httpx factory is a good pattern which could be followed for those issues too.

Co-authored-by: Kathy Wu <wukathy@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3634 from mikeedjones:feat/expose-mcps-streamable-http-custom-httpx-factory-parameter 1017a9875c697b28b96a7a8d1311494ef89af65a
PiperOrigin-RevId: 852443631
2026-01-05 13:57:26 -08:00
George Weale e3db2d0d83 fix: Propagate RunConfig custom metadata to all events
Adds a method to merge custom metadata from the RunConfig into each Event. This metadata is applied to events generated by the agent, early exit events, and the initial user message event.

Close #3953

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 852433171
2026-01-05 13:30:09 -08:00
George Weale 4ddb2cb2a8 chore: Close database engines to avoid aiosqlite pytest hangs
Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 852428755
2026-01-05 13:18:08 -08:00
Google Team Member 8789ad8f16 fix: Include back-ticks around the BQ asset names in the tools examples
These changes add extra hint for the LLM in the `execute_tool` SQL examples to always use back-ticks around BQ project, dataset and table names in the generated SQL, to save the SQL parsing error when the name has special characters.

PiperOrigin-RevId: 852418943
2026-01-05 12:52:49 -08:00
George Weale 93d6e4c888 fix: Allow string values for ToolTrajectoryCriterion.match_type
Adds a Pydantic field validator to ToolTrajectoryCriterion to automatically convert string inputs for the match_type field into the corresponding MatchType enum member

Close #3711

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 852415560
2026-01-05 12:43:53 -08:00
Xiang (Sean) Zhou e850e9c9ba chore: Update disconnecting log message
websocket disconnection could happen in both sending/receiving text, update the log message to make it less confusing.

Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com>
PiperOrigin-RevId: 852410439
2026-01-05 12:30:15 -08:00
George Weale 838530ebe0 fix: rehydration of EventActions in StorageEvent.to_event
The change updates the `StorageEvent.to_event` method to use `EventActions.model_validate` when rehydrating the `actions` field. This ensures that nested models within `EventActions`, such as `EventCompaction`, are correctly reconstructed from the stored data

Close #4047

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 852408683
2026-01-05 12:26:10 -08:00
Mimi Sun 8bed01cbdc fix: make the BigQuery analytics plugin work with agents that don't have instructions such as the LoopAgent
PiperOrigin-RevId: 852382657
2026-01-05 11:21:25 -08:00
George Weale e32f017979 fix: Prevent ContextFilterPlugin from creating orphaned function responses
When truncating conversation history, make sure function_response messages always have their corresponding function_call included

Close #4027

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 852377919
2026-01-05 11:09:52 -08:00
George Weale 688f48fffb fix: Update empty event check to include executable code and execution results
Close #3859
Close #3921

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 852375447
2026-01-05 11:04:34 -08:00
George Weale 6f259f08b3 fix: Harden YAML builder tmp save/cleanup
- Add path-safe helpers so all builder filesystem operations stay under <agents_dir>/<app_name> and reject traversal/invalid upload paths.
- Rework /builder/save to support tmp=true writes under <app>/tmp/<app>, promote tmp → app root on final save (preserving tools.py/tools/), then clean up tmp on success.
- Simplify /builder/app/{app_name}/cancel to best-effort delete tmp; update GET /builder/app/{app_name}?tmp=true to auto-recreate tmp from the app root and safely serve requested files.

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 852366567
2026-01-05 10:47:12 -08:00
Rohit Yanamadala 3ec7ae3b8d fix: ignore adk-bot administrative actions in stale agent
Merge https://github.com/google/adk-python/pull/4041

## Description
This PR fixes false positive stale labels in the `adk_stale_agent`.

Previously, the agent was incorrectly identifying the issue as "stale" because it treated `adk-bot` (acting via PAT) as a human maintainer. Since the username lacks the `[bot]` suffix, administrative alerts (e.g., "Notification: The author has updated...") were counted as maintainer activity, inadvertently triggering the stale logic immediately after an author's edit.

## Changes Made
- **Hardcoded Bot Exclusion:** Added `BOT_NAME = "adk-bot"` and updated history parsing loops (comments, edits, timeline) to explicitly ignore this actor.
- **Bot Alert Skip:** Added logic to `continue` (skip) processing the bot's specific "Notification" comment so it is not recorded as the last activity on the timeline.

Co-authored-by: Xuan Yang <xygoogle@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/4041 from ryanaiagent:fix/stale-bot-logic f1500a94cb8c9d5090e9b1ef29690506120f7749
PiperOrigin-RevId: 852365962
2026-01-05 10:45:58 -08:00
George Weale 6b7386b762 fix: Heal missing tool results before LiteLLM requests
Detect assistant tool calls that lack matching tool results in the history and insert placeholder tool messages so strict providers don’t reject the request. Prevents crash loops when executions are interrupted mid-tool call.

Close #3971

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 852340750
2026-01-05 09:49:20 -08:00
Joseph Pagadora 5b7c8c04d6 chore: Introduce MetricInfoProvider interface, and refactor metric evaluators to use this interface to provide MetricInfo
Co-authored-by: Joseph Pagadora <jcpagadora@google.com>
PiperOrigin-RevId: 851406110
2026-01-02 11:49:34 -08:00
Google Team Member 07bb164758 fix: Exclude thought parts when merging agent output
PiperOrigin-RevId: 850500329
2025-12-30 13:39:40 -08:00
Keyur Joshi a364388d97 feat: Add custom instructions support to LlmBackedUserSimulator
Details:
- Allows users to provide custom instructions for the LLM-backed user simulator via the `custom_instructions` field in `LlmBackedUserSimulatorConfig`.
- The custom instructions must include placeholders for the stop signal, conversation plan, and conversation history. A pydantic validator ensures these placeholders are present.
- If no custom instructions are provided, the current default template is used.

Co-authored-by: Keyur Joshi <keyurj@google.com>
PiperOrigin-RevId: 850471448
2025-12-30 11:42:46 -08:00
Keyur Joshi 0918b647df fix: fix inconsistent method signatures for evaluate_invocations
The evaluate_invocations method override in Evaluator subclasses was not consistent, leading to errors during calls, especially when using kwargs. Made the overrides and calls consistent to resolve this issue.

Co-authored-by: Keyur Joshi <keyurj@google.com>
PiperOrigin-RevId: 850462752
2025-12-30 11:07:25 -08:00
Yeesian Ng 38a30a44d2 fix: Handle overriding of requirements when deploying to agent engine
Co-authored-by: Yeesian Ng <ysian@google.com>
PiperOrigin-RevId: 850423017
2025-12-30 08:30:35 -08:00
Google Team Member 26e77e1694 fix: Fix issue with MCP tools throwing an error
Fixes: https://github.com/google/adk-python/issues/3082
PiperOrigin-RevId: 849562638
2025-12-27 15:51:03 -08:00
Yeesian Ng 1f546df35a feat: Set log level when deploying to Agent Engine
Co-authored-by: Yeesian Ng <ysian@google.com>
PiperOrigin-RevId: 848243087
2025-12-23 11:25:39 -08:00
Google Team Member 871571d997 feat: Mark Vertex calls made from non-gemini models
PiperOrigin-RevId: 848159669
2025-12-23 06:50:46 -08:00
Google Team Member 0f5b677c53 feat: Mark Vertex calls made from non-gemini models
PiperOrigin-RevId: 848140103
2025-12-23 05:37:36 -08:00
Google Team Member 4f3b733074 fix: label response as thought if task is immediately returned as working
PiperOrigin-RevId: 847660113
2025-12-22 01:21:41 -08:00
Xuan Yang 0b1cff2976 feat: Enable PROGRESSIVE_SSE_STREAMING feature by default
Related: https://github.com/google/adk-python/issues/3705

Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 846793027
2025-12-19 10:50:49 -08:00
Kathy Wu 71b32890f5 fix: Only prepend "https://" to the MCP server url if it doesn't already have a scheme
There isn't a consistent format for MCP server urls in the registry-- some customers add the https:// but others don't. To standardize, only prepend if it isn't there already.

Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 846451152
2025-12-18 16:07:16 -08:00
Rohit Yanamadala f51b9b70b2 fix: Prevent stale bot from flagging internal maintainer discussions
Merge https://github.com/google/adk-python/pull/3938

Co-authored-by: Xuan Yang <xygoogle@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3938 from ryanaiagent:fix/stale-bot-logic 605d3499784facffc0e0ca3c1fb0547202660f46
PiperOrigin-RevId: 846450195
2025-12-18 16:04:21 -08:00
Google Team Member e4ee9d7c46 feat: Update event_converter used in A2ARemote agent to use a2a_task.status.message only if parts are non-empty
PiperOrigin-RevId: 846413612
2025-12-18 14:23:27 -08:00
Xiang (Sean) Zhou f1eb1c0254 chore: Update latest Live Model names for sample agent
Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com>
PiperOrigin-RevId: 846351549
2025-12-18 11:33:18 -08:00
Xiang (Sean) Zhou d58ea589ad chore: Update google-genai and google-cloud-aiplatform versions
Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com>
PiperOrigin-RevId: 846307170
2025-12-18 09:42:15 -08:00
Xuan Yang f5f4c01d1b fix: Pin aiosqlite version to 0.21.0
Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 846056994
2025-12-17 21:26:19 -08:00
Kathy Wu 253ac87c79 fix: nit fixes for API Registry - updating imports / type hints and formatting
Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 845980315
2025-12-17 17:23:58 -08:00
Kathy Wu 0088b0f3ad fix: Add x-goog-user-project header to http calls in API Registry
This gcloud authentication header is required as a project override when using google ADC credentials. It is required for all OneMCP servers. Originally I manually put it in the big query sample, but since it is used for all OneMCP, it makes sense to just add it to the core API Registry logic. I also refactored the auth header logic a bit to deduplicate.

Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 845967178
2025-12-17 16:41:50 -08:00
George Weale fcea86f58c chore: Update _flatten_ollama_content return type and add tests
The return type of _flatten_ollama_content is now strictly str | None

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 845963722
2025-12-17 16:31:43 -08:00
Google Team Member f35d129b4c feat(fix): Check all content parts for emptiness in _contains_empty_content
PiperOrigin-RevId: 845954226
2025-12-17 16:03:12 -08:00
Shangjie Chen 589f15cb27 feat: Add an internal function name 'adk_framework' to allow passing function response to the framework but not poluting the agent context
Co-authored-by: Shangjie Chen <deanchen@google.com>
PiperOrigin-RevId: 845933584
2025-12-17 15:07:25 -08:00
Kathy Wu 78c96e99ff fix: update Api Registry Agent prompt to be more specific and give it the gcloud project id
Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 845884290
2025-12-17 13:00:19 -08:00
George Weale e3bac1ab8c fix: Built-in agents (names starting with "__") now use in-memory session storage instead of creating .adk folders in the agents directory
Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 845852695
2025-12-17 11:36:22 -08:00
George Weale c6f389d4bc fix: Refine Ollama content flattening and provider checks
- Stripping whitespace from custom LLM provider and model names when checking for "ollama_chat".
- Enhancing `_flatten_ollama_content` to correctly handle content that is None, a string, a dictionary, or an iterable (like a tuple) of content blocks, not just lists. This aligns with LiteLLM's `OpenAIMessageContent` type being an `Iterable`.

Close #3928

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 845848017
2025-12-17 11:25:44 -08:00
Salman Chishti 1add41e160 fix: Upgrade GitHub Actions for Node 24 compatibility
Merge https://github.com/google/adk-python/pull/3932

## Summary

Upgrade GitHub Actions to their latest versions to ensure compatibility with Node 24, as Node 20 will reach end-of-life in April 2026.

## Changes

| Action | Old Version(s) | New Version | Release | Files |
|--------|---------------|-------------|---------|-------|
| `actions/checkout` | [`v5`](https://github.com/actions/checkout/releases/tag/v5) | [`v6`](https://github.com/actions/checkout/releases/tag/v6) | [Release](https://github.com/actions/checkout/releases/tag/v6) | analyze-releases-for-adk-docs-updates.yml, check-file-contents.yml, discussion_answering.yml, isort.yml, pr-triage.yml, pyink.yml, python-unit-tests.yml, stale-bot.yml, triage.yml, upload-adk-docs-to-vertex-ai-search.yml |

## Context

Per [GitHub's announcement](https://github.blog/changelog/2025-09-19-deprecation-of-node-20-on-github-actions-runners/), Node 20 is being deprecated and runners will begin using Node 24 by default starting March 4th, 2026.

### Why this matters

- **Node 20 EOL**: April 2026
- **Node 24 default**: March 4th, 2026
- **Action**: Update to latest action versions that support Node 24

### Security Note

Actions that were previously pinned to commit SHAs remain pinned to SHAs (updated to the latest release SHA) to maintain the security benefits of immutable references.

### Testing

These changes only affect CI/CD workflow configurations and should not impact application functionality. The workflows should be tested by running them on a branch before merging.

Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3932 from salmanmkc:upgrade-github-actions-node24 0ffbb0b7b5f63d27583f8c24781f2d3ca92c0c23
PiperOrigin-RevId: 845813166
2025-12-17 10:01:43 -08:00
Salman Chishti fa717ad8f0 fix: Upgrade GitHub Actions to latest versions
Merge https://github.com/google/adk-python/pull/3933

## Summary

Upgrade GitHub Actions to their latest versions for improved features, bug fixes, and security updates.

## Changes

| Action | Old Version(s) | New Version | Release | Files |
|--------|---------------|-------------|---------|-------|
| `google-github-actions/auth` | [`v2`](https://github.com/google-github-actions/auth/releases/tag/v2) | [`v3`](https://github.com/google-github-actions/auth/releases/tag/v3) | [Release](https://github.com/google-github-actions/auth/releases/tag/v3) | discussion_answering.yml, upload-adk-docs-to-vertex-ai-search.yml |

## Why upgrade?

Keeping GitHub Actions up to date ensures:
- **Security**: Latest security patches and fixes
- **Features**: Access to new functionality and improvements
- **Compatibility**: Better support for current GitHub features
- **Performance**: Optimizations and efficiency improvements

### Security Note

Actions that were previously pinned to commit SHAs remain pinned to SHAs (updated to the latest release SHA) to maintain the security benefits of immutable references.

### Testing

These changes only affect CI/CD workflow configurations and should not impact application functionality. The workflows should be tested by running them on a branch before merging.

Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3933 from salmanmkc:upgrade-github-actions-node24-general 142ef77d94da42b0f75a1fc810e8deeb666684a4
PiperOrigin-RevId: 845804209
2025-12-17 09:37:58 -08:00
Google Team Member 43270bcb61 fix: Move and enhance the deprecation warning for the plugins argument in "_validate_runner_params" to the beginning of the function
Previously, the warning check occurred after "plugins" could be populated from "app.plugins". This caused the deprecation warning to trigger incorrectly even when plugins were properly provided via the app argument. Moving the check ensures it only triggers when the deprecated plugins argument is explicitly used.

The change also enhanced the condition that would trigger the warning to cover the empty list case.

PiperOrigin-RevId: 845746847
2025-12-17 06:48:44 -08:00
Goodnight 322dd1827a docs: Fix typos, broken links, and grammar across documentation
Merge https://github.com/google/adk-python/pull/3937

**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
Not applicable

**Problem:**
Several markdown files contained typos, grammatical errors (e.g., "search youtubes"), and awkward phrasing.
**Solution:**
Performed a comprehensive quality assurance pass on the documentation.
- Fixed typos in README.md and AGENTS.md.
- Improved grammar and phrasing in CONTRIBUTING.md and sample READMEs.

### Testing Plan

This is a documentation and typo fix PR.

**Unit Tests:**

- [ ] I have added or updated unit tests for my change.
- [ ] All unit tests pass locally.
N/A - Documentation changes only.

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

This is a documentation and typo fix PR.

### 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.
- [x] I have manually tested my changes end-to-end.
- [ ] Any dependent changes have been merged and published in downstream modules.

Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3937 from Goodnight77:docs/fix-typos a0cf4db6741f19c77eeb0746c9db524dd02121ac
PiperOrigin-RevId: 845599254
2025-12-16 22:45:02 -08:00
Hiroaki Sano 42317f849f fix: Add missing space in README.md
Merge https://github.com/google/adk-python/pull/3939

### Link to Issue or Description of Change

**1. Link to an existing issue (if applicable):**

n/a

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

**Problem:**
In the Community Repo section of README.md, there was a missing space between the markdown link `[adk-python-community repo](...)` and the word `that`, causing the text to render as `repo](...)that` instead of `repo](...) that`.

**Solution:**
Add a single space between the closing parenthesis of the markdown link and the word "that" to fix the typo.

### Testing Plan

**Unit Tests:**

This is a small documentation/typo fix. No code changes were made.

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

I verified that the markdown renders correctly with proper spacing between the link and following text.

### 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

This is a minor typo fix in the README.md file. No functional changes.

Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3939 from hiroakis:fix-readme-typo f4e8014367961b55124da57b5c910890a287b2af
PiperOrigin-RevId: 845595505
2025-12-16 22:33:06 -08:00
Liang Wu ba91fea541 feat: Use new JSON-based schema for newly-created databases
Part 2 of https://github.com/google/adk-python/discussions/3605.

The DatabaseSessionService now checks for the usage of a V1 schema based on the "adk_internal_metadata" table. Table creation and subsequent operations use either the V0 or V1 SQLAlchemy models accordingly. New databases will default to V1.

Migration script and CLI command will be provided in the next change.

Co-authored-by: Liang Wu <wuliang@google.com>
PiperOrigin-RevId: 845443406
2025-12-16 14:49:31 -08:00
Xiang (Sean) Zhou 2ea6e513cf feat: support regex for allowed origins
fixes https://github.com/google/adk-python/issues/3908

Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com>
PiperOrigin-RevId: 845397350
2025-12-16 12:53:35 -08:00
Kamal Aboul-Hosn b6f6dcbeb4 feat: Add a handwritten tool for Cloud Pub/Sub
Merge https://github.com/google/adk-python/pull/3865

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3865 from kamalaboulhosn:main 37a38a4dcadb04a0af0ec584e6f611204a63cd2a
PiperOrigin-RevId: 845345128
2025-12-16 10:48:09 -08:00
Liang Wu 7e6ef71eec feat: Introduce new database schema for DatabaseSessionService
Part 1 of https://github.com/google/adk-python/discussions/3605.

This change adds a new schema that uses JSON serialization to store Events data in the database. A new "adk_internal_metadata" table is also added to store information like schema version. Since we want to keep supporting existing DB, we fork from the original schema and call it "v0", while the new one is called "v1".

The change is no-op for existing users. In later change, the new schema will be used for new databases, and migration scripts will be provided for existing databases.

Co-authored-by: Liang Wu <wuliang@google.com>
PiperOrigin-RevId: 844986248
2025-12-15 17:32:48 -08:00
Xuan Yang a0885064b0 chore: Add override_feature_enabled to override the default feature enable states
Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 844905911
2025-12-15 13:46:17 -08:00
Liang Wu e8ab7dafa9 chore: Move SQLite migration script to migration/ folder
Co-authored-by: Liang Wu <wuliang@google.com>
PiperOrigin-RevId: 844902789
2025-12-15 13:38:51 -08:00
Hiroaki Sano 8335f35015 fix: Change error_message column type to TEXT in DatabaseSessionService
Merge https://github.com/google/adk-python/pull/3917
To migrate from existing DB :

ALTER TABLE events ALTER COLUMN error_message TYPE TEXT;  -- PostgreSQL
ALTER TABLE events MODIFY error_message TEXT;             -- MySQL
SQLite: Doesn't enforce VARCHAR length limits anyway. No impact.
### Link to Issue or Description of Change

**1. Link to an existing issue (if applicable):**

n/a

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

**Problem:**

When storing events with error messages longer than 1024 characters using `DatabaseSessionService`, PostgreSQL raises:

```
ERROR: value too long for type character varying(1024)
```

The `error_message` column in `StorageEvent` is defined as `String(1024)`, which maps to `VARCHAR(1024)`. Error messages can exceed 1024 characters.

**Solution:**

Change the column type from `String(1024)` to `Text` to allow unlimited length error messages.

### Testing Plan

**Unit Tests:**

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

$ pytest ./tests/unittests/sessions/ -v
======================= 75 passed, 3 warnings in 26.92s ========================

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

- Verified that events with long error messages (>1024 chars) can be stored in PostgreSQL
- Verified backward compatibility with existing databases

### 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

This is a minimal change (1 line) that only affects the `error_message` column type definition.

Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3917 from hiroakis:main 1474fd552cdbd7206de383e5507fd8a733aecda1
PiperOrigin-RevId: 844845692
2025-12-15 11:09:25 -08:00
Google Team Member e515e0f321 feat: Introduce a post-hoc, per-turn evaluator for user simulations
PiperOrigin-RevId: 844818512
2025-12-15 10:05:31 -08:00
Marlin Ranasinghe 69997cd5ef fix: oauth refresh not triggered on token expiry
Merge https://github.com/google/adk-python/pull/3767

Co-authored-by: Xuan Yang <xygoogle@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3767 from MarlzRana:marlzrana/fix-oauth-refresh-not-triggered-on-token-expiry 2dae3917de6e8d3fa5317857d06305d47c0773b0
PiperOrigin-RevId: 843756363
2025-12-12 10:57:58 -08:00
George Weale 5c4bae7ff2 fix: Add MIME type inference and default for file URIs in LiteLLM
This change ensures that file URI parts passed to LiteLLM always include a "format" field. If `mime_type` is not explicitly provided in `FileData`, the system attempts to infer it from the URI's file extension. If inference fails, a default "application/octet-stream" is used. This is necessary because LiteLLM's Vertex AI backend requires the "format" field for GCS URIs.

Close #3787

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 843753810
2025-12-12 10:51:55 -08:00
David Sullivan 8782a69503 feat: add token_endpoint_auth_method support to OAuth2 credentials
Merge https://github.com/google/adk-python/pull/2870

## Summary

  Add `token_endpoint_auth_method` field to OAuth2Auth class to allow configuring OAuth2 token endpoint authentication methods. This enables users to specify how the client should authenticate with the authorization server's token
  endpoint.

  • Add `token_endpoint_auth_method` field to `OAuth2Auth` with default value `"client_secret_basic"`
  • Update `create_oauth2_session()` to pass the authentication method to `OAuth2Session`
  • Maintain backward compatibility with existing OAuth2 configurations

  ## Unit Tests
  Added unit test coverage with 3 new test methods:

  1. `test_create_oauth2_session_with_token_endpoint_auth_method()` - Tests explicit auth method setting (`client_secret_post`)
  2. `test_create_oauth2_session_with_default_token_endpoint_auth_method()` - Tests default behavior (`client_secret_basic`)
  3. `test_create_oauth2_session_oauth2_scheme_with_token_endpoint_auth_method()` - Tests with OAuth2 scheme using `client_secret_jwt`

  **Test Results:**
   16/16 OAuth2 credential utility tests passed
   240/240 auth module tests passed (no regressions)
   Tests cover both GOOGLE_AI and VERTEX variants
   Pylint score: 9.41/10

  ## Changes Made

  **src/google/adk/auth/auth_credential.py**
  - Added `token_endpoint_auth_method: Optional[str] = "client_secret_basic"` to `OAuth2Auth` class

  **src/google/adk/auth/oauth2_credential_util.py**
  - Updated `create_oauth2_session()` to pass `token_endpoint_auth_method` parameter to `OAuth2Session`

  **tests/unittests/auth/test_oauth2_credential_util.py**
  - Added 3 comprehensive test methods covering different authentication scenarios

  ## Backward Compatibility

   **Non-breaking change** - All existing OAuth2 configurations continue to work unchanged with the default `client_secret_basic` authentication method.

  ## Supported Authentication Methods

  - `client_secret_basic` (default) - Client credentials in Authorization header
  - `client_secret_post` - Client credentials in request body
  - `client_secret_jwt` - JWT with client secret
  - `private_key_jwt` - JWT with private key

Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2870 from sully90:feat/oauth2-token-endpoint-auth-method 04fe8244598f96b4e3366f0fc79382628382e9c2
PiperOrigin-RevId: 843739984
2025-12-12 10:16:36 -08:00
Xiang (Sean) Zhou 29c1115959 chore: Bumps version to v1.21.0 and updates CHANGELOG.md
Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com>
PiperOrigin-RevId: 843427582
2025-12-11 16:54:08 -08:00
Liang Wu 60e314a78f fix: Update SQLite database URL for async connection
The example is broken without the fix.

Co-authored-by: Liang Wu <wuliang@google.com>
PiperOrigin-RevId: 843424168
2025-12-11 16:42:10 -08:00
George Weale ee9b4ca908 feat: Add .yml to watched file extensions and add unit tests for AgentChangeEventHandler
Close #3834

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 843409166
2025-12-11 16:00:17 -08:00
George Weale db711cd789 fix: Redirect LiteLLM logs from stderr to stdout
LiteLLM's StreamHandlers output to stderr by default. In cloud environments like GCP, stderr output is treated as ERROR severity regardless of actual log level, causing INFO-level logs to be incorrectly classified as errors.

This change redirects LiteLLM loggers to stdout in two places:
- In `lite_llm.py`: Immediately after litellm import
- In `logs.py`: When `setup_adk_logger()` is called (with guard to check if litellm is imported)

Close #3824

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 843393874
2025-12-11 15:14:15 -08:00
George Weale 055dfc7974 fix: Normalize multipart content for LiteLLM's ollama_chat provider
LiteLLM's `ollama_chat` provider does not accept array-based content in messages. This change flattens multipart content by joining text parts or JSON-serializing non-text parts before sending the request to the LiteLLM completion API. This ensures compatibility with Ollama's chat endpoint.

Close #3727

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 843382361
2025-12-11 14:46:37 -08:00
Yifan Wang df8684734b chore: update adk web, fixes image not rendering, state not updating, update drop down box width and trace icons
Co-authored-by: Yifan Wang <wanyif@google.com>
PiperOrigin-RevId: 843378628
2025-12-11 14:36:40 -08:00
Google Team Member 9cccab4537 fix: installing dependencies for py 3.10
PiperOrigin-RevId: 843378433
2025-12-11 14:35:51 -08:00
Xuan Yang e1a7593ae8 feat: Add header_provider to OpenAPIToolset and RestApiTool
Fixes: https://github.com/google/adk-python/issues/3782

Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 843352147
2025-12-11 13:29:00 -08:00
Xuan Yang cb3244bb58 feat: Use json schema for function tool declaration when feature enabled
Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 843350330
2025-12-11 13:24:41 -08:00
George Weale 894d8c6c26 fix: Refactor LiteLLM response schema formatting for different models
The `_to_litellm_response_format` function now adapts the output format based on the provided model. Gemini models continue to use the "response_schema" key, while OpenAI-compatible models (including Azure OpenAI and Anthropic) now use the "json_schema" key as per LiteLLM's documentation for JSON mode. The schema name is also included in the "json_schema" format.

Close #3713
Close #3890

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 843326850
2025-12-11 12:20:11 -08:00
George Weale 99f893ae28 fix: Resolve project and credentials before creating Spanner client
Explicitly resolve the GCP project from arguments or environment variables before calling `spanner.Client`. This avoids redundant calls to `google.auth.default()` that newer versions of the Spanner library might make.

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 843320305
2025-12-11 12:03:10 -08:00
Google Team Member 7b2fe14dab feat: Upgrade BigQueryAgentAnalyticsPlugin to v2.0
Performance: Switched to BigQuery Storage Write API with async batching, reducing agent latency.
Multimodal: Native support for GCS offloading (ObjectRef) for images, video, and large text.
Reliability: Added connection pooling, retries, and a "rescue flush" for safe shutdown on Cloud Run.
Observability: Fixed distributed tracing hierarchy with ContextVars support.
PiperOrigin-RevId: 843062561
2025-12-10 23:04:01 -08:00
Xiang (Sean) Zhou 68d70488b9 chore: Add sample agent for interaction api integration
Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com>
PiperOrigin-RevId: 843037705
2025-12-10 21:37:03 -08:00
Xiang (Sean) Zhou c6320caaa5 feat: Support interactions API for calling models
Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com>
PiperOrigin-RevId: 843032402
2025-12-10 21:21:14 -08:00
Xiang (Sean) Zhou f0bdcaba44 chore: Update genAI SDK version
Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com>
PiperOrigin-RevId: 843030125
2025-12-10 21:13:52 -08:00
George Weale 7b356ddc1b feat: Add add_session_to_memory to CallbackContext and ToolContext
This change introduces an add_session_to_memory method to both CallbackContext and ToolContext, allowing agents and tools to explicitly trigger the saving of the current session to the memory service. This enables more fine-grained control over when session data is persisted for memory generation. A ValueError is raised if the memory service is not configured.

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 843021899
2025-12-10 20:47:08 -08:00
Krishna vamsi Dhulipalla 4111f85b61 docs(adk): fix run_async example and correct ticketId payload key
Merge https://github.com/google/adk-python/pull/3875

# Problem
The example in `contributing/samples/human_in_loop/README.md` shows:

```python
await runner.run_async(...)
```

However, `run_async` returns an **async generator**, so awaiting it raises:

```
TypeError: object async_generator can't be used in 'await' expression
```

Additionally, the example payload uses `"ticket-id"` while ADK tools and other examples use `"ticketId"`, creating a mismatch that breaks copy/paste usage.

# Solution
- Updated the snippet to consume the async generator correctly:

```python
async for event in runner.run_async(...):
    ...
```

- Aligned the payload key from `"ticket-id"` → `"ticketId"` for consistency with ADK schema and other examples.

These changes make the example runnable and consistent with the API’s actual behavior.

# Testing Plan
This PR is a **small documentation correction**, so no unit tests are required per contribution guidelines.

- Verified the corrected snippet manually to ensure it no longer raises `TypeError`.

# Checklist
- [x] I have read the 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. *(N/A – docs only)*
- [ ] I have added tests that prove my fix is effective or that my feature works. *(N/A – docs only)*
- [ ] New and existing unit tests pass locally with my changes. *(N/A – docs only)*
- [x] I have manually tested my changes end-to-end.
- [ ] Any dependent changes have been merged and published in downstream modules. *(N/A)*

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3875 from krishna-dhulipalla:docs/fix-adk-run_async-example 83fc5b430690b63b8b7bf1025ef03b0761264751
PiperOrigin-RevId: 842952362
2025-12-10 17:24:58 -08:00
Xuan Yang b23deeb9ab docs: Update adk docs update workflow to invoke the updater agent once per suggestion
Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 842789476
2025-12-10 10:45:05 -08:00
Xuan Yang 51a638b6b8 chore: Introduce build_function_declaration_with_json_schema to use pydantic to generate json schema for FunctionTool
Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 842783745
2025-12-10 10:31:09 -08:00
George Weale 6388ba3b20 fix: Avoid false positive "App name mismatch" warnings in Runner
When users instantiate LlmAgent directly (not subclassed), the origin inference incorrectly detected ADK's internal google/adk/agents/ path as a mismatch.

Use metadata from AgentLoader when available
Skip inference for google.adk.* module

Close #3143

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 842774292
2025-12-10 10:08:37 -08:00
Google Team Member 4f54660d6d fix: Update the code to work with either 1 event or more than 1 events
Update the code to work with either 1 event or more than 1 events.

PiperOrigin-RevId: 842406345
2025-12-09 14:48:25 -08:00
Xiang (Sean) Zhou ee743bd19a chore: Update component definition for triaging agent
Context: many issues related to local mult-agent system is tagged with a2a

Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com>
PiperOrigin-RevId: 842397159
2025-12-09 14:25:18 -08:00
Xuan Yang bab57296d5 chore: Migrate Google tools to use the new feature decorator
Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 842321126
2025-12-09 11:21:06 -08:00
Xuan Yang 1ae944b39d chore: Migrate computer to use the new feature decorator
Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 842287104
2025-12-09 10:03:43 -08:00
hoonji 32e87f6381 feat: Adds ADK EventActions to A2A response
Merge https://github.com/google/adk-python/pull/3631

### Link to Issue or Description of Change

**1. Link to an existing issue (if applicable):**

- Closes: #3630

**Solution:**
Adds [Event.actions](https://github.com/google/adk-python/blob/a3aa07722a7de3e08807e86fd10f28938f0b267d/src/google/adk/events/event.py#L51) to A2A event metadata during ADK -> A2A event conversion (to allow A2A event consumers to access important info like state_delta, artifact delta, etc)

### Testing Plan

`pytest ./tests/unittests` passes

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3631 from hoonji:main 31d3a49ad630bbd778aa4cf62dd9ccfc50f5b7af
PiperOrigin-RevId: 842274939
2025-12-09 09:32:36 -08:00
George Weale 56775afc48 fix: OpenAPI schema generation by skipping JSON schema for judge_model_config
Close #3750

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 841991676
2025-12-08 18:20:41 -08:00
Google Team Member cde7f7c243 feat: Allow overriding connection template
PiperOrigin-RevId: 841984336
2025-12-08 17:54:25 -08:00
Xuan Yang 82e6623fa9 fix: Add tool_name_prefix support to OpenAPIToolset
Fixes: https://github.com/google/adk-python/issues/3779

Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 841850614
2025-12-08 11:35:08 -08:00
Google Team Member 143ad44f8c fix: pass context to client inceptors
PiperOrigin-RevId: 840918430
2025-12-05 16:26:20 -08:00
Google Team Member f22bac0b20 feat: add Spanner execute sql query result mode
Add using the execute sql query return result as list of dictionaries.
In each dictionary the key is the column name and the value is the value of
the that column in a given row.

PiperOrigin-RevId: 840909555
2025-12-05 16:00:42 -08:00
George Weale de841a4a09 chore: Improve error message for missing invocation_id and new_message in run_async
Help with issue in #3801

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 840833736
2025-12-05 12:34:18 -08:00
Google Team Member b7ce5e17b6 fix: Yield event with error code when agent run raised A2AClientHTTPError
PiperOrigin-RevId: 840816236
2025-12-05 11:45:47 -08:00
Xuan Yang 9d2388a46f feat: Add SSL certificate verification configuration to OpenAPI tools
This change introduces a `verify` parameter to `RestApiTool` and `OpenAPIToolset`. This parameter allows users to configure how SSL certificates are verified when making API calls using the `requests` library. Options include providing a path to a CA bundle, disabling verification, or using a custom `ssl.SSLContext`. New methods `configure_verify` and `configure_verify_all` are added to update this setting after initialization. This is useful for environments with TLS-intercepting proxies.

Fixes: https://github.com/google/adk-python/issues/3720

Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 840809727
2025-12-05 11:30:03 -08:00
Kacper Jawoszek 711df01e73 feat(otel): remove experimental status from otel_to_cloud
Co-authored-by: Kacper Jawoszek <jawoszek@google.com>
PiperOrigin-RevId: 840703872
2025-12-05 06:39:07 -08:00
Google Team Member a9b853fe36 fix: ApigeeLLM support for Built-in tools like GoogleSearch, BuiltInCodeExecutor when calling Gemini models through Apigee
PiperOrigin-RevId: 840459113
2025-12-04 16:57:30 -08:00
George Weale 3d444cc953 chore: Ignore the .adk/ directory
Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 840387909
2025-12-04 13:54:17 -08:00
Google Team Member 82bd4f380b fix: Extract and propagate task_id in RemoteA2aAgent
The RemoteA2aAgent now extracts a "task_id" from the custom metadata of the last agent event in the session, alongside the existing "context_id". This task_id is then included in the A2AMessage sent to the remote A2A service.

Close #3765

PiperOrigin-RevId: 840375992
2025-12-04 13:25:46 -08:00
George Weale c557b0a1f2 fix: Update FastAPI and Starlette to fix CVE-2025-62727 (ReDoS vulnerability)
Update fastapi constraint from <0.119.0 to <0.124.0
Update starlette minimum version from >=0.46.2 to >=0.49.1

Closes #3822

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 840372879
2025-12-04 13:18:59 -08:00
davidkl97 f2735177f1 fix(oauth): add client id to token exchange
Merge https://github.com/google/adk-python/pull/2805

fixes #2806
add client id to token request, adhering to [RFC 6749](https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.3)

Co-authored-by: Xuan Yang <xygoogle@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2805 from davidkl97:fix/oauth-exchange-token 3366dce65ce4dd4fee649a81ab7e486689637442
PiperOrigin-RevId: 840369113
2025-12-04 13:09:42 -08:00
George Weale 2b64715505 fix: Handle string function responses in LiteLLM conversion
When converting `types.Content` with a `function_response` to LiteLLM's `ChatCompletionToolMessage`, if the response is already a string, use it directly. Otherwise, serialize the response to JSON. This prevents double-serialization of string payloads

Close #3676

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 840013822
2025-12-03 19:17:16 -08:00
George Weale 0a07a667e9 feat: Change service creation and add app name mapping for sessions
This change refactors how session, memory, and artifact services are created in the fast_api server, using the shared service_factory.

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 839997110
2025-12-03 18:27:16 -08:00
Doug Reid e9182e5eb4 feat: Add Gemma3Ollama model integration and a sample
This change introduces `Gemma3Ollama`, a new LLM model class for running Gemma 3 models locally via Ollama, leveraging LiteLLM. The function calling logic previously in the `Gemma` class has been refactored into a `GemmaFunctionCallingMixin` and is now used by both `Gemma` and `Gemma3Ollama`. A new sample application, `hello_world_gemma3_ollama`, is added to demonstrate using `Gemma3Ollama` with an agent. Unit tests for `Gemma3Ollama` are also included.

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

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 839996879
2025-12-03 18:27:07 -08:00
Lin-Nikaido b0c3cc6e36 fix: Support file uploads for OpenAI/Azure in LiteLLM
This change expands the supported file MIME types and introduces provider-specific handling for file uploads. For providers like OpenAI and Azure, inline file data is now uploaded via `litellm.acreate_file` to obtain a `file_id`, which is then used in the message content. Other providers continue to use base64 encoded file data. Affected functions have been updated to be asynchronous

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

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 839996848
2025-12-03 18:26:27 -08:00
George Weale bb8a269079 fix: Extract and propagate task_id in RemoteA2aAgent
The RemoteA2aAgent now extracts a "task_id" from the custom metadata of the last agent event in the session, alongside the existing "context_id". This task_id is then included in the A2AMessage sent to the remote A2A service.

Close #3765

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 839996774
2025-12-03 18:25:41 -08:00
Łukasz Lipiński 507424acb9 feat: Add location for table in agent events in plugin BigQueryAgentAnalytics
Merge https://github.com/google/adk-python/pull/3784

Co-authored-by: Xuan Yang <xygoogle@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3784 from lipinski:fix/add-location-to-bigqueryagentanalytics 8d88b2c3ad849b22e14a8d74185bfe348fd2503b
PiperOrigin-RevId: 839980070
2025-12-03 17:25:03 -08:00
Xuan Yang 92821b8dda docs: Remove the duplicated label instructions for the ADK triaging agent
Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 839970998
2025-12-03 16:55:35 -08:00
Ankur Sharma 960b206752 chore: Bumps version to v1.20.0 and updates CHANGELOG.md
Co-authored-by: Ankur Sharma <ankusharma@google.com>
PiperOrigin-RevId: 839930279
2025-12-03 15:03:25 -08:00
Bo Yang 5947c41b55 chore: Update component owners
Co-authored-by: Bo Yang <ybo@google.com>
PiperOrigin-RevId: 839896507
2025-12-03 13:40:48 -08:00
Shangjie Chen 9d918d45df feat!: Rollback the DB migration as it is breaking
Co-authored-by: Shangjie Chen <deanchen@google.com>
PiperOrigin-RevId: 839818479
2025-12-03 10:39:43 -08:00
George Weale 8c9105bf14 chore: Drop Python 3.9 support, set minimum to Python 3.10
Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 839799108
2025-12-03 09:56:22 -08:00
George Weale e02b9fb608 fix: Add a warning when deploying with the ADK Web UI enabled
The warning message shows that ADK Web is for development purposes only and should not be used in production, as it has access to all data. This warning is displayed when the `--with-ui` flag is used with `adk deploy` and `adk deploy to-gke`

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 839795361
2025-12-03 09:47:13 -08:00
Rohit Yanamadala 76dc169a83 fix: Add editLimit parameter to GraphQL query
Merge https://github.com/google/adk-python/pull/3771

Co-authored-by: Xuan Yang <xygoogle@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3771 from google:ryanaiagent-patch-1 a169e728af223594febc39299e046f2a195d606a
PiperOrigin-RevId: 839620767
2025-12-03 00:16:14 -08:00
Kathy Wu b638a48357 fix: Update API Registry Toolset to prod cloudapiregistry URL now that it is available
Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 839547174
2025-12-02 20:17:38 -08:00
Faraaz Ahmed b807d62fe3 feat(bigquery): Add labels support to BigQueryToolConfig for job tracking and monitoring
Merge https://github.com/google/adk-python/pull/3583

**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

**1. Link to an existing issue (if applicable):**

- Closes: #3582

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

_If applicable, please follow the issue templates to provide as much detail as
possible._

**Problem:**
Currently, the BigQuery tool in ADK does not provide a way for developers to add custom labels to BigQuery jobs created by their agents. This makes it difficult to:

Track and monitor BigQuery costs associated with specific agents or use cases
Organize and filter BigQuery jobs in the Google Cloud Console
Implement billing attribution and resource organization strategies
Differentiate between jobs from different environments (dev, staging, production)
While the tool automatically adds an internal adk-bigquery-tool label with the caller_id, there's no mechanism for users to add their own custom labels for tracking and monitoring purposes.

**Solution:**
Add a labels configuration field to BigQueryToolConfig that allows users to specify custom key-value pairs to be applied to all BigQuery jobs executed by the agent. The solution should:

Configuration Option: Add an optional labels parameter to BigQueryToolConfig accepting a dictionary of string key-value pairs
Validation: Ensure labels follow BigQuery's requirements (non-empty string keys, string values)
Job Application: Automatically apply configured labels to all BigQuery jobs alongside the existing internal labels Documentation: Provide clear documentation on how to use labels for tracking and monitoring

### Testing Plan

_Please describe the tests that you ran to verify your changes. This is required
for all PRs that are not small documentation or typo fixes._

**Unit Tests:**

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

_Please include a summary of passed `pytest` results._

```
pytest tests/unittests/tools/bigquery/test_bigquery_tool_config.py -v --tb=line -W ignore::UserWarning
========================================= test session starts ==========================================
platform darwin -- Python 3.11.14, pytest-9.0.1, pluggy-1.6.0 -- *****redacted******
cachedir: .pytest_cache
rootdir: *****redacted******
configfile: pyproject.toml
plugins: mock-3.15.1, anyio-4.11.0, xdist-3.8.0, langsmith-0.4.43, asyncio-1.3.0
asyncio: mode=Mode.AUTO, debug=False, asyncio_default_fixture_loop_scope=function, asyncio_default_test_loop_scope=function
collected 14 items

tests/unittests/tools/bigquery/test_bigquery_tool_config.py::test_bigquery_tool_config_experimental_warning PASSED                                                                                                   [  7%]
tests/unittests/tools/bigquery/test_bigquery_tool_config.py::test_bigquery_tool_config_invalid_property PASSED                                                                                                       [ 14%]
tests/unittests/tools/bigquery/test_bigquery_tool_config.py::test_bigquery_tool_config_invalid_application_name PASSED                                                                                               [ 21%]
tests/unittests/tools/bigquery/test_bigquery_tool_config.py::test_bigquery_tool_config_max_query_result_rows_default PASSED                                                                                          [ 28%]
tests/unittests/tools/bigquery/test_bigquery_tool_config.py::test_bigquery_tool_config_max_query_result_rows_custom PASSED                                                                                           [ 35%]
tests/unittests/tools/bigquery/test_bigquery_tool_config.py::test_bigquery_tool_config_valid_maximum_bytes_billed PASSED                                                                                             [ 42%]
tests/unittests/tools/bigquery/test_bigquery_tool_config.py::test_bigquery_tool_config_invalid_maximum_bytes_billed PASSED                                                                                           [ 50%]
tests/unittests/tools/bigquery/test_bigquery_tool_config.py::test_bigquery_tool_config_valid_labels PASSED                                                                                                           [ 57%]
tests/unittests/tools/bigquery/test_bigquery_tool_config.py::test_bigquery_tool_config_empty_labels PASSED                                                                                                           [ 64%]
tests/unittests/tools/bigquery/test_bigquery_tool_config.py::test_bigquery_tool_config_none_labels PASSED                                                                                                            [ 71%]
tests/unittests/tools/bigquery/test_bigquery_tool_config.py::test_bigquery_tool_config_invalid_labels_type PASSED                                                                                                    [ 78%]
tests/unittests/tools/bigquery/test_bigquery_tool_config.py::test_bigquery_tool_config_invalid_label_key_type PASSED                                                                                                 [ 85%]
tests/unittests/tools/bigquery/test_bigquery_tool_config.py::test_bigquery_tool_config_invalid_label_value_type PASSED                                                                                               [ 92%]
tests/unittests/tools/bigquery/test_bigquery_tool_config.py::test_bigquery_tool_config_empty_label_key PASSED                                                                                                        [100%]

==================================================================================================== 14 passed in 2.02s ====================================================================================================
```

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

_Please provide instructions on how to manually test your changes, including any
necessary setup or configuration. Please provide logs or screenshots to help
reviewers better understand the fix._

### 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

_Add any other context or screenshots about the feature request here._

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3583 from Faraaz1994:feature/bq_label 0fd7fe6a3b1ee20a36f73562e425d007b8d7dc9d
PiperOrigin-RevId: 839523588
2025-12-02 19:15:20 -08:00
Xuan Yang 3aef9a18b1 docs: Update ADK issue triaging agent to add component label before planned
Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 839391092
2025-12-02 12:54:44 -08:00
Shangjie Chen 77401132d1 chore: Add migration guide for DatabaseSessionService
Co-authored-by: Shangjie Chen <deanchen@google.com>
PiperOrigin-RevId: 839376632
2025-12-02 12:15:52 -08:00
Google Team Member 090711934f feat: add Spanner vector_store_similarity_search tool
The vector_store_similarity_search tool performs similarity search against data in a Spanner vector store table, using the provided Spanner tool settings for configuration.

PiperOrigin-RevId: 839352057
2025-12-02 11:18:57 -08:00
Hangfei Lin 8da61be45a fix: Flush pending transcriptions on turn/generation complete or interrupt for Gemini API
The Gemini API may not always send an explicit transcription finished signal. This change ensures that any buffered input or output transcription text is yielded as a finished transcription when a turn is completed, generation is complete, or the session is interrupted.

Also, refined the check for `event.partial` in runners.py to be more explicit.

Co-authored-by: Hangfei Lin <hangfei@google.com>
PiperOrigin-RevId: 839008606
2025-12-01 18:09:29 -08:00
George Weale 98d82935e6 fix: allow LlmAgent model to be provided via CodeConfig
LlmAgentConfig.model now accepts either a plain model string or a CodeConfig. This lets YAML configs pass a LiteLLM instance with managed API settings (e.g., api_base and fallbacks) so agents can hit KimiK2’s managed endpoint instead of only the default modelID.

Close #3579

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 838978654
2025-12-01 16:31:22 -08:00
George Weale 7e8eeca6aa fix: Add a FastAPI endpoint for saving artifacts
This change adds new `POST` endpoint `/apps/{app_name}/users/{user_id}/sessions/{session_id}/artifacts` to the ADK web server. This endpoint lets clients to save new artifacts associated with a specific session. The endpoint uses `SaveArtifactRequest` and returns `SaveArtifactResponse`, including the version and canonical URI of the saved artifact.

Close #1975

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 838977880
2025-12-01 16:29:18 -08:00
George Weale ed9da3fa45 feat!: Introduction of ADK folder for local session and artifact storage
Default CLI session storage to SQLite instead of in-memory

Previously, adk run and adk web used in-memory session storage by default, causing sessions to be lost on restart. Now sessions persist to .adk/session.db automatically. To use in-memory storage, pass --session-service-uri memory://

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 838975328
2025-12-01 16:22:35 -08:00
Keyur Joshi dd827af2ee chore: Move simulation related modules to a sub-package in evaluation
Co-authored-by: Keyur Joshi <keyurj@google.com>
PiperOrigin-RevId: 838904075
2025-12-01 13:16:12 -08:00
Rohit Yanamadala cb19d0714c fix: Optimize Stale Agent with GraphQL and Search API to resolve 429 Quota errors
Merge https://github.com/google/adk-python/pull/3700

### Description
This PR refactors the `adk_stale_agent` to address `429 RESOURCE_EXHAUSTED` errors encountered during workflow execution. The previous implementation was inefficient in fetching issue history (using pagination over the REST API) and lacked server-side filtering, causing excessive API calls and huge token consumption that breached Gemini API quotas.

The new implementation switches to a **GraphQL-first approach**, implements server-side filtering via the Search API, adds robust concurrency controls, and significantly improves code maintainability through modular refactoring.

### Root Cause of Failure
The previous workflow failed with the following error due to passing too much context to the LLM and processing too many irrelevant issues:
```text
google.genai.errors.ClientError: 429 RESOURCE_EXHAUSTED.
Quota exceeded for metric: generativelanguage.googleapis.com/generate_content_paid_tier_input_token_count
```
### Key Changes

#### 1. Optimization: REST → GraphQL (`agent.py`)
*   **Old:** Fetched issue comments and timeline events using multiple paginated REST API calls (`/timeline`).
*   **New:** Implemented `get_issue_state` using a single **GraphQL** query. This fetches comments, `userContentEdits`, and specific timeline events (Labels, Renames) in one network request.
*   **Refactoring:** The complex analysis logic has been decomposed into focused helper functions (_fetch_graphql_data, _build_history_timeline, _replay_history_to_find_state) for better readability and testing.
*   **Configurable:** Added GRAPHQL_COMMENT_LIMIT and GRAPHQL_TIMELINE_LIMIT settings to tune context depth
*   **Impact:** Drastically reduces the data payload size and eliminates multiple API round-trips, significantly lowering the token count sent to the LLM.

#### 2. Optimization: Server-Side Filtering (`utils.py`)
*   **Old:** Fetched *all* open issues via REST and filtered them in Python memory.
*   **New:** Uses the GitHub Search API (`get_old_open_issue_numbers`) with `created:<DATE` syntax.
*   **Impact:** Only fetches issue numbers that actually meet the age threshold, preventing the agent from wasting cycles and tokens on brand-new issues.

#### 3. Concurrency & Rate Limiting (`main.py` & `settings.py`)
*   **Old:** Sequential execution loop.
*   **New:** Implemented `asyncio.gather` with a configurable `CONCURRENCY_LIMIT` (set to 3).
*   **New:** Added `urllib3` retry strategies (exponential backoff) in `utils.py` to handle GitHub API rate limits (HTTP 429) gracefully.

#### 4. Logic Improvements ("Ghost Edits")
*   **New Feature:** The agent now detects "Ghost Edits" (where an author updates the issue description without posting a new comment).
*   **Action:** If a silent edit is detected on a stale candidate, the agent now alerts maintainers instead of marking it stale, preventing false positives.

### File Comparison Summary

| File | Change |
| :--- | :--- |
| `main.py` | Switched from `InMemoryRunner` loop to `asyncio` chunked processing. Added execution timing and API usage logging. |
| `agent.py` | Replaced REST logic with GraphQL query. Added logic to handle silent body edits. Decomposed giant get_issue_state into helper functions with docstrings. Added _format_days helper. |
| `utils.py` | Added `HTTPAdapter` with Retries. Added `get_old_open_issue_numbers` using Search API. |
| `settings.py` | Removed `ISSUES_PER_RUN`; added configuration for CONCURRENCY_LIMIT, SLEEP_BETWEEN_CHUNKS, and GraphQL limits. |
| `PROMPT_INSTRUCTIONS.txt` | Simplified decision tree; removed date calculation responsibility from LLM. |

### Verification
The new logic minimizes token usage by offloading date calculations to Python and strictly limiting the context passed to the LLM to semantic intent analysis (e.g., "Is this a question?").

*   **Metric Check:** The workflow now tracks API calls per issue to ensure we stay within limits.
*   **Safety:** Silent edits by users now correctly reset the "Stale" timer.
*   **Maintainability:** All complex logic is now isolated in typed helper functions with comprehensive docstrings.

Co-authored-by: Xuan Yang <xygoogle@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3700 from ryanaiagent:feat/improve-stale-agent 888064eff125ae74f7c3a9ad6c74f98de80243a2
PiperOrigin-RevId: 838885530
2025-12-01 12:25:51 -08:00
Ankur Sharma 2a1a41d3ec chore: Adding Eval Client label to model calls made during evals
Co-authored-by: Ankur Sharma <ankusharma@google.com>
PiperOrigin-RevId: 838857867
2025-12-01 11:20:46 -08:00
Eitan Yarmush 8e82838f1e fix: Refactor Anthropic integration to support both direct API and Vertex AI
This change introduces an `AnthropicLlm` base class for direct Anthropic API calls using `AsyncAnthropic`. The existing `Claude` class now inherits from `AnthropicLlm` and is specialized to use `AsyncAnthropicVertex` for models hosted on Vertex AI. The `messages.create` call is now properly awaited

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

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 838851026
2025-12-01 11:04:51 -08:00
Ishan Raj Singh 7edd7ea9b7 chore: Add warning for full resource path in VertexAiMemoryBankService agent_engine_id
This change updates the docstring for `agent_engine_id` to clarify that only the resource ID is expected. It also adds a warning log if the provided `agent_engine_id` contains a '/' character, suggesting it might be a full resource path, and provides guidance on how to extract the ID. Unit tests are added to verify the warning behavior.

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

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 838845022
2025-12-01 10:51:47 -08:00
Shangjie Chen 0094eea3ca feat!: Migrate DatabaseSessionService to use JSON serialization schema
Also provide a command line tool `adk migrate session` for DB migration

Addresses https://github.com/google/adk-python/discussions/3605
Addresses https://github.com/google/adk-python/issues/3681

To verify:
```
# Start one postgres DB
docker run --name my-postgres -d -e POSTGRES_DB=agent  -e POSTGRES_USER=agent  -e POSTGRES_PASSWORD=agent  -e PGDATA=/var/lib/postgresql/data/pgdata -v pgvolume:/var/lib/postgresql/data -p 5532:5432 postgres

# Connect to an old version of ADK and produce some query data
adk web --session_service_uri=postgresql://agent:agent@localhost:5532/agent

# Check out to the latest branch and restart ADK web
# You should see error log ask you to migrate the DB

# Start a new DB
docker run --name migration-test-db \
  -d \ --rm \ -e POSTGRES_DB=agent \ -e POSTGRES_USER=agent \ -e POSTGRES_PASSWORD=agent -e PGDATA=/var/lib/postgresql/data/pgdata -v migration_test_vol:/var/lib/postgresql/data -p 5533:5432 postgres

# DB Migration
adk migrate session \
  --source_db_url="postgresql://agent:agent@localhost:5532/agent" \
  --dest_db_url="postgresql://agent:agent@localhost:5533/agent"

# Run ADK web with the new DB
adk web --session_service_uri=postgresql+asyncpg://agent:agent@localhost:5533/agent

# You should see the data from old DB is migrated
```

Co-authored-by: Shangjie Chen <deanchen@google.com>
PiperOrigin-RevId: 837341139
2025-11-26 19:49:08 -08:00
Xuan Yang 786aaed335 feat: Support streaming function call arguments in progressive SSE streaming feature
Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 837172244
2025-11-26 10:15:31 -08:00
George Weale 73e5687b9a fix: Remove 'per_agent' from kwargs when using remote session service URIs
Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 837169299
2025-11-26 10:08:13 -08:00
Kathy Wu ec4ccd718f feat: Create APIRegistryToolset to add tools from Cloud API registry to agent
This calls the cloudapiregistry.googleapis.com API to get MCP tools from the project's registry, and adds them to ADK.

Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 837166909
2025-11-26 10:01:58 -08:00
George Weale f283027e92 feat: expose service URI flags
Adds the shared adk_services_options decorator to adk run and other commands so developers can pass session/artifact URIs from the CLI

Has new warning for the unsupported memory service on adk run, and removes the legacy --session_db_url/--artifact_storage_uri flags with tests

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 836743358
2025-11-25 11:13:03 -08:00
George Weale 06e6fc9132 feat: wire runtime entrypoints to service factory defaults
This change routes adk run and the FastAPI server through the new session/artifact service factory, keeps the default experience backed by per-agent .adk storage

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 836733234
2025-11-25 10:47:44 -08:00
happyryan 5453b5bfde fix: Allow image parts in user messages for Anthropic Claude
Previously, image parts were always filtered out when converting content to Anthropic message parameters. This change updates the logic to only filter out image parts and log a warning when the content role is not "user". This enables sending image data as part of user prompts to Claude models

Merges: https://github.com/google/adk-python/pull/3286

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 836725196
2025-11-25 10:30:08 -08:00
Hangfei Lin 5cad8a7f58 fix: Throw warning when using transparent session resumption in ADK Live for Gemini API key
transparent session resumption is only supported in Vertex AI APIs

Co-authored-by: Hangfei Lin <hangfei@google.com>
PiperOrigin-RevId: 836715170
2025-11-25 10:04:57 -08:00
Virtuoso633 d29261a3dc feat(models): Enable multi-provider support for Claude and LiteLLM
Merges: https://github.com/google/adk-python/pull/2810

Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 836706608
2025-11-25 09:46:44 -08:00
Bastien Jacot-Guillarmod e6be5bc9c6 fix: Add type annotations to Runner.__aenter__
PiperOrigin-RevId: 836614561
2025-11-25 04:45:00 -08:00
Om Kute c6e7d6b16a feat(tools): Add debug logging to VertexAiSearchTool
Merge https://github.com/google/adk-python/pull/3284

**Problem:**
When debugging agents that utilize the `VertexAiSearchTool`, it's currently difficult to inspect the specific configuration parameters (datastore ID, engine ID, filter, max_results, etc.) being passed to the underlying Vertex AI Search API via the `LlmRequest`. This lack of visibility can hinder troubleshooting efforts related to tool configuration.

**Solution:**
This PR enhances the `VertexAiSearchTool` by adding a **debug-level log statement** within the `process_llm_request` method. This log precisely records the parameters being used for the Vertex AI Search configuration just before it's appended to the `LlmRequest`.

This provides developers with crucial visibility into the tool's runtime behavior when debug logging is enabled, significantly improving the **debuggability** of agents using this tool. Corresponding unit tests were updated to rigorously verify this new logging output using `caplog`. Additionally, minor fixes were made to the tests to resolve Pydantic validation errors.

Co-authored-by: Xuan Yang <xygoogle@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3284 from omkute10:feat/add-logging-vertex-search-tool 199c12bf00a57abe202401591088c0423b39b928
PiperOrigin-RevId: 836419886
2025-11-24 17:29:50 -08:00
Xuan Yang b331d97dfb docs: Remove the list_unlabeled_issues tool from the issue triaging agent
Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 836416597
2025-11-24 17:14:51 -08:00
qieqieplus 4a42d0d9d8 feat: Add enum constraint to agent_name for transfer_to_agent
Merge https://github.com/google/adk-python/pull/2437

Current implementation of `transfer_to_agent` doesn't enforce strict constraints on agent names, we could use JSON Schema's enum definition to implement stricter constraints.

Co-authored-by: Xuan Yang <xygoogle@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2437 from qieqieplus:main 052e8e73b9d61c0998573a2077f15864873d0dd7
PiperOrigin-RevId: 836410397
2025-11-24 16:51:36 -08:00
Shangjie Chen 728abe4d81 feat(agents): Add warning for duplicate sub-agent names
Co-authored-by: Shangjie Chen <deanchen@google.com>
PiperOrigin-RevId: 836409638
2025-11-24 16:48:45 -08:00
Google Team Member 4eb2a11403 fix: fix bug where remote a2a agent wasn't using its a2a part converter
PiperOrigin-RevId: 836399603
2025-11-24 16:18:18 -08:00
Kristen Pereira a1c09b724b fix: Windows Path Handling and Normalize Cross-Platform Path Resolution in AgentLoader
Merge https://github.com/google/adk-python/pull/3609

Co-authored-by: George Weale <gweale@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3609 from p-kris10:fix/windows-cmd 8cb0310bd4450097a0a7714eaac6521b6a447442
PiperOrigin-RevId: 836395714
2025-11-24 16:07:40 -08:00
AlexeyChernenkoPlato cf21ca3584 fix: double function response processing issue
Merge https://github.com/google/adk-python/pull/2588

## Description
Fixes an issue in `base_llm_flow.py` where, in Bidi-streaming (live) mode, the multi-agent structure causes duplicated responses after tool calling.

## Problem
In Bidi-streaming (live) mode, when utilizing a multi-agent structure, the leaf-level sub-agent and its parent agent both process the same function call response, leading to duplicate replies. This duplication occurs because the parent agent's live connection remains open while initiating a new connection with the child agent.

## Root Cause
The issue originated from the placement of agent transfer logic in the `_postprocess_live` method at lines 547-557. When a `transfer_to_agent` function call was made:

1. The function response was processed in `_postprocess_live`
2. A recursive call to `agent_to_run.run_live` was initiated
3. This prevented the closure of the parent agent's connection at line 175 of the `run_live` method, as that code path was never reached
4. Both the parent and child agents remained active, causing both to process subsequent function responses

## Solution
This PR addresses the issue by ensuring the parent agent's live connection is closed before initiating a new one with the child agent. Changes made:

**Connection Management**: Moved the agent transfer logic from `_postprocess_live` method to the `run_live` method, specifically:
- Removed agent transfer handling from lines 547-557 in `_postprocess_live`
- Added agent transfer handling after connection closure at lines 176-184 in `run_live`

**Code Refactoring**: The agent transfer now occurs in the proper sequence:
1. Parent agent processes the `transfer_to_agent` function response
2. Parent agent's live connection is properly closed (line 175)
3. New connection with child agent is initiated (line 182)
4. Child agent handles subsequent function calls without duplication

**Improved Flow Control**: This ensures that each agent processes function call responses without duplication, maintaining proper connection lifecycle management in multi-agent structures.

## Testing
To verify this fix works correctly:

1. **Multi-Agent Structure Test**: Set up a multi-agent structure with a parent agent that transfers to a child agent via `transfer_to_agent` function call
2. **Bidi-Streaming Mode**: Enable Bidi-streaming (live) mode in the configuration
3. **Function Call Verification**: Trigger a function call that results in agent transfer
4. **Response Monitoring**: Verify that only one response is generated (not duplicated)
5. **Connection Management**: Confirm that parent agent's connection is properly closed before child agent starts

**Expected Behavior**:
- Single function response per call
- Clean agent handoffs without connection leaks
- Proper connection lifecycle management

## Backward Compatibility
This change is **fully backward compatible**:
- No changes to public APIs or method signatures
- Existing single-agent flows remain unaffected
- Non-live (regular async) flows continue to work as before
- Only affects the internal flow control in live multi-agent scenarios

Co-authored-by: Hangfei Lin <hangfei@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2588 from AlexeyChernenkoPlato:fix/double-function-response-processing-issue 3339260a4e007251137d199bdcef0ddef4487b03
PiperOrigin-RevId: 835619170
2025-11-22 09:34:05 -08:00
Shangjie Chen a9a418ba87 fix: Remove distructive validation
Co-authored-by: Shangjie Chen <deanchen@google.com>
PiperOrigin-RevId: 835466120
2025-11-21 20:56:39 -08:00
George Weale 2e1f730c3b fix: Update LiteLLM system instruction role from "developer" to "system"
This change replaces the use of `ChatCompletionDeveloperMessage` with `ChatCompletionSystemMessage` and sets the role to "system" for providing system instructions to LiteLLM models

Close #3657

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 835388738
2025-11-21 15:56:04 -08:00
Xuan Yang 52674e7fac fix: Update AgentTool to use Agent's description when input_schema is provided in FunctionDeclaration
Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 835379243
2025-11-21 15:25:27 -08:00
davidkl97 777dba3033 feat(tools): Add an option to disallow propagating runner plugins to AgentTool runner
Merge https://github.com/google/adk-python/pull/2779

Fixes #2780

### testing plan
not available as is doesn't introduce new functionality

Co-authored-by: Wei Sun (Jack) <weisun@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2779 from davidkl97:feature/agent-tool-plugins a602c808789f3daeed6244e352a6fb8fb6972de3
PiperOrigin-RevId: 835366974
2025-11-21 14:49:36 -08:00
saroj rout 2247a45922 feat(agents): add validation for unique sub-agent names (#3557)
Merge https://github.com/google/adk-python/pull/3576

**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

**1. Link to an existing issue (if applicable):**

- Closes: #3557
- Related: #_issue_number_

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

_If applicable, please follow the issue templates to provide as much detail as
possible._

**Problem:**
When creating a BaseAgent with multiple sub-agents, there was no validation to ensure that all sub-agents have unique names. This could lead to confusion when trying to find or reference specific sub-agents by name, as duplicate names would make it ambiguous which agent is being referenced.
**Solution:**
Added a @field_validator for the sub_agents field in BaseAgent that validates all sub-agents have unique names. The validator:
Checks for duplicate names in the sub-agents list
Raises a ValueError with a clear error message listing all duplicate names found
Returns the validated list if all names are unique
Handles edge cases like empty lists gracefully

### Testing Plan

_Please describe the tests that you ran to verify your changes. This is required
for all PRs that are not small documentation or typo fixes._

**Unit Tests:**

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

_Please include a summary of passed `pytest` results._
Added 4 new test cases in tests/unittests/agents/test_base_agent.py:
test_validate_sub_agents_unique_names_single_duplicate: Verifies that a single duplicate name raises ValueError
test_validate_sub_agents_unique_names_multiple_duplicates: Verifies that multiple duplicate names are all reported in the error message
test_validate_sub_agents_unique_names_no_duplicates: Verifies that unique names pass validation successfully
test_validate_sub_agents_unique_names_empty_list: Verifies that empty sub-agents list passes validation
All tests pass locally. You can run with:
pytest tests/unittests/agents/test_base_agent.py::test_validate_sub_agents_unique_names_single_duplicate tests/unittests/agents/test_base_agent.py::test_validate_sub_agents_unique_names_multiple_duplicates tests/unittests/agents/test_base_agent.py::test_validate_sub_agents_unique_names_no_duplicates tests/unittests/agents/test_base_agent.py::test_validate_sub_agents_unique_names_empty_list -v
**Manual End-to-End (E2E) Tests:**

_Please provide instructions on how to manually test your changes, including any
necessary setup or configuration. Please provide logs or screenshots to help
reviewers better understand the fix._

Test Case 1: Duplicate names should raise error
from google.adk.agents import Agent

agent1 = Agent(name="sub_agent", model="gemini-2.5-flash")
agent2 = Agent(name="sub_agent", model="gemini-2.5-flash")  # Same name

# This should raise ValueError
try:
    parent = Agent(
        name="parent",
        model="gemini-2.5-flash",
        sub_agents=[agent1, agent2]
    )
except ValueError as e:
    print(f"Expected error: {e}")
    # Output: Found duplicate sub-agent names: `sub_agent`. All sub-agents must have unique names.

Test Case 2: Unique names should work
from google.adk.agents import Agent

agent1 = Agent(name="agent1", model="gemini-2.5-flash")
agent2 = Agent(name="agent2", model="gemini-2.5-flash")

# This should work without error
parent = Agent(
    name="parent",
    model="gemini-2.5-flash",
    sub_agents=[agent1, agent2]
)
print("Success: Unique names validated correctly")

### 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

This change adds validation at the BaseAgent level, so it automatically applies to all agent types that inherit from BaseAgent (e.g., LlmAgent, LoopAgent, etc.). The validation uses Pydantic's field validator system, which runs during object initialization, ensuring the constraint is enforced early and consistently.
The error message clearly identifies which names are duplicated, making it easy for developers to fix the issue:

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3576 from sarojrout:feat/validate-unique-sub-agent-names 07adf1f9a5fc935389eb9dfa3cbc1311f551ebe3
PiperOrigin-RevId: 835358118
2025-11-21 14:24:07 -08:00
Adrian Altermatt 609c6172d9 docs: too many E(inv=2, role=user) plus reformatting
Merge https://github.com/google/adk-python/pull/3538

Main change from:
E(inv=2, role=user), E(inv=2, role=model), E(inv=2, role=user),

To:
E(inv=2, role=user), E(inv=2, role=model)

I think the last E(inv=2, role=user) was wrong. Also reformatted.

Co-authored-by: Hangfei Lin <hangfei@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3538 from adrianad:patch-1 627b933bdc3e00e45f704edf95448281e32d127c
PiperOrigin-RevId: 835346467
2025-11-21 13:49:01 -08:00
Giorgio Boa 9d331abb4e ci: bump action scripts versions
Merge https://github.com/google/adk-python/pull/3638

Thanks for this great project 👏
This PR updates the GitHub actions dependencies to the latest version.

### 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.

Co-authored-by: Hangfei Lin <hangfei@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3638 from gioboa:ci/actions-versions f7d6f3b5233e8cb135c8af88d5b6e0ead8382055
PiperOrigin-RevId: 835343177
2025-11-21 13:39:46 -08:00
Rohit Yanamadala 23f1d8914a docs(agent): Implement stale issue bot
Merge https://github.com/google/adk-python/pull/3546

Co-authored-by: Xuan Yang <xygoogle@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3546 from ryanaiagent:feat/stale-issue-agent bcf45098c1c6406b4a42228e4a8ef02f12840425
PiperOrigin-RevId: 835327931
2025-11-21 12:54:20 -08:00
Shangjie Chen 5583bb819b chore: Update MCP requirement to >1.10.0
Resolves https://github.com/google/adk-python/issues/3644

Co-authored-by: Shangjie Chen <deanchen@google.com>
PiperOrigin-RevId: 835302097
2025-11-21 11:43:32 -08:00
Shangjie Chen 89aee16f16 chore: Allow google-cloud-storage >=2.18.0
Resolves https://github.com/google/adk-python/issues/3641

Co-authored-by: Shangjie Chen <deanchen@google.com>
PiperOrigin-RevId: 835292931
2025-11-21 11:18:40 -08:00
Max Ind a4453c884c fix: adk deploy agent_engine uses correct URI during an update
Co-authored-by: Max Ind <maxind@google.com>
PiperOrigin-RevId: 835269976
2025-11-21 10:17:57 -08:00
Google Team Member 11df1e886d fix: Change pass to yield in BaseLlmConnection.receive
PiperOrigin-RevId: 835268090
2025-11-21 10:12:19 -08:00
Austin Wise 59eba96ea4 fix: Remove unused, incorrect import
PiperOrigin-RevId: 835247166
2025-11-21 09:10:04 -08:00
Google Team Member 631b58336d fix: Content is marked non empty if its first part contains text or inline_data or file_data or func call/response
PiperOrigin-RevId: 835063599
2025-11-20 22:19:28 -08:00
George Weale a3e4ad3cd1 fix: Update session last update time when appending events
The `database_session_service` now updates the `update_time` of a session to the event's timestamp when an event is appended

Close #2721

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 834994070
2025-11-20 18:27:02 -08:00
George Weale 848fdbef7c fix: Filter out None values from enum lists in schema generation
Close #3552

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 834967220
2025-11-20 17:02:45 -08:00
George Weale 31cfa3b82b feat: Capture thinking output, forward raw payloads, and fix exec locals
LlmResponse/Event now keep both provider reasoning output and the raw vendor payload so callbacks and loggers can inspect hidden “thoughts” or trace bugs without rewriting adapters.

LiteLLM’s adapter and streaming loop emit reasoning chunks alongside text and aggregate them into final events -> all responses now carry a JSON-safe copy of the source payload for debug. UnsafeLocalCodeExecutor uses the documented exec(code, globals, globals) form, letting helper functions defined inside snippets call each other.

Close #1749

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 834956847
2025-11-20 16:30:19 -08:00
Dylan b57fe5f459 feat(web): add list-apps-detailed endpoint
Merge https://github.com/google/adk-python/pull/3430

**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

**1. Link to an existing issue (if applicable):**

- Closes: #3429

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

_If applicable, please follow the issue templates to provide as much detail as
possible._

**Problem:**
The existing `/list-apps` endpoint only returns the name of the folder that each agent is in

**Solution:**
This adds a new endpoint `/list-apps-detailed` which will load each agent using the existing `AgentLoader.load_agent` method, and then return the folder name, display name (with underscores replaced with spaces for a more readable version), description, and the agent type.

This does introduce overhead if you had multiple agents since they all need to be loaded, but by maintaining the existing `/list-apps` endpoint, users can choose which one to hit if they don't want to load all agents. Since the existing `load_agents` method will cache results, there's only a penalty on the first hit.

### Testing Plan

Created a unit test for this, similar to the `/list-apps`. Also tested this with my own ADK instance to verify it loaded correctly.
```
curl --location "localhost:8000/list-apps-detailed"
```
```json
{
    "apps": [
        {
            "name": "agent_1",
            "displayName": "Agent 1",
            "description": "A test description for a test agent",
            "agentType": "package"
        },
        {
            "name": "agent_2",
            "displayName": "Agent 2",
            "description": "A test description for a test agent ",
            "agentType": "package"
        },
        {
            "name": "agent_3",
            "displayName": "Agent 3",
            "description": "A test description for a test agent",
            "agentType": "package"
        }
    ]
}

```

**Unit Tests:**

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

 3054 passed, 2383 warnings in 46.96s

### 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.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3430 from dylan-apex:more-detailed-list-apps e6864fd61a673da5fd2fb28d2d7d72cb90f5af0a
PiperOrigin-RevId: 834907771
2025-11-20 14:15:06 -08:00
Issac cd54f48fed fix: fix paths for public docs
Merge https://github.com/google/adk-python/pull/3572

**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

**1. Link to an existing issue (if applicable):**

N/A

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

**Problem:**
Docs fix

### Checklist

- [ ] I have read the [CONTRIBUTING.md](https://github.com/google/adk-python/blob/main/CONTRIBUTING.md) document.
- [ ] 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.

Co-authored-by: Hangfei Lin <hangfei@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3572 from issacg:patch-1 b7c7ed46ff0fb018f4da1537535eff27c323daf5
PiperOrigin-RevId: 834864431
2025-11-20 12:26:43 -08:00
George Weale 084c2de0da fix: Make sure request bodies without explicit names are named 'body'
The `Parameter` class now provides default Python names based on the parameter location when the original name is empty. This prevents parameters from having an empty string as their Python name, especially for request bodies defined without a top-level name.

Close #2213

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 834850255
2025-11-20 11:48:46 -08:00
George Weale bf8b85da52 fix: save sessions with camelCase aliases
Make sure that the adk run --save_session writes session JSON using the Pydantic camelCase aliases (by_alias=True), matching ADK Web and keeping session files consistent

Close #3558

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 834847209
2025-11-20 11:41:41 -08:00
Holt Skinner caf23ac49f docs: Add Code Wiki badge to README
Merge https://github.com/google/adk-python/pull/3603

**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

**1. Link to an existing issue (if applicable):**

- Closes: #_issue_number_
- Related: #_issue_number_

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

_If applicable, please follow the issue templates to provide as much detail as
possible._

**Problem:**
_A clear and concise description of what the problem is._

**Solution:**
_A clear and concise description of what you want to happen and why you choose
this solution._

### Testing Plan

_Please describe the tests that you ran to verify your changes. This is required
for all PRs that are not small documentation or typo fixes._

**Unit Tests:**

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

_Please include a summary of passed `pytest` results._

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

_Please provide instructions on how to manually test your changes, including any
necessary setup or configuration. Please provide logs or screenshots to help
reviewers better understand the fix._

### Checklist

- [ ] I have read the [CONTRIBUTING.md](https://github.com/google/adk-python/blob/main/CONTRIBUTING.md) document.
- [ ] 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.

### Additional context

_Add any other context or screenshots about the feature request here._

Co-authored-by: Hangfei Lin <hangfei@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3603 from holtskinner:patch-1 833405898b747438e3f8a1b8c34095e25135fca3
PiperOrigin-RevId: 834805195
2025-11-20 10:00:29 -08:00
Kathy Wu a3aa07722a fix: Update the retry_on_closed_resource decorator to retry on all errors
Retrying only on closed_resource error is not enough to be reliable for production environments due to the other network errors that may occur -- remote protocol error, read timeout, etc. We will update this to retry on all errors. Since it is only a one-time retry, it should not affect latency significantly. Fixes https://github.com/google/adk-python/issues/2561.

Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 834514264
2025-11-19 17:50:49 -08:00
Shangjie Chen a6e4d6c0d9 chore: Bumps version to v1.19.0 and updates CHANGELOG.md
Co-authored-by: Shangjie Chen <deanchen@google.com>
PiperOrigin-RevId: 834503873
2025-11-19 17:12:56 -08:00
Divyansh Shukla 8fc6128b62 fix: Fix out of bounds error in _run_async_impl
PiperOrigin-RevId: 834492696
2025-11-19 16:36:35 -08:00
Xuan Yang 679d543f8e docs: Update ADK triaging agent to only triage planned issues
It also enables the ADK triaging agent to run periodically on planned but not triaged issues.

Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 834489103
2025-11-19 16:26:55 -08:00
Google Team Member f13a11e1dc feat: Propagate application_name set for the BigQuery Tools as BigQuery job labels
This change will help the tools user identify per agent job usage in BQ console and INFORMATION_SCHEMA views. This change fulfills the feature request #3582. Here is a demo after change: screen/C6YB4ge2FM2ZREi.

PiperOrigin-RevId: 834480140
2025-11-19 16:02:32 -08:00
George Weale 131d39c3db fix: Change name for builder agent
When this agent was built before the agent name was changed in the build script and accepted like that from the VB so changed to set into that form

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 834479335
2025-11-19 16:00:51 -08:00
George Weale 12db84f5cd fix: Remove app name from FileArtifactService directory structure
Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 834462462
2025-11-19 15:12:48 -08:00
Ankur Sharma dc3f60cc93 chore: Plumb memory service from LocalEvalService to EvaluationGenerator
Co-authored-by: Ankur Sharma <ankusharma@google.com>
PiperOrigin-RevId: 834398581
2025-11-19 12:28:52 -08:00
Yifan Wang 14e3802643 chore: update adk web to match main branch
Co-authored-by: Yifan Wang <wanyif@google.com>
PiperOrigin-RevId: 834378696
2025-11-19 11:37:29 -08:00
Shangjie Chen ffbab4cf4e chore: Add BigQuery related label handling
Co-authored-by: Shangjie Chen <deanchen@google.com>
PiperOrigin-RevId: 834375503
2025-11-19 11:29:40 -08:00
George Weale b2b7f2d6aa chore: Move adk_agent_builder_assistant to built_in_agents
Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 834371390
2025-11-19 11:18:37 -08:00
Hangfei Lin 3ad30a58f9 fix: Add transcription fields to session events
This change introduces `input_transcription` and `output_transcription` fields to session events, enabling the storage and retrieval of transcription data in both the database and Vertex AI session services.

Closes #3172

Co-authored-by: Hangfei Lin <hangfei@google.com>
PiperOrigin-RevId: 834366848
2025-11-19 11:08:38 -08:00
George Weale 0ac35b23dc docs: Add path sanitization for model-generated file paths
Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 834344352
2025-11-19 10:13:16 -08:00
Mimi Sun 857de04deb feat: update save_files_as_artifacts_plugin to never keep inline data
PiperOrigin-RevId: 834328794
2025-11-19 09:36:42 -08:00
Max Ind e15e19da05 fix: remove hardcoded google-cloud-aiplatform version in agent engine requirements
This fixes e.g. `--trace_to_cloud flag`

Co-authored-by: Max Ind <maxind@google.com>
PiperOrigin-RevId: 834190152
2025-11-19 02:01:34 -08:00
Michael Jones 0cc3d6d6d5 Feat/expose mcps streamable http custom httpx factory parameter (#2997)
* feat: Add support for custom HTTPX client factory in StreamableHTTPConnectionParams

* Update src/google/adk/tools/mcp_tool/mcp_session_manager.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* unit tested mock

* provide default - httpx client factory can't be none

* feat: Enhance StreamableHTTPConnectionParams with httpx_client_factory attribute

* fmt

* fmt

* refactor: Rename test_init_with_streamable_http_none_httpx_factory to test_init_with_streamable_http_default_httpx_factory for clarity

* isort

* fmt

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Kathy Wu <108756731+wukath@users.noreply.github.com>
2025-11-18 11:09:48 -08:00
Hangfei Lin b5f5df9fa8 fix(runners): Ensure event compaction completes by awaiting task
Fixes https://github.com/google/adk-python/issues/3174

The event compaction process, configured via `EventsCompactionConfig`, was
previously scheduled as a background task using `asyncio.create_task`.
Because Python's `asyncio.create_task` only holds a weak reference to
the created task and no strong reference was maintained by ADK, the
compaction task could be garbage-collected before it finished executing.
This resulted in event compaction failing silently or only partially
running, preventing session history from being summarized.

### Approaches Considered

Two approaches were considered to fix this:

1.  **`asyncio.create_task` + Reference:** Create the task with `create_task` and store a strong reference to it (e.g., in a `set` on the [Runner](http://_vscodecontentref_/0) instance), removing it only when complete via `task.add_done_callback()`.
    *   **Pros:** The [run_async](http://_vscodecontentref_/1) async generator finishes immediately after yielding the last agent event.
    *   **Cons:** Adds complexity to the Runner state; background task failures are silent to the [run_async](http://_vscodecontentref_/2) caller; requires enhancement to `runner.close()` to correctly manage pending tasks on shutdown.
2.  **`await`:** Directly `await` the compaction coroutine at the end of [run_async](http://_vscodecontentref_/3) after all agent events have been yielded.
    *   **Pros:** Simple to implement; ensures compaction runs to completion; failures during compaction propagate immediately to the [run_async](http://_vscodecontentref_/4) caller, making them visible and easier to debug.
    *   **Cons:** The `async for` loop iterating over [run_async](http://_vscodecontentref_/5) will not terminate until compaction finishes.

### Decision

This change implements the `await` approach. Although it means the `async for` loop takes longer to terminate when compaction occurs, it was chosen for its **simplicity and robustness**. Ensuring that compaction either succeeds or fails visibly is preferable to silent background failures.

All agent response events are yielded *before* compaction starts, so there is **no user-perceived delay in receiving the agent's answer** for the current turn.

### Integration Note for Users

Because compaction is now awaited, code consuming events via `async for event in runner.run_async(...)` will only finish iterating *after* compaction is complete (if compaction is triggered for that invocation).

If your application only needs the agent's response to proceed (e.g., displaying a message in a UI and allowing the user to reply), you can process events as they arrive and initiate the next turn without waiting for the `async for` loop to fully terminate. A new call to [run_async](http://_vscodecontentref_/6) for the next user query can be made immediately and will execute concurrently.

**Example:**

```python
async def handle_agent_turn(runner, message):
    print("Agent is thinking...")
    async for event in runner.run_async(user_id='...', session_id='...', new_message=message):
        # Stream events to UI, log, etc.
        if event.author == 'model' and event.content and event.content.parts[0].text:
            print(f"Agent response: {event.content.parts[0].text}")
            # The agent has provided a text response.
            # The application can now enable user input for the next turn,
            # even though this async for loop might not finish immediately
            # if compaction is running.
    print("Invocation complete (including compaction if any).")

# In your application:
# A new call to handle_agent_turn(runner, next_message) can be made
# as soon as the user provides the next input, without waiting for
# the previous call's generator to be exhausted.

Co-authored-by: Hangfei Lin <hangfei@google.com>
PiperOrigin-RevId: 833885375
2025-11-18 10:57:50 -08:00
George Weale a12ae812d3 feat: Add service factory for configurable session and artifact backends
this creates service_factory to handle .adk folder changes (including per-agent .adk defaults and in-memory/custom URI handling)

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 833875524
2025-11-18 10:35:31 -08:00
Shangjie Chen 8eb1bdbc58 chore: Add demo for rewind
Co-authored-by: Shangjie Chen <deanchen@google.com>
PiperOrigin-RevId: 833871446
2025-11-18 10:26:15 -08:00
George Weale 236f562cd2 fix: Load agent/app before creating session
This change loads the agent or app from the specified directory before creating the session. This allows using the correct application name (from the `App` object if applicable) when initializing the session, rather than always defaulting to the folder name. The variable `root_agent` is also renamed to `agent_or_app` to better reflect that it can be either an Agent or an App

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 833839070
2025-11-18 09:09:22 -08:00
Google Team Member 4dd28a3970 feat: Add id and custom_metadata fields to MemoryEntry
PiperOrigin-RevId: 833581243
2025-11-17 18:34:03 -08:00
Ankur Sharma b2c45f8d91 chore: Enhance the messaging with possible fixes for RESOURCE_EXHAUSTED errors from Gemini
Co-authored-by: Ankur Sharma <ankusharma@google.com>
PiperOrigin-RevId: 833538475
2025-11-17 16:15:56 -08:00
Google Team Member 5ac5129fb0 feat: Enhance BQ Plugin Schema, Error Handling, and Logging
This update enhances the BigQuery agent analytics plugin:

*   **Enhanced Error Logging:** Improved error messages for schema mismatches.
*   **Reordered Logging Content:** Prioritized metadata in `before_model_callback`.

PiperOrigin-RevId: 833508755
2025-11-17 15:00:38 -08:00
Google Team Member c642f13f21 feat: Thread custom_metadata through forwarding artifact service
PiperOrigin-RevId: 833496193
2025-11-17 14:25:30 -08:00
Kathy Wu a48a1a9e88 fix: Improve logic for checking if a MCP session is disconnected
Currently logic to check for a disconnected session only checks for certain headers but doesn't detect all cases, leading to situations where it tries to connect to a session that is down. This adds logic so that we ping the server to check if it is disconnected. Fixes https://github.com/google/adk-python/issues/3321.

Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 833487825
2025-11-17 14:05:02 -08:00
Xuan Yang a5ac1d5e14 feat: Add progressive SSE streaming feature
Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 833483804
2025-11-17 13:55:38 -08:00
George Weale 0ec01956e8 fix: keep vertex session event history intact
Close #3504

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 833417574
2025-11-17 11:13:08 -08:00
George Weale 840283228e feat!: Raise minimum Python version to 3_10
Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 833363352
2025-11-17 09:02:58 -08:00
Xuan Yang 1dd97f5b45 fix: Add experimental feature to use parameters_json_schema and response_json_schema for McpTool
Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 833144947
2025-11-16 20:55:16 -08:00
Wei Sun (Jack) f7f6837fde docs: Add python tips to AGENTS.md to assist vibe coding
Co-authored-by: Wei Sun (Jack) <weisun@google.com>
PiperOrigin-RevId: 832772144
2025-11-15 14:08:04 -08:00
George Weale 2dea5733b7 fix: add type hints in cleanup_unused_files.py
Updates type annotations to use built-in types like `list` and `dict`, and uses `| None` for optional types, along with adding `from __future__ import annotations`

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 832522395
2025-11-14 17:58:37 -08:00
Xuan Yang 871da731f1 feat: Add feature decorator for the feature registry system
Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 832503990
2025-11-14 16:48:09 -08:00
Shangjie Chen 9211f4ce8c fix: Use async for to loop through event iterator to get all events in vertex_ai_session_service
Fix https://github.com/google/adk-python/issues/3559

Co-authored-by: Shangjie Chen <deanchen@google.com>
PiperOrigin-RevId: 832476367
2025-11-14 15:22:27 -08:00
Kathy Wu a754c96d3c fix: Improve logic for checking if a MCP session is disconnected
Currently logic to check for a disconnected session only checks for certain headers but doesn't detect all cases, leading to situations where it tries to connect to a session that is down. This adds logic so that we ping the server to check if it is disconnected. Fixes https://github.com/google/adk-python/issues/3321.

Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 832460068
2025-11-14 14:33:39 -08:00
anrzeszutek 29fea7ec1f fix: Fix deploy to cloud run on Windows
Merge https://github.com/google/adk-python/pull/3536

- Closes: #1597
- Related: #3306

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3536 from anrzeszutek:main ab9f6bfcd51b373934c0c03ef41c880ce224b31d
PiperOrigin-RevId: 832441843
2025-11-14 13:41:58 -08:00
Google Team Member 7c993b01d1 feat: Schema Enhancements with Descriptions, Partitioning, and Truncation Indicator
This update enhances the BigQuery agent analytics plugin:

*   **Schema Field Descriptions:** The recommended BigQuery table schema now includes descriptions for each field, improving data understandability.
*   **Optimized Table Structure:** The plugin now creates the table with daily partitioning on `timestamp` and clustering on `event_type`, `agent`, and `user_id` by default.
*   **Truncation Flag:** A new boolean field `is_truncated` is added to the schema to show if the `content` was truncated.

PiperOrigin-RevId: 832436799
2025-11-14 13:28:45 -08:00
Ankur Sharma 696852a280 chore: Add default retry options as fall back to llm_request that are made during evals
In order to make evals more resilient to temporary model failures, we add retry options to llm_requests that are made during evals.

Note that this is a fall back option, if the developer has already specified their own retry options, then those will be honored.

Co-authored-by: Ankur Sharma <ankusharma@google.com>
PiperOrigin-RevId: 832383755
2025-11-14 11:02:54 -08:00
milkisbad 9b754564b3 fix: status code in error message in RestApiTool
Merge https://github.com/google/adk-python/pull/2819

add status code to http error to make it more verbose

issue: https://github.com/google/adk-python/issues/2820

# testing plan
run new tests that have beed added in PR

Co-authored-by: Hangfei Lin <hangfei@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2819 from milkisbad:rest_api_tool_verbose_error 79ac6d96174d414e7ca958379102cfa7ede0e883
PiperOrigin-RevId: 832367374
2025-11-14 10:24:21 -08:00
George Weale 0fa7e4619d fix: Add jsonschema dependency for Agent Builder config validation
Close #3494

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 832362832
2025-11-14 10:10:30 -08:00
Google Team Member b7d571bc3f chore: make readability improvements in ADK BQ tool tests
PiperOrigin-RevId: 832110063
2025-11-13 19:43:25 -08:00
Google Team Member 5adbf95a0a fix: stop updating write mode in the global settings during tool execution
Two tools - detect_anomalies and analyze_contribution are modifying the settings passed to them, which is not right as the settings are held and passed by the top level, which means several tools share the same settings.

PiperOrigin-RevId: 832081738
2025-11-13 18:02:19 -08:00
Xuan Yang 23ad40bad2 feat: Introduce a feature registry system for ADK
Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 832050198
2025-11-13 16:14:49 -08:00
Yeesian Ng b8e4aedfbf fix: Add vertexai initialization for code being deployed to AgentEngine
Co-authored-by: Yeesian Ng <ysian@google.com>
PiperOrigin-RevId: 832031219
2025-11-13 15:23:24 -08:00
Google Team Member ffbb0b37e1 feat: allow setting max_billed_bytes in BigQuery tools config
This will allow users to configure a limit to access in ADK tools on the charges for queries.

PiperOrigin-RevId: 831921163
2025-11-13 10:42:56 -08:00
George Weale 22eb7e5b06 feat: Add support for parsing inline JSON tool calls in LiteLLM responses
Close #1968

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 831911719
2025-11-13 10:18:27 -08:00
Sara Robinson 2efc184a46 chore: Add support for abstract types in AFC
PiperOrigin-RevId: 831873580
2025-11-13 08:38:25 -08:00
Google Team Member 6bb0b7417e chore: Add abstract type annotation support to AFC
PiperOrigin-RevId: 831545133
2025-11-12 14:39:43 -08:00
Liang Wu 69627b699f chore: Implement lazy loading for modules within google.adk.tools
This is ~27% of the current cold start latency after previous changes are submitted. This change refactors `google.adk.tools/__init__.py` to use `__getattr__` for lazy loading of all tools and related classes. Previously, all modules were imported directly upon `google.adk.tools` import, leading to potentially long initial import times. With lazy loading, modules are only imported when they are first accessed, improving the initial startup performance.

Co-authored-by: Liang Wu <wuliang@google.com>
PiperOrigin-RevId: 831537187
2025-11-12 14:17:26 -08:00
Hangfei Lin 0ab79b9502 fix: Deprecate save_live_audio in favor of save_live_blob and fix audio event saving
This change:
*   Deprecates the `save_live_audio` configuration option in `RunConfig`, introducing `save_live_blob` as its replacement. A warning is issued if `save_live_audio` is used.
*   Updates `base_llm_flow.py` to use the new `save_live_blob` flag.
*   Ensures that audio events generated by `audio_cache_manager.py` are properly appended to the session service.
*   Adds a utility script `pcm_audio_player.py` for playing raw PCM audio files.

Input sample event: 14a5859f-6b6c-46ed-9f28-e5008793b1c6|live_bidi_streaming_multi_agent|user|1e867c7f-dbe1-4268-a7bc-7a9fa5fbd16c|e-7a28a060-29bf-4483-bc5c-17248698a897|1762916981.5932|{"content":{"parts":[{"file_data":{"file_uri":"artifact://live_bidi_streaming_multi_agent/user/1e867c7f-dbe1-4268-a7bc-7a9fa5fbd16c/_adk_live/adk_live_audio_storage_input_audio_1762916981593.pcm#0","mime_type":"audio/pcm"}}],"role":"user"},"invocation_id":"e-7a28a060-29bf-4483-bc5c-17248698a897","author":"user","actions":{"state_delta":{},"artifact_delta":{},"requested_auth_configs":{},"requested_tool_confirmations":{}},"id":"14a5859f-6b6c-46ed-9f28-e5008793b1c6","timestamp":1762916981.5932002}

output sample event:
506c9df4-e143-4ebc-90a5-2f5b2eb26754|live_bidi_streaming_multi_agent|user|1e867c7f-dbe1-4268-a7bc-7a9fa5fbd16c|e-7a28a060-29bf-4483-bc5c-17248698a897|1762916986.10579|{"content":{"parts":[{"file_data":{"file_uri":"artifact://live_bidi_streaming_multi_agent/user/1e867c7f-dbe1-4268-a7bc-7a9fa5fbd16c/_adk_live/adk_live_audio_storage_output_audio_1762916986105.pcm;rate=24000#0","mime_type":"audio/pcm;rate=24000"}}],"role":"model"},"invocation_id":"e-7a28a060-29bf-4483-bc5c-17248698a897","author":"model","actions":{"state_delta":{},"artifact_delta":{},"requested_auth_configs":{},"requested_tool_confirmations":{}},"id":"506c9df4-e143-4ebc-90a5-2f5b2eb26754","timestamp":1762916986.105794}

Co-authored-by: Hangfei Lin <hangfei@google.com>
PiperOrigin-RevId: 831512074
2025-11-12 13:16:13 -08:00
George Weale 675ecaa8db feat!: Upgrade to include python3.14
pin crew ai to 3.13 at highest version as it uses chromadb and that uses onnxruntime which does not work yet with 3.14

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 831508884
2025-11-12 13:09:00 -08:00
Google Team Member d12468ee5a feat: add a2a_request_meta_provider to RemoteAgent init
The change adds an extension point for controlling which request metadata gets attached to A2A requests made by a RemoteAgent.
Instead of taking metadata from custom_metadata of session events users can construct payloads using a2a_request_meta_provider.

request_meta feature was added in v0.3.11 of the a2a-sdk library: https://github.com/a2aproject/a2a-python/releases/tag/v0.3.11

PiperOrigin-RevId: 831506364
2025-11-12 13:04:06 -08:00
Hangfei Lin 5d5708b2ab chore: Add debug logging for live connection
This CL adds debug logs to show the history being sent to the live connection and the live connect config used.

Co-authored-by: Hangfei Lin <hangfei@google.com>
PiperOrigin-RevId: 831473597
2025-11-12 11:36:08 -08:00
Sara Robinson 52b1dfea14 chore: Add abstract type annotation support to AFC
PiperOrigin-RevId: 831462920
2025-11-12 11:11:41 -08:00
Liang Wu 22c6dbe83c chore: Defer import of live, Client and _transformers in google.genai
Co-authored-by: Liang Wu <wuliang@google.com>
PiperOrigin-RevId: 831444358
2025-11-12 10:27:56 -08:00
George Weale a19be12c1f fix: change LiteLLM content and tool parameter handling
This changes how content parts are converted for LiteLLM, treating all "text/" mime types as plain text and only "application/pdf" as a file

Close #1940

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 831418696
2025-11-12 09:23:00 -08:00
Ankur Sharma e2d3b2d862 feat: Added support for InOrder and AnyOrder match in ToolTrajectoryAvgScore Metric
Co-authored-by: Ankur Sharma <ankusharma@google.com>
PiperOrigin-RevId: 831413968
2025-11-12 09:10:34 -08:00
Google Team Member b2c8ba5806 chore: Defer import of live, Client and _transformers in google.genai
This is targeting the Client import mostly, but also prevents future latency increase if the other modules in genai adds more 3p dependencies. This change will make ADK only import `live`, `Client` and `_transformers` just-in-time, therefore cutting down cold start latency.

PiperOrigin-RevId: 831244349
2025-11-11 23:56:20 -08:00
Google Team Member 37ee1869b5 fix: Enhance BigQuery Plugin Robustness and Schema Accuracy
This update improves the `BigQueryAgentAnalyticsPlugin` in several ways:

*   Corrects the PyArrow schema generation to accurately reflect BigQuery field nullability based on the `mode` attribute.
*   Introduces a configurable `shutdown_timeout` in `BigQueryLoggerConfig` to manage how long the plugin waits for pending logs to flush during shutdown.
*   Adds more robust error handling within the `shutdown` method and background write tasks, particularly for event loop closure issues.
*   Improves internal logging to provide better diagnostics.
*   Ensures consistent use of safe content formatting.

PiperOrigin-RevId: 831225837
2025-11-11 22:47:13 -08:00
Shangjie Chen a501c59ac4 feat: Support registering custom services from local files
This change introduces a mechanism for users to register their own custom backend services for sessions, memory, and artifacts without modifying the ADK framework. This enhances the extensibility of ADK.

Two methods of registration are supported, both by placing a file in the parent directory of the agents.

**YAML Configuration (services.yaml or .yml)**

This is the recommended approach for simple services that can be instantiated with a constructor like MyService(uri="...", **kwargs).

Example services.yaml:

```
services:
  - scheme: mysession
    type: session
    class: my_package.my_module.MyCustomSessionService
```

**Python Registration (services.py)**

For services requiring more complex initialization logic, users can define factory functions in a services.py file.

Example services.py

```
from google.adk.cli.service_registry import get_service_registry
from my_package.my_module import MyCustomSessionService

def my_session_factory(uri: str, **kwargs):
    # custom initialization logic
    return MyCustomSessionService(...)

get_service_registry().register_session_service("mysession", my_session_factory)
```

ADK will load services from services.yaml/.yml first, and then from services.py. If the same service scheme is defined in both, the registration in services.py will take precedence.

To use a registered service, specify its URI via the corresponding command-line flag, e.g., `--session_service_uri=mysession://....`

Co-authored-by: Shangjie Chen <deanchen@google.com>
PiperOrigin-RevId: 831211371
2025-11-11 21:59:19 -08:00
George Weale 99fc17b336 feat: add adk folder manager and per agent local storage helpers
Creates AdkFolderManager for creating/resetting the .adk layout, helper builders that return SQLite- and filesystembacked services for each agent

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 831206377
2025-11-11 21:38:51 -08:00
Google Team Member 3674fbbe8f fix: Update the retry_on_closed_resource decorator to retry on all errors
Retrying only on closed_resource error is not enough to be reliable for production environments due to the other network errors that may occur -- remote protocol error, read timeout, etc. We will update this to retry on all errors. Since it is only a one-time retry, it should not affect latency significantly. Fixes https://github.com/google/adk-python/issues/2561.

PiperOrigin-RevId: 831153803
2025-11-11 18:44:18 -08:00
Liang Wu 999af55880 chore: Defer import of google.cloud.storage in GCSArtifactService
The `google.cloud.storage` module is now imported within the `__init__` method of `GCSArtifactService`, rather than at the top level. This avoids importing the potentially heavy `storage` module unless an instance of `GCSArtifactService` is actually created.

Co-authored-by: Liang Wu <wuliang@google.com>
PiperOrigin-RevId: 831124463
2025-11-11 17:02:20 -08:00
Liang Wu 22ca7eefc0 chore: Defer import of live, Client and _transformers in google.genai
This is targeting the Client import mostly, but also prevents future latency increase if the other modules in genai adds more 3p dependencies. This change will make ADK only import `live`, `Client` and `_transformers` just-in-time, therefore cutting down cold start latency.

Co-authored-by: Liang Wu <wuliang@google.com>
PiperOrigin-RevId: 831124329
2025-11-11 17:01:28 -08:00
Kathy Wu a550509441 fix: Update the retry_on_closed_resource decorator to retry on all errors
Retrying only on closed_resource error is not enough to be reliable for production environments due to the other network errors that may occur -- remote protocol error, read timeout, etc. We will update this to retry on all errors. Since it is only a one-time retry, it should not affect latency significantly. Fixes https://github.com/google/adk-python/issues/2561.

Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 831123085
2025-11-11 16:57:25 -08:00
Google Team Member d85a301039 feat: Add support for passing request metadata in RemoteA2AAgent
This change updates `RemoteA2AAgent` to extract and forward custom metadata from session events to the `a2a-sdk`'s `send_message` method. The metadata is looked for under the key `A2A_METADATA_PREFIX + "metadata"` within the `custom_metadata` of the relevant session events. The `a2a-sdk` dependency is also updated to a version that supports this feature.

This feature was added in v0.3.11 of the a2a-sdk library: https://github.com/a2aproject/a2a-python/releases/tag/v0.3.11

PiperOrigin-RevId: 831120978
2025-11-11 16:49:39 -08:00
Google Team Member 249216e890 feat: Add Graceful Plugin Shutdown to Runner
This change introduces a shutdown lifecycle hook for plugins. The `PluginManager` now has an `async def shutdown()` method that will call `await plugin.shutdown()` on any registered plugins that implement the method. This is called from `Runner.close()`, allowing plugins to perform cleanup tasks like flushing logs or closing connections when the runner instance is being closed. This improves the reliability of plugins that perform background operations.

PiperOrigin-RevId: 831037737
2025-11-11 13:05:03 -08:00
Hangfei Lin 01bac62f0c chore: Update agent instructions and retry limit in plugin_reflect_tool_retry sample
The agent's instructions are updated to guide it to guess a positive integer, starting from 50 and decreasing, using the `guess_number_tool` until the target is found. The maximum number of retries for the `CustomRetryPlugin` is increased from 6 to 10.

Co-authored-by: Hangfei Lin <hangfei@google.com>
PiperOrigin-RevId: 830984481
2025-11-11 10:52:44 -08:00
Hangfei Lin 01a0309f0a chore: Add Go ADK link to README
The README now includes a link to the `adk-go` GitHub repository.

Co-authored-by: Hangfei Lin <hangfei@google.com>
PiperOrigin-RevId: 830971424
2025-11-11 10:21:36 -08:00
Google Team Member 824ab07212 fix: Let part converters also return multiple parts so they can support more usecases
PiperOrigin-RevId: 830882000
2025-11-11 06:15:00 -08:00
Catalin Lupuleti fd33610e96 test: add tests for max_query_result_rows in BigQuery tool config
Merge https://github.com/google/adk-python/pull/2167, during which:

- Let the already added `max_query_result_rows` field cover for `max_downloaded_rows` field added in the PR
- Revert `max_rows` parameter added to execute_sql function, the tool config control should serve most practical use cases
- Keep the relevant tests for tool config

🤖 Generated with [Claude Code](https://claude.ai/code)

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2167 from lupuletic:feature/configurable-max-downloaded-rows 23c56905c297d7aec2be4f1eb86ea23c8178bf21
PiperOrigin-RevId: 830701093
2025-11-10 19:43:24 -08:00
Hangfei Lin 2b0f953255 feat: Add artifact metadata support and a new sample for context offloading
Enhanced `save_artifact` in `callback_context.py` to accept `custom_metadata` and added `get_artifact_version` to retrieve artifact details.

Introduced a new sample, `context_offloading_with_artifact`, demonstrating how to use ADK artifacts to offload large data from the LLM context. The sample includes:
-   `QueryLargeDataTool`: Generates mock sales reports, saves them as artifacts with custom metadata, and injects the artifact content into the LLM request immediately after creation.
-   `CustomLoadArtifactsTool`: Provides summaries of available artifacts to the LLM based on metadata and loads artifact content on demand when `load_artifacts` is called.

Co-authored-by: Hangfei Lin <hangfei@google.com>
PiperOrigin-RevId: 830592786
2025-11-10 14:10:10 -08:00
GitMarco27 74959414d8 feat: full async implementation of DatabaseSessionService
Merge https://github.com/google/adk-python/pull/2889

# Implement Full async DatabaseSessionService

**Target Issue:** #1005

## Overview

This PR introduces an asynchronous implementation of the `DatabaseSessionService` with minimal breaking changes. The primary goal is to enable effective use of ADK in fully async environments and API endpoints while avoiding event loop blocking during database I/O operations.

## Changes

- Converted `DatabaseSessionService` to use async/await patterns throughout

## Testing Plan

The implementation has been tested following the project's contribution guidelines:

### Unit Tests
- All existing unit tests pass successfully
- Minor update to test requirements added to support `aiosqlite`

### Manual End-to-End Testing
- E2E tests performed using:
  - **LLM Provider:** LiteLLM
  - **Database:** PostgreSQL with `asyncpg` driver

 ```python
from google.adk.sessions.database_session_service import DatabaseSessionService

connection_string: str = (
    "postgresql+asyncpg://PG_USER:PG_PSWD@PG_HOST:5432/PG_DB"
)
session_service: DatabaseSessionService = DatabaseSessionService(
    db_url=connection_string
)

session = await session_service.create_session(
    app_name="test_app", session_id="test_session", user_id="test_user"
)
assert session is not None

sessions = await session_service.list_sessions(app_name="test_app", user_id="test_user")
assert len(sessions.sessions) > 0

session = await session_service.get_session(
    app_name="test_app", session_id="test_session", user_id="test_user"
)
assert session is not None

await session_service.delete_session(
    app_name="test_app", session_id="test_session", user_id="test_user"
)
assert (
    await session_service.get_session(
        app_name="test_app", session_id="test_session", user_id="test_user"
    )
    is None
)
```

The implementation have been also tested using the following configurations for llm provider and Runner:

```python
def get_azure_openai_model(deployment_id: str | None = None) -> LiteLlm:
    ...

    if not deployment_id:
        deployment_id = os.getenv("AZURE_OPENAI_DEPLOYMENT_ID")

    logger.info(f"Using Azure OpenAI deployment ID: {deployment_id}")

    return LiteLlm(
        model=f"azure/{os.getenv('AZURE_OPENAI_DEPLOYMENT_ID')}",
        stream=True,
    )

...

    @staticmethod
    def _get_runner(agent: Agent) -> Runner:
        storage=DatabaseSessionService(db_url=get_pg_connection_string())
        return Runner(
            agent=agent,
            app_name=APP_NAME,
            session_service=storage,
        )

...

async for event in self.runner.run_async(
    user_id=user_id,
    session_id=session_id,
    new_message=content,
    run_config=(
        RunConfig(
            streaming_mode=StreamingMode.SSE, response_modalities=["TEXT"]
        )
        if stream
        else RunConfig()
    ),
):
    last_event = event
    if stream:
        yield event

...

```

## Breaking Changes

- Database connection string format may need updates for async drivers

Co-authored-by: Shangjie Chen <deanchen@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2889 from GitMarco27:feature/async_database_session_service e1b1b14934c1fb7975a6832cdd1549e94acab985
PiperOrigin-RevId: 830525148
2025-11-10 11:18:02 -08:00
Shangjie Chen 2443a1b74f docs: Update adk cli help message regarding the update to SqliteSessionService
Co-authored-by: Shangjie Chen <deanchen@google.com>
PiperOrigin-RevId: 830521954
2025-11-10 11:09:57 -08:00
George Weale 7b87056dfa fix: adapt fixtures for pytest 9 rules
Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 830493430
2025-11-10 10:06:12 -08:00
Amy Wu 7937e9ed40 fix: Use async with for API client in Vertex session management to ensure proper resource management
PiperOrigin-RevId: 830485639
2025-11-10 09:49:10 -08:00
George Weale c4858896ff fix: Update description for load_artifacts tool
The tool description now clarifies that `load_artifacts` should be called when a user uploads files, to make those artifacts accessible within the session.

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 830469802
2025-11-10 09:07:59 -08:00
George Weale 0db2041e1a fix: Correct FastAPI version constraint in toml
The upper bound for the `fastapi` dependency is adjusted from `<1.119.0` to `<0.119.0`.

Close #3422

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 830465681
2025-11-10 08:58:15 -08:00
Jeff Bryner 352dd995e1 fix: Add required parameters with defaults if missing
Merge https://github.com/google/adk-python/pull/2054

fixes https://github.com/google/adk-python/issues/2053

Co-authored-by: Xuan Yang <xygoogle@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2054 from jeffbryner:fix-required-params dd75a0b5798792dccb1ca0ac0240ce0c0b1fad14
PiperOrigin-RevId: 830251203
2025-11-09 20:46:41 -08:00
Xuan Yang f31226ee92 docs: Update the error message for function parameter ToolContext not named as tool_context
Fixes https://github.com/google/adk-python/issues/1530

Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 830248414
2025-11-09 20:35:28 -08:00
George Weale 93aad61198 fix: Safely handle FunctionDeclaration without a required attribute
Update `_function_declaration_to_tool_param` to use `getattr` when accessing the `required` field within `function_declaration.parameters`. This prevents `AttributeError` when a `FunctionDeclaration`'s parameters schema does not include a `required` attribute
Close #2891

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 830225582
2025-11-09 19:06:45 -08:00
Sanjay Siddharth MJ 2882995289 fix: Fixes DeprecationWarning when using send method
Merge https://github.com/google/adk-python/pull/3352

Replace send() method with send_realtime_input() to fix DeprecationWarning

### Link to Issue or Description of Change

**1. Link to an existing issue (if applicable):**

- Closes: #2393

### Testing Plan

Have run unit test for test_live_request_queue.py

**Unit Tests:**

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

Summary :

tests/unittests/agents/test_live_request_queue.py::test_send_realtime PASSED                [100%]

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

### 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.
- [ ] 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.
- [ ] Any dependent changes have been merged and published in downstream modules.

Tested both API variants.

Co-authored-by: Hangfei Lin <hangfei@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3352 from SanjaySiddharth:fix-dep-session.send b23b641a63ff20d1f2dbd9abd519f8facf0aab77
PiperOrigin-RevId: 830182844
2025-11-09 16:00:43 -08:00
GenkiNoguchi a3b4ec69d8 feat: Add user_id property to ReadonlyContext
Merge https://github.com/google/adk-python/pull/2875

related: https://github.com/google/adk-python/issues/2876

  ## Reason for this change:

  Currently, there is no direct way to access the user_id from within agent contexts, plugins, or callbacks. This limitation prevents several important use cases:

  1. **User-specific logging and tracing**: When debugging or monitoring agent behavior, it's crucial to associate actions with specific users for better observability.
  2. **User-scoped operations**: Plugins and callbacks often need to perform user-specific operations, such as accessing user-specific resources or applying user-level configurations.
  3. **Session management**: The user_id is a key component of session identification, but it's not accessible through the ReadonlyContext interface, requiring workarounds to access it.

  ## Changes made:

  - Added a `user_id` property to the `ReadonlyContext` class in `src/google/adk/agents/readonly_context.py`
  - The property exposes the user_id from the underlying invocation context as a readonly field

  ## Impact:

  This change will:
  - Enable plugins and callbacks to access the current user's ID directly through the context
  - Improve logging and tracing capabilities by allowing user-specific tracking
  - Simplify code that needs to perform user-scoped operations without requiring access to internal implementation details
  - Maintain backward compatibility as this is an additive change

  ### Before:
- No direct way to access user_id from ReadonlyContext

###   After:
  ```python

  @property
  def user_id(self) -> str:
      """The id of the user. READONLY field."""
      return self._invocation_context.user_id
```
  This is a non-breaking change that adds a new readonly property to the existing ReadonlyContext interface.

Co-authored-by: Hangfei Lin <hangfei@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2875 from ammmr:ammmr-add-user_id-property-to-readonly-context 771734ebf39cb0748a5dc826436236268fbb58f8
PiperOrigin-RevId: 830170908
2025-11-09 14:51:52 -08:00
Max Ind 116b26c33e feat: add plugin for returning GenAI Parts from tools into the model request
Added to mitigate https://github.com/google/adk-python/issues/3064

Co-authored-by: Max Ind <maxind@google.com>
PiperOrigin-RevId: 830135940
2025-11-09 11:47:08 -08:00
Shangjie Chen e218254495 feat: Add SqliteSessionService and a migration script to migrate existing DB using DatabaseSessionService to SqliteSessionService
The new Sqlite version has fixed schema and use a single column to store Event data, this should avoid DB migration for future add to the Event object.

- This change introduces `SqliteSessionService`, an asynchronous session service using `aiosqlite` that stores event data as JSON within SQLite.
- A migration script, `migrate_from_sqlalchemy_sqlite.py`, is included to transition data from the older SQLAlchemy-based SQLite schema to this new format.
- The CLI service registry is updated to use SqliteSessionService for sqlite:// URIs.
- Throw error when user trying to access a legacy DB and advice the user to do the migration.

Co-authored-by: Shangjie Chen <deanchen@google.com>
PiperOrigin-RevId: 829971174
2025-11-08 21:19:38 -08:00
Wei Sun (Jack) 50ceda00cf docs(models): Updates BaseLlm#generate_content_async docstring with the expected behavior
NOTE:

- This is the expected behavior, so that SSE streaming and non-streaming behaviors are idential to each other in the persisted session.
- The underlying google_llm.py hasn't been fully comply with this behavior, which will be addressed in future changes.

Co-authored-by: Wei Sun (Jack) <weisun@google.com>
PiperOrigin-RevId: 829878175
2025-11-08 13:21:38 -08:00
Google Team Member 6b14f88726 feat: Refactor and Rename BigQuery Agent Analytics Plugin
This change updates the `BigQueryAgentAnalyticsPlugin` (formerly in `bigquery_logging_plugin.py`) to perform BigQuery writes asynchronously in background tasks, preventing blocking of the main agent execution flow. Initialization of BigQuery clients and table creation is also made asynchronous. The content logged in various callbacks has been streamlined and simplified. The plugin file has been renamed to `bigquery_agent_analytics_plugin.py` to match the class name.

PiperOrigin-RevId: 829603260
2025-11-07 15:44:03 -08:00
GenkiNoguchi 42d4c4ed5f chore: Change live connection log level from info to debug
Merge https://github.com/google/adk-python/pull/2600

**Reason for this change:**

Currently, the detailed llm_request object is logged at the info level when connecting to the live API. This causes two main issues:

  1. Excessive log output with large instructions: When instructions are large, the unstructured log output becomes problematic. Since the logs are not structured, any
  newline characters in the instruction content cause each line to be output as a separate log entry, resulting in massive log output that floods the logging system.
  2. Unnecessary verbosity in production: The detailed request information is primarily useful for debugging purposes and should not appear in standard info-level logs,
  especially when connections are established frequently.

  **Changes made:**

  - Changed logger.info to logger.debug in src/google/adk/models/google_llm.py at line 294 for the live connection logging statement.

  **Impact:**

  This change will:
  - Reduce log noise in production environments where info-level logging is enabled
  - Keep the detailed connection information available when debug-level logging is needed for troubleshooting
  - Improve log readability by showing only essential information at the info level

  **Before:**
  logger.info('Connecting to live with llm_request:%s', llm_request)

  **After:**
  logger.debug('Connecting to live with llm_request:%s', llm_request)

  This is a non-breaking change that only affects logging verbosity.

Co-authored-by: Hangfei Lin <hangfei@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2600 from ammmr:ammmr-info-to-debug-connect-log 36eab157f5d5ca00b44ee6ad8a4e1aeec871600c
PiperOrigin-RevId: 829596092
2025-11-07 15:20:10 -08:00
Google Team Member 34ea2edfd2 fix: Fixes a bug introduced by the underlying google genai library
We need to set project and location parameters when we instantiate the Google GenAI library Client for VertexAi. This used to work before through environment variables but it doesn't seem to work anymore. So we are updating the `ApigeeLlm` wrapper to read from `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` environment variables and pass to the Client constructor.

PiperOrigin-RevId: 829569362
2025-11-07 14:02:41 -08:00
Google Team Member 9e22cc4022 feat: Bigquery detect_anomalies tool results sort by timestamp for better visualization
Timestamp need to be ordered so that for better display and further visualization.

PiperOrigin-RevId: 829548481
2025-11-07 13:03:34 -08:00
Lê Nam Khánh 51dee43f08 docs: fix typos in some files
Merge https://github.com/google/adk-python/pull/3444

This PR fixes typos in the file file using codespell.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3444 from khanhkhanhlele:Fix/typos/20251107165249 e9629a8c0255ddc0764cb0df7f36ebe61bd6515e
PiperOrigin-RevId: 829516217
2025-11-07 11:32:32 -08:00
George Weale e0e762598e docs: Use a trimmed ADK AgentConfig schema in Agent Builder Assistant
This trimmed schema includes only the fields relevant to agent shells, tool wiring, and common generation parameters, improving efficiency and focus.

The default model for the assistant has also been updated to "gemini-2.5-pro"

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 829513627
2025-11-07 11:26:18 -08:00
Henrique Cadioli 8f3c3bfda5 fix: cache canonical tools to avoid multiple calls when streaming
Merge https://github.com/google/adk-python/pull/3299
Fixes https://github.com/google/adk-python/issues/3237

Co-authored-by: Xuan Yang <xygoogle@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3299 from hcadioli:fix/cache-tools de02bd3e4533c3741edf05788a5e8b2d3d38bae4
PiperOrigin-RevId: 829499299
2025-11-07 10:51:32 -08:00
Kathy Wu 9761fc6bbb fix: Fix McpToolset hanging indefinitely
This fixes McpToolset from hanging indefinitely during a list_tools call (https://github.com/google/adk-python/issues/3084) by adding a timeout.

Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 829499276
2025-11-07 10:50:38 -08:00
Naofumi Yamada 0ccc43cf49 fix: Fix error when query job destination is None
Merge https://github.com/google/adk-python/pull/3127

# What this PR does
This PR fixes a bug in the `execute_sql function` within `bigquery/query_tool.py`. The bug caused an error when executing queries that do not return a result set, such as a `CREATE TEMP FUNCTION` statement.

# The problem
Within `execute_sql,` when a user executed a query that doesn't produce a result set, like the following:

```sql
CREATE TEMP FUNCTION f() AS (0); SELECT f();
```

The corresponding BigQuery job object would have its `destination` property set to `None`. This caused an error because the code was written with the expectation of a valid destination table.

# The solution
The fix modifies `execute_sql` to check if the `query_job.destination` is None. If it is, the function correctly identifies the query as a statement that doesn't require a destination and allows it to complete successfully.

This ensures that `execute_sql` can robustly handle these types of queries.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3127 from na0fu3y:patch-1 69218a8d25699dfa2e18bb305087f01192e91e91
PiperOrigin-RevId: 829270885
2025-11-06 22:28:06 -08:00
Google Team Member a0cf97eba2 feat: Some small infra fixes to the gepa demo colab
PiperOrigin-RevId: 829240716
2025-11-06 20:44:25 -08:00
Google Team Member d118479ccf feat: Improve gepa voter agent demo colab
PiperOrigin-RevId: 829208761
2025-11-06 19:13:11 -08:00
Kathy Wu 8e0648df23 fix: Fix MCPToolset crashing with anyio.BrokenResourceError
Add error handling for broken resource error so that it retries. Fixes https://github.com/google/adk-python/issues/2769.

Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 829146121
2025-11-06 16:12:49 -08:00
Google Team Member c0be1df052 feat: set per-tool user agent in BQ calls and tool label in BQ jobs
This will help per tool usage for BigQuery tools.

PiperOrigin-RevId: 829142106
2025-11-06 16:01:50 -08:00
Google Team Member f1f44675e4 ADK changes
PiperOrigin-RevId: 829136628
2025-11-06 15:55:26 -08:00
Hangfei Lin f3d6fcf444 chore: Add debug logging for missing function call events
This change adds a debug log statement to output the function response IDs and the event list when a matching function call event is not found, which helps in debugging.

Co-authored-by: Hangfei Lin <hangfei@google.com>
PiperOrigin-RevId: 829059186
2025-11-06 12:20:36 -08:00
Liang Wu dd706bdc45 feat: Update conformance test CLI to handle long-running tool calls
Capture the function call ID from events and use it to populate the `function_response.id` in subsequent user messages, enabling recording and replaying of test cases involving long-running tools.

Co-authored-by: Liang Wu <wuliang@google.com>
PiperOrigin-RevId: 829042356
2025-11-06 11:38:13 -08:00
Wei Sun (Jack) e511eb1f70 chore: Removes the unrealistic todo comment of visibility management
Co-authored-by: Wei Sun (Jack) <weisun@google.com>
PiperOrigin-RevId: 829041637
2025-11-06 11:36:49 -08:00
George Weale 7ea4aed35b fix: Add support for structured output schemas in LiteLLM models
Add `_to_litellm_response_format` to convert ADK's `response_schema` types (Pydantic models, JSON schema dicts) into the format needed by LiteLLM for JSON object/schema constraints

Close #1967

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 829037987
2025-11-06 11:29:10 -08:00
Josh Soref d672349ddf chore: Fix spelling in tests
Merge https://github.com/google/adk-python/pull/3402

This PR corrects misspellings identified by the [check-spelling action](https://github.com/marketplace/actions/check-spelling)

Note: while I use tooling to identify errors, the tooling doesn't _actually_ provide the corrections, I'm picking them on my own. I'm a human, and I may make mistakes.

### Testing Plan

The misspellings have been reported at https://github.com/jsoref/adk-python/actions/runs/19056081305/attempts/1#summary-54426435973

The action reports that the changes in this PR would make it happy: https://github.com/jsoref/adk-python/actions/runs/19056081446/attempts/1#summary-54426436321

**Unit Tests:**

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

_Please include a summary of passed `pytest` results._

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

_Please provide instructions on how to manually test your changes, including any
necessary setup or configuration. Please provide logs or screenshots to help
reviewers better understand the fix._

### 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.

### Additional context

- https://github.com/google/adk-python/pull/3382#issuecomment-3488654110

Co-authored-by: Liang Wu <wuliang@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3402 from jsoref:spelling-tests 3cf0439d0584e4557179c25596aadf3b5b7c3fa8
PiperOrigin-RevId: 829035089
2025-11-06 11:21:59 -08:00
Hangfei Lin 1819ecb4b8 fix: Improve handling of partial and complete transcriptions in live calls
In `gemini_llm_connection.py`, accumulate partial transcription texts and emit `LlmResponse` with `partial=True` for each chunk. When the transcription is marked as `finished`, emit a final `LlmResponse` with the full accumulated text and `partial=False`.

In `runners.py`, modify `_should_append_to_history` to only add transcription events to the history when they are fully finished, preventing partial transcriptions from being added.

Co-authored-by: Hangfei Lin <hangfei@google.com>
PiperOrigin-RevId: 829029715
2025-11-06 11:09:21 -08:00
Liang Wu 44d45fe9cd chore: Lazy load Vertex AI dependencies in ADK modules
This is about 35% decrease. This change refactors several ADK modules to import `vertexai` and its submodules only when they are first used, rather than at the top of the file. This improves module load times by avoiding unnecessary imports of large dependencies. Imports are also placed within `if TYPE_CHECKING:` blocks where appropriate.

Co-authored-by: Liang Wu <wuliang@google.com>
PiperOrigin-RevId: 829017293
2025-11-06 10:40:54 -08:00
Liang Wu 5f057498a2 chore: Lazy import DatabaseSessionService in the adk/sessions/ module
This accounts for about 8% of latency in cold start, because DatabaseSessionService imports from sqlalchemy. After the change, DatabaseSessionService is only imported if it's really needed by the program. The other objects in this file are not affected because they contribute to a small fraction of the latency.

Co-authored-by: Liang Wu <wuliang@google.com>
PiperOrigin-RevId: 829009868
2025-11-06 10:24:43 -08:00
Krzysztof Czuszynski 8dd5a79b29 fix: Fix transcript finish
Merge https://github.com/google/adk-python/pull/3324

**Problem:**
ADK seems to not pass output/input transcription `finished` flag from the Gemini.

**Solution:**
Relaxation of checking conditions of valid llm_response for input/output transcription.

### Testing Plan

Unit test `test_receive_transcript_finished` checks if input/output transcription message with no text but `finished` flag is received.

**Unit Tests:**

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

<img width="785" height="373" alt="image" src="https://github.com/user-attachments/assets/6d870e9f-1372-4808-91a9-38578c1b3729" />

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

Configure Gemini Agent to produce input & output transcriptions. Observe incoming transcript messages - to see if the finished flag appears at the end agents & users statement.

### 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

The mentioned `finished` flag can be obtained in native Gemini APIs like via Websocket but not via ADK.

Co-authored-by: Hangfei Lin <hangfei@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3324 from ChrisQlasty:fix/transcript_finish e7b8e5e5f5fac1d2dfd495f2dbadb19ed4328b0c
PiperOrigin-RevId: 828987996
2025-11-06 09:29:12 -08:00
Google Team Member f167890d00 feat: Add documentation and instructions to help configure gepa experiments
PiperOrigin-RevId: 828911323
2025-11-06 05:31:24 -08:00
George Weale e3caf79139 feat: expose artifact URLs to the model when available
SaveFilesAsArtifactsPlugin now resolves the canonical URI for each saved artifact. When the URI is model-accessible (`gs://`, `https://`, `http://`), we add a `Part(file_data=...)` so the LLM can fetch the filedirectly while still emitting the placeholder. If no model-accessible URI exists, we retain the original inline blob alongside the placeholder to preserve access to the uploaded bytes.

Close #2016

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 828786519
2025-11-05 22:17:37 -08:00
Hangfei Lin 52db15f133 fix: Remove unused _run_compaction_default method
The `_run_compaction_default` method is no longer called and can be safely removed.

Co-authored-by: Hangfei Lin <hangfei@google.com>
PiperOrigin-RevId: 828760157
2025-11-05 20:47:09 -08:00
Josh Soref e568558674 chore: Fix spelling in markdown files
Merge https://github.com/google/adk-python/pull/3403

This PR corrects misspellings identified by the [check-spelling action](https://github.com/marketplace/actions/check-spelling)

Note: while I use tooling to identify errors, the tooling doesn't _actually_ provide the corrections, I'm picking them on my own. I'm a human, and I may make mistakes.

### Testing Plan

The misspellings have been reported at https://github.com/jsoref/adk-python/actions/runs/19056081305/attempts/1#summary-54426435973

The action reports that the changes in this PR would make it happy: https://github.com/jsoref/adk-python/actions/runs/19056081446/attempts/1#summary-54426436321

**Unit Tests:**

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

_Please include a summary of passed `pytest` results._

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

_Please provide instructions on how to manually test your changes, including any
necessary setup or configuration. Please provide logs or screenshots to help
reviewers better understand the fix._

### 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.

### Additional context

- https://github.com/google/adk-python/pull/3382#issuecomment-3488654110

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3403 from jsoref:spelling-markdown 432b7ded3bddfe4a1d8127c50fd7a001f19bda83
PiperOrigin-RevId: 828754459
2025-11-05 20:30:49 -08:00
Kapil Sachdeva d7521eb638 feat: Expose run_config of current invocation from ReadonlyContext
Merge https://github.com/google/adk-python/pull/3410

### Link to Issue or Description of Change

**1. Link to an existing issue (if applicable):**

- Closes: #3409

Co-authored-by: Hangfei Lin <hangfei@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3410 from ksachdeva:expose-runconfig b62b923df421f0bdc1c20948d16765c555c01cb8
PiperOrigin-RevId: 828738445
2025-11-05 19:47:11 -08:00
Shangjie Chen f511352508 chore: Clarify the usage of agent_state
Co-authored-by: Shangjie Chen <deanchen@google.com>
PiperOrigin-RevId: 828733706
2025-11-05 19:30:58 -08:00
ananyablonko 0fccc7933a fix(core): ParallelAgent's branching with include_contents='none' may cause index out of range error
Merge https://github.com/google/adk-python/pull/2961

Fixes #2404

Consider code where a sub_agent somewhere under a ParallelAgent has include_contents='none'.
```python
import asyncio
import os
from typing import TypedDict
from dotenv import load_dotenv

from google.adk.agents import LlmAgent, ParallelAgent, SequentialAgent
from google.adk.runners import Runner
from google.adk.sessions import DatabaseSessionService, InMemorySessionService
from google.genai import types
import logging

USE_DB=False

load_dotenv()
logging.basicConfig(
    filename='log.log',
    level=logging.DEBUG
)
for logger_name in ["httpcore"]:
    logging.getLogger(logger_name).setLevel(logging.ERROR)

class AgentArgs(TypedDict):
    model: str
    instruction: str

class SessionArgs(TypedDict):
    user_id: str
    session_id: str

agent_args = AgentArgs(
    model="gemini-2.0-flash",
    instruction="Answer 'Ack' and nothing else."
)

session_args = SessionArgs(
    user_id="0",
    session_id="0"
)

app_name = "Test"

def create_agent_in_branch(i: int):
    agent_1 = LlmAgent(
        name=f"subagent_{i}_1",
        **agent_args
    )

    agent_2 = LlmAgent(
        name=f"subagent_{i}_2",
        include_contents='none',
        **agent_args
    )

    return SequentialAgent(
        name=f"agent_{i}",
        sub_agents=[agent_1, agent_2]
    )

root = ParallelAgent(
    name="root",
    sub_agents=[create_agent_in_branch(i) for i in range(1, 5)]
)

runner = Runner(
    agent=root,
    app_name=app_name,
    session_service=DatabaseSessionService(db_url=os.getenv("DB_URL", "")) if USE_DB else InMemorySessionService(),
)

async def main() -> None:
    try:
        await runner.session_service.delete_session(app_name=app_name, **session_args)
    except:
        pass
    await runner.session_service.create_session(app_name=app_name, **session_args)

    message = types.Content(role="user", parts=[types.Part(text=" ")])
    async for event in runner.run_async(**session_args, new_message=message):
        if event.is_final_response():
            print(((event.content or types.Content()).parts or [types.Part()])[0].text or "")

if __name__ == '__main__':
    asyncio.run(main())
```

The log here will often have one or more ```subagent_{i}_2``` not receive their prompts from ```subagent_{i}_1```.
This inconsistency is caused by the way ```include_contents='none'``` is implemented in flows/llm_flows/contents.py:328-356:

```python
    for i in range(len(events) - 1, -1, -1):
    event = events[i]
    if event.author == 'user' or _is_other_agent_reply(agent_name, event):
      return _get_contents(current_branch, events[i:], agent_name)

  return []
```

That is, we first find the most recent (other-agent / user) event, **even if it's not on our branch**, and then filter the remainder. Thus in the above example, we may sometimes filter out all events, when we expect to have the event of a previous agent in a ```SequentialAgent```.

The solution is to first filter events by branch, and only then search for the latest.

### TEST SUMMARY:
```
=================================================== short test summary info ===================================================
FAILED tests/unittests/agents/test_agent_config.py::test_agent_config_discriminator_with_sub_agents[GOOGLE_AI-LoopAgent-LoopAgent] - FileNotFoundError: Config file not found: C:\Users\AnanYablonko\AppData\Local\Temp\pytest-of-AnanYablonko\pytest-1\test_age...
FAILED tests/unittests/agents/test_agent_config.py::test_agent_config_discriminator_with_sub_agents[GOOGLE_AI-google.adk.agents.LoopAgent-LoopAgent] - FileNotFoundError: Config file not found: C:\Users\AnanYablonko\AppData\Local\Temp\pytest-of-AnanYablonko\pytest-1\test_age...
FAILED tests/unittests/agents/test_agent_config.py::test_agent_config_discriminator_with_sub_agents[GOOGLE_AI-google.adk.agents.loop_agent.LoopAgent-LoopAgent] - FileNotFoundError: Config file not found: C:\Users\AnanYablonko\AppData\Local\Temp\pytest-of-AnanYablonko\pytest-1\test_age...
FAILED tests/unittests/agents/test_agent_config.py::test_agent_config_discriminator_with_sub_agents[GOOGLE_AI-ParallelAgent-ParallelAgent] - FileNotFoundError: Config file not found: C:\Users\AnanYablonko\AppData\Local\Temp\pytest-of-AnanYablonko\pytest-1\test_age...
FAILED tests/unittests/agents/test_agent_config.py::test_agent_config_discriminator_with_sub_agents[GOOGLE_AI-google.adk.agents.ParallelAgent-ParallelAgent] - FileNotFoundError: Config file not found: C:\Users\AnanYablonko\AppData\Local\Temp\pytest-of-AnanYablonko\pytest-1\test_age...
FAILED tests/unittests/agents/test_agent_config.py::test_agent_config_discriminator_with_sub_agents[GOOGLE_AI-google.adk.agents.parallel_agent.ParallelAgent-ParallelAgent] - FileNotFoundError: Config file not found: C:\Users\AnanYablonko\AppData\Local\Temp\pytest-of-AnanYablonko\pytest-1\test_age...
FAILED tests/unittests/agents/test_agent_config.py::test_agent_config_discriminator_with_sub_agents[GOOGLE_AI-SequentialAgent-SequentialAgent] - FileNotFoundError: Config file not found: C:\Users\AnanYablonko\AppData\Local\Temp\pytest-of-AnanYablonko\pytest-1\test_age...
FAILED tests/unittests/agents/test_agent_config.py::test_agent_config_discriminator_with_sub_agents[GOOGLE_AI-google.adk.agents.SequentialAgent-SequentialAgent] - FileNotFoundError: Config file not found: C:\Users\AnanYablonko\AppData\Local\Temp\pytest-of-AnanYablonko\pytest-1\test_age...
FAILED tests/unittests/agents/test_agent_config.py::test_agent_config_discriminator_with_sub_agents[GOOGLE_AI-google.adk.agents.sequential_agent.SequentialAgent-SequentialAgent] - FileNotFoundError: Config file not found: C:\Users\AnanYablonko\AppData\Local\Temp\pytest-of-AnanYablonko\pytest-1\test_age...
FAILED tests/unittests/agents/test_agent_config.py::test_agent_config_discriminator_with_sub_agents[VERTEX-LoopAgent-LoopAgent] - FileNotFoundError: Config file not found: C:\Users\AnanYablonko\AppData\Local\Temp\pytest-of-AnanYablonko\pytest-1\test_age...
FAILED tests/unittests/agents/test_agent_config.py::test_agent_config_discriminator_with_sub_agents[VERTEX-google.adk.agents.LoopAgent-LoopAgent] - FileNotFoundError: Config file not found: C:\Users\AnanYablonko\AppData\Local\Temp\pytest-of-AnanYablonko\pytest-1\test_age...
FAILED tests/unittests/agents/test_agent_config.py::test_agent_config_discriminator_with_sub_agents[VERTEX-google.adk.agents.loop_agent.LoopAgent-LoopAgent] - FileNotFoundError: Config file not found: C:\Users\AnanYablonko\AppData\Local\Temp\pytest-of-AnanYablonko\pytest-1\test_age...
FAILED tests/unittests/agents/test_agent_config.py::test_agent_config_discriminator_with_sub_agents[VERTEX-ParallelAgent-ParallelAgent] - FileNotFoundError: Config file not found: C:\Users\AnanYablonko\AppData\Local\Temp\pytest-of-AnanYablonko\pytest-1\test_age...
FAILED tests/unittests/agents/test_agent_config.py::test_agent_config_discriminator_with_sub_agents[VERTEX-google.adk.agents.ParallelAgent-ParallelAgent] - FileNotFoundError: Config file not found: C:\Users\AnanYablonko\AppData\Local\Temp\pytest-of-AnanYablonko\pytest-1\test_age...
FAILED tests/unittests/agents/test_agent_config.py::test_agent_config_discriminator_with_sub_agents[VERTEX-google.adk.agents.parallel_agent.ParallelAgent-ParallelAgent] - FileNotFoundError: Config file not found: C:\Users\AnanYablonko\AppData\Local\Temp\pytest-of-AnanYablonko\pytest-1\test_age...
FAILED tests/unittests/agents/test_agent_config.py::test_agent_config_discriminator_with_sub_agents[VERTEX-SequentialAgent-SequentialAgent] - FileNotFoundError: Config file not found: C:\Users\AnanYablonko\AppData\Local\Temp\pytest-of-AnanYablonko\pytest-1\test_age...
FAILED tests/unittests/agents/test_agent_config.py::test_agent_config_discriminator_with_sub_agents[VERTEX-google.adk.agents.SequentialAgent-SequentialAgent] - FileNotFoundError: Config file not found: C:\Users\AnanYablonko\AppData\Local\Temp\pytest-of-AnanYablonko\pytest-1\test_age...
FAILED tests/unittests/agents/test_agent_config.py::test_agent_config_discriminator_with_sub_agents[VERTEX-google.adk.agents.sequential_agent.SequentialAgent-SequentialAgent] - FileNotFoundError: Config file not found: C:\Users\AnanYablonko\AppData\Local\Temp\pytest-of-AnanYablonko\pytest-1\test_age...
FAILED tests/unittests/agents/test_agent_config.py::test_agent_config_discriminator_llm_agent_with_sub_agents[GOOGLE_AI-LlmAgent-LlmAgent] - FileNotFoundError: Config file not found: C:\Users\AnanYablonko\AppData\Local\Temp\pytest-of-AnanYablonko\pytest-1\test_age...
FAILED tests/unittests/agents/test_agent_config.py::test_agent_config_discriminator_llm_agent_with_sub_agents[GOOGLE_AI-google.adk.agents.LlmAgent-LlmAgent] - FileNotFoundError: Config file not found: C:\Users\AnanYablonko\AppData\Local\Temp\pytest-of-AnanYablonko\pytest-1\test_age...
FAILED tests/unittests/agents/test_agent_config.py::test_agent_config_discriminator_llm_agent_with_sub_agents[GOOGLE_AI-google.adk.agents.llm_agent.LlmAgent-LlmAgent] - FileNotFoundError: Config file not found: C:\Users\AnanYablonko\AppData\Local\Temp\pytest-of-AnanYablonko\pytest-1\test_age...
FAILED tests/unittests/agents/test_agent_config.py::test_agent_config_discriminator_llm_agent_with_sub_agents[VERTEX-LlmAgent-LlmAgent] - FileNotFoundError: Config file not found: C:\Users\AnanYablonko\AppData\Local\Temp\pytest-of-AnanYablonko\pytest-1\test_age...
FAILED tests/unittests/agents/test_agent_config.py::test_agent_config_discriminator_llm_agent_with_sub_agents[VERTEX-google.adk.agents.LlmAgent-LlmAgent] - FileNotFoundError: Config file not found: C:\Users\AnanYablonko\AppData\Local\Temp\pytest-of-AnanYablonko\pytest-1\test_age...
FAILED tests/unittests/agents/test_agent_config.py::test_agent_config_discriminator_llm_agent_with_sub_agents[VERTEX-google.adk.agents.llm_agent.LlmAgent-LlmAgent] - FileNotFoundError: Config file not found: C:\Users\AnanYablonko\AppData\Local\Temp\pytest-of-AnanYablonko\pytest-1\test_age...
FAILED tests/unittests/cli/utils/test_cli_tools_click.py::test_cli_run_invokes_run_cli[GOOGLE_AI] - AssertionError: assert 1 == 0
FAILED tests/unittests/cli/utils/test_cli_tools_click.py::test_cli_run_invokes_run_cli[VERTEX] - AssertionError: assert 1 == 0
FAILED tests/unittests/cli/utils/test_cli_tools_click.py::test_cli_eval_with_eval_set_file_path[GOOGLE_AI] - assert 0 == 1
FAILED tests/unittests/cli/utils/test_cli_tools_click.py::test_cli_eval_with_eval_set_file_path[VERTEX] - assert 0 == 1
FAILED tests/unittests/evaluation/test_local_eval_sets_manager.py::TestLocalEvalSetsManager::test_local_eval_sets_manager_update_eval_case_eval_set_not_found[GOOGLE_AI] - OSError: [Errno 22] Invalid argument: '<tests.unittests.evaluation.test_local_eval_sets_manager.TestLocalEvalSetsManager ob...
FAILED tests/unittests/evaluation/test_local_eval_sets_manager.py::TestLocalEvalSetsManager::test_local_eval_sets_manager_update_eval_case_eval_set_not_found[VERTEX] - OSError: [Errno 22] Invalid argument: '<tests.unittests.evaluation.test_local_eval_sets_manager.TestLocalEvalSetsManager ob...
FAILED tests/unittests/evaluation/test_local_eval_sets_manager.py::TestLocalEvalSetsManager::test_local_eval_sets_manager_delete_eval_case_eval_set_not_found[GOOGLE_AI] - OSError: [Errno 22] Invalid argument: '<tests.unittests.evaluation.test_local_eval_sets_manager.TestLocalEvalSetsManager ob...
FAILED tests/unittests/evaluation/test_local_eval_sets_manager.py::TestLocalEvalSetsManager::test_local_eval_sets_manager_delete_eval_case_eval_set_not_found[VERTEX] - OSError: [Errno 22] Invalid argument: '<tests.unittests.evaluation.test_local_eval_sets_manager.TestLocalEvalSetsManager ob...
FAILED tests/unittests/sessions/test_session_service.py::test_get_session_with_config[GOOGLE_AI-SessionServiceType.DATABASE] - OSError: [Errno 22] Invalid argument
FAILED tests/unittests/sessions/test_session_service.py::test_get_session_with_config[VERTEX-SessionServiceType.DATABASE] - OSError: [Errno 22] Invalid argument
================================= 34 failed, 4540 passed, 3044 warnings in 187.68s (0:03:07) ==================================
```

Co-authored-by: Wei Sun (Jack) <weisun@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2961 from ananyablonko:main b4a21adcd4231efeffd552a96734b2161b317e0a
PiperOrigin-RevId: 828700099
2025-11-05 17:41:35 -08:00
Lorenzo 63b69fbc0f fix(cli): Handle the case when OS doesn't support symlink for adk run
Merge https://github.com/google/adk-python/pull/2582

Relate to #3306

## Description
Fixes issues #6 and #1785 where ADK commands crash on Windows due to symlink creation requiring admin privileges.

## Problem
On Windows, running ADK commands (like `adk run`) fails with `OSError: [WinError 1314] A required privilege is not held by the client: ...` because the logging system attempts to create a symlink for the latest log file. Windows requires administrator privileges for symlink creation by default (unless Developer Mode is enabled), causing crashes for non-admin users.

## Root Cause
The issue was in [`logs.py`](https://github.com/google/adk-python/blob/main/src/google/adk/cli/utils/logs.py#L72) where `os.symlink()` was called unconditionally without error handling, causing the entire CLI to crash when symlink creation failed.

## Solution
This PR implements graceful symlink handling. Changes made:
- Extracted symlink creation into separate function with error handling
- Added graceful fallback when symlink creation fails
- Replaced crashes with warnings to keep CLI functional
- Improved user messaging about log file locations

This solution follows a similar pattern to the one used in [ROS2](https://github.com/ros2) in its [logging module](https://github.com/ros2/launch/blob/rolling/launch/launch/logging/__init__.py#L93).

## Testing
### Before (broken)
```bash
> adk run my_agent
Log setup complete: C:\Users\username\AppData\Local\Temp\agents_log\agent.20250817_215119.log
Traceback (most recent call last):
  File "google\adk\cli\utils\logs.py", line 72, in log_to_tmp_folder
    os.symlink(log_filepath, latest_log_link)
OSError: [WinError 1314] A required privilege is not held by the client
```

### After (fixed)
```bash
> adk run my_agent
Log setup complete: C:\Users\username\AppData\Local\Temp\agents_log\agent.20250817_215319.log
UserWarning: Cannot create symlink for latest log file: [WinError 1314] A required privilege is not held by the client
To access latest log: tail -F C:\Users\username\AppData\Local\Temp\agents_log\agent.20250817_215319.log
Running agent my_agent, type exit to exit.
```

Co-authored-by: Wei Sun (Jack) <weisun@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2582 from lorenzofavaro:fix/windows-symlink-permissions 1e99a6287994f1bfd9ac11550d3dc06205998df5
PiperOrigin-RevId: 828690483
2025-11-05 17:09:51 -08:00
Josh Soref 1d80d32efc chore: Fix spelling in src
Merge https://github.com/google/adk-python/pull/3382

This PR corrects misspellings identified by the [check-spelling action](https://github.com/marketplace/actions/check-spelling)

Note: while I use tooling to identify errors, the tooling doesn't _actually_ provide the corrections, I'm picking them on my own. I'm a human, and I may make mistakes.

### Testing Plan

The misspellings have been reported at https://github.com/jsoref/adk-python/actions/runs/19056081305/attempts/1#summary-54426435973

The action reports that the changes in this PR would make it happy: https://github.com/jsoref/adk-python/actions/runs/19056081446/attempts/1#summary-54426436321

**Unit Tests:**

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

_Please include a summary of passed `pytest` results._

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

_Please provide instructions on how to manually test your changes, including any
necessary setup or configuration. Please provide logs or screenshots to help
reviewers better understand the fix._

### 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.

### Additional context

- follow-up to #2447

Co-authored-by: Hangfei Lin <hangfei@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3382 from jsoref:spelling 3df5932e97391c437e1638d7163e5e3d5c52d5c3
PiperOrigin-RevId: 828686941
2025-11-05 16:59:10 -08:00
Google Team Member 48681cb31b chore: Returns agent state regardless if ctx.is_resumable
This allows state to be passing across agents

PiperOrigin-RevId: 828665491
2025-11-05 15:59:57 -08:00
Josh Soref 59d422ca21 chore: Fix spelling in contributing
Merge https://github.com/google/adk-python/pull/3394

This PR corrects misspellings identified by the [check-spelling action](https://github.com/marketplace/actions/check-spelling)

Note: while I use tooling to identify errors, the tooling doesn't _actually_ provide the corrections, I'm picking them on my own. I'm a human, and I may make mistakes.

### Testing Plan

The misspellings have been reported at https://github.com/jsoref/adk-python/actions/runs/19056081305/attempts/1#summary-54426435973

The action reports that the changes in this PR would make it happy: https://github.com/jsoref/adk-python/actions/runs/19056081446/attempts/1#summary-54426436321

**Unit Tests:**

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

_Please include a summary of passed `pytest` results._

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

_Please provide instructions on how to manually test your changes, including any
necessary setup or configuration. Please provide logs or screenshots to help
reviewers better understand the fix._

### 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.

### Additional context

- https://github.com/google/adk-python/pull/3382#issuecomment-3488654110

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3394 from jsoref:spelling-contributing c3d5e342c4350f7cae9f8f0c6638b176f2e30e80
PiperOrigin-RevId: 828659867
2025-11-05 15:43:25 -08:00
Google Team Member a2ce34a0b9 feat: Migrate BigQuery logging to Storage Write API
This commit refactors the `BigQueryAgentAnalyticsPlugin` to leverage the modern BigQuery Storage Write API, replacing the previous implementation that used the legacy `insert_rows_json` method (based on `tabledata.insertAll`).

**Key Changes:**

*   **Switched to Storage Write API:** Event logs are now ingested using the `BigQueryWriteClient` from the `google-cloud-bigquery-storage` library.
*   **Utilizes Default Stream:** We are using the `_default` stream for sending data, which is an efficient method for streaming in data without needing to manage stream lifecycles. This is ideal for continuous event logging.
*   **Apache Arrow Format:** Log entries are converted to the Apache Arrow format using `pyarrow` before being sent. The BigQuery table schema is dynamically converted to an Arrow schema. This binary format is more efficient than JSON.
*   **Updated Initialization:** The plugin now initializes both the standard `bigquery.Client` (for table management) and the `BigQueryWriteClient`.
*   **Test Updates:** Unit tests in `test_bigquery_logging_plugin.py` have been comprehensively updated to mock the new `BigQueryWriteClient`, `bq_schema_utils`, and `pyarrow` components. Tests now verify calls to `append_rows` and the data structure passed to create the Arrow RecordBatch.

**Benefits of this change:**

*   **Improved Performance:** The Storage Write API is designed for high-throughput streaming and offers better performance compared to the legacy API.
*   **Reduced Cost:** Ingesting data via the Storage Write API is generally more cost-effective.
*   **Enhanced Reliability:** The Storage Write API provides more robust streaming capabilities.
*   **Modernization:** Aligns the plugin with the recommended best practices for BigQuery data ingestion.

This change enhances the efficiency and scalability of the BigQuery logging plugin.

PiperOrigin-RevId: 828655496
2025-11-05 15:33:57 -08:00
Wei Sun (Jack) fa5c546a55 fix(tools): Add proper cleanup for AgentTool to prevent MCP session errors
Merge https://github.com/google/adk-python/pull/3411

## Summary

Fixes AgentTool cleanup to prevent MCP session errors by calling `runner.close()` after sub-agent execution.

## Problem

When using AgentTool with MCP tools, the runner cleanup happened during garbage collection in a different async task context, causing:
```
RuntimeError: Attempted to exit cancel scope in a different task than it was entered in
```

## Solution

- Call `await runner.close()` immediately after sub-agent execution in AgentTool
- This ensures MCP sessions and other resources are cleaned up in the correct async task context
- Updated test mock to include the close() method

## Demo Agents

Added two comprehensive demo agents showing how to use AgentTool with MCP tools:

### mcp_in_agent_tool_remote (SSE mode)
- Uses HTTP/SSE connection to remote MCP server
- Zero-installation setup with `uvx`
- Demonstrates server-side MCP deployment pattern

### mcp_in_agent_tool_stdio (stdio mode)
- Uses subprocess connection with automatic server launch
- Fully automatic setup with `uvx` subdirectory syntax
- Demonstrates embedded MCP deployment pattern

Both demos:
- Use Gemini 2.5 Flash
- Include example prompts for JSON Schema exploration
- Have comprehensive READMEs with architecture diagrams
- Follow ADK agent structure conventions

## Testing

-  All existing unit tests pass
-  Manual testing with both SSE and stdio modes
-  Verified cleanup happens in correct async context
-  No more cancel scope errors with MCP tools

## Related

- Fixes #1112
- Related to #929

Co-authored-by: Wei Sun (Jack) <weisun@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3411 from google:fix/agent-tool-mcp-cleanup 9ae753b5a4
PiperOrigin-RevId: 828651896
2025-11-05 15:23:39 -08:00
Kathy Wu ee8106be77 fix: Fix error handling when MCP server is unreachable
Currently ADK web hangs and logs "AGSI callable returned without completing response" when the server is unreachable. To fix, set timeouts for connecting to server.

Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 828648928
2025-11-05 15:15:58 -08:00
George Weale 99ca6aa6e6 feat: add file-backed artifact service
- add FileArtifactService that persists artifacts to the local filesystem
- adjust BaseArtifactService and exports so callers can wire in the filebacked implementation

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 828629298
2025-11-05 14:26:51 -08:00
George Weale d9ec07d39b docs: Improve Agent Builder Assistant schema reference for prompts
Replace the full JSON schema dump with a compact text summary of key AgentConfig components like LlmAgent, ToolConfig, and GenerateContentConfig

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 828627911
2025-11-05 14:23:18 -08:00
Josh Soref 2b31bd9414 chore: Fix spelling: provide
Merge https://github.com/google/adk-python/pull/3407

This PR corrects misspellings identified by the [check-spelling action](https://github.com/marketplace/actions/check-spelling)

Note: while I use tooling to identify errors, the tooling doesn't _actually_ provide the corrections, I'm picking them on my own. I'm a human, and I may make mistakes.

### Testing Plan

The misspellings have been reported at https://github.com/jsoref/adk-python/actions/runs/19056081305/attempts/1#summary-54426435973

The action reports that the changes in this PR would make it happy: https://github.com/jsoref/adk-python/actions/runs/19056081446/attempts/1#summary-54426436321

**Unit Tests:**

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

_Please include a summary of passed `pytest` results._

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

_Please provide instructions on how to manually test your changes, including any
necessary setup or configuration. Please provide logs or screenshots to help
reviewers better understand the fix._

### 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.

### Additional context

- https://github.com/google/adk-python/pull/3382#issuecomment-3488654110

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3407 from jsoref:spelling-issue-template ce8febc6ab5368640c0ec2ae5d6a2c8ac5bf8ed6
PiperOrigin-RevId: 828610865
2025-11-05 13:40:17 -08:00
Google Team Member e02f177790 feat: Improve gepa tau-bench colab for external use
PiperOrigin-RevId: 828579343
2025-11-05 12:23:47 -08:00
Xuan Yang 9ec38c0d89 feat: Add on_model_error_callback in LlmAgent
Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 828560608
2025-11-05 11:37:08 -08:00
Shangjie Chen d6b928bdf7 chore: Returns agent state regardless if ctx.is_resumable
This allows state to be passing across agents

Co-authored-by: Shangjie Chen <deanchen@google.com>
PiperOrigin-RevId: 828557989
2025-11-05 11:31:26 -08:00
Google Team Member 744f94f0c8 fix: Add None check for event in remote_a2a_agent.py
PiperOrigin-RevId: 828538350
2025-11-05 10:47:24 -08:00
Xuan Yang d8d7774f0f chore: Update v1.18.0 wheel and CHANGELOG.md
Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 828533243
2025-11-05 10:35:33 -08:00
Hangfei Lin 082675546f chore: Stop logging the full content of LLM blobs
The blob content is often large and binary, which makes the logs unreadable and can cause excessive logging.

Co-authored-by: Hangfei Lin <hangfei@google.com>
PiperOrigin-RevId: 828523413
2025-11-05 10:12:07 -08:00
Hangfei Lin aa77834e2e chore: Update Gemini Live model names in live bidi streaming sample
The sample agent now uses updated model names for Gemini Live, including a new Vertex model as the default and a new AI Studio model option.

Co-authored-by: Hangfei Lin <hangfei@google.com>
PiperOrigin-RevId: 828515811
2025-11-05 09:57:59 -08:00
Yeesian Ng 0b1784e0e4 fix: Update dependency version constraints to be based on PyPI versions
Co-authored-by: Yeesian Ng <ysian@google.com>
PiperOrigin-RevId: 828460860
2025-11-05 07:32:00 -08:00
Xuan Yang e01e54e9ee chore: Bumps version to v1.18.0 and updates CHANGELOG.md
Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 828313025
2025-11-04 23:20:57 -08:00
Google Team Member 63353b2b74 feat: Refactor gepa sample code and clean-up user demo colab
PiperOrigin-RevId: 828293079
2025-11-04 22:16:55 -08:00
Nimantha Cooray 4284c61901 fix: agent evaluations detailed output rows wrapping issue
Merge https://github.com/google/adk-python/pull/3381

### Link to Issue or Description of Change

**1. Link to an existing issue (if applicable):**

- Closes: #3363
- This PR sets a max column width for the table printed in detailed output of agent evaluations.

**Problem:**
The detailed output of agent evaluations is not readable due to rows in the table getting wrapped. This happens when there are long text values in cells.

<img width="1904" height="717" alt="508807185-9e8fe1c3-d04a-43dd-acf9-0befaa1b247d" src="https://github.com/user-attachments/assets/61526ad2-8a9e-4c18-83e2-51a3b9b32d2b" />

**Solution:**
Existing code uses `tabulate` python package to format the table. We can set a maximum column width using `maxcolwidths` parameter. I have set it to `25`.

After the fix:
<img width="1882" height="711" alt="508810179-b91c5bca-fb43-480b-90ff-bca2e909417c" src="https://github.com/user-attachments/assets/b653f825-719e-4101-9acb-e28a52694cf8" />

### Testing Plan

I have manually tested if the output is properly displayed after changes. Please let me know if any unit tests can be added for this.

**Unit Tests:**

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

<img width="1627" height="39" alt="image" src="https://github.com/user-attachments/assets/59a70619-3669-4113-8ab7-dcff130ee241" />

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

1. Create a simple agent using adk (preferably an agent that outputs a long text).
2. Create an evalset for this agent.
3. Run the evalset with `print_detailed_results` option and check if the output is properly displayed.

If you want a quick setup for testing this, I have a sample repo with an agent and an evalset [here](https://github.com/nimanthadilz/adk-test/tree/reproduce-print-detailed-results). You will have to manually build & install the fixed adk version to test it.

### 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.
- [ ] 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.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3381 from nimanthadilz:fix-eval-output-rows-wrapping-issue f6d40121f621df60c4596a1c62e0c54e4da309d3
PiperOrigin-RevId: 828265715
2025-11-04 20:40:45 -08:00
Hyeongjun Kang 0c49aef251 chore: correct typo in pyproject.toml (swtich → switch)
Merge https://github.com/google/adk-python/pull/2651

### Summary
Correct a misspelling in the build configuration:
- "swtich" → "switch" in `pyproject.toml`.

### Rationale
This is a spelling fix only. It improves readability and avoids potential confusion in configuration.
There is no impact on runtime behavior, tests, or public APIs.

### Notes
- Follows Conventional Commits style for build/config changes (`build:`).
- CLA status should be green via the Google CLA bot.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2651 from marsboy02:docs/fix-type-pyproject b78c014c864b1a143ffc157c7a8c807f5f19d31d
PiperOrigin-RevId: 828221776
2025-11-04 18:30:22 -08:00
Yeesian Ng d4b2a8b49f feat: Add support for Vertex AI Express Mode when deploying to Agent Engine
Co-authored-by: Yeesian Ng <ysian@google.com>
PiperOrigin-RevId: 828178479
2025-11-04 16:24:07 -08:00
Google Team Member 033f5a5d3f feat: Add configuration options to BigQuery logging plugin
This change introduces BigQueryLoggerConfig to allow customization of the BigQueryAgentAnalyticsPlugin. Users can now enable/disable the plugin, specify event type allowlists and denylists, and provide a custom function to format or redact the content field before logging to BigQuery. The content logged for model and tool errors has also been enhanced.

PiperOrigin-RevId: 828172241
2025-11-04 16:06:49 -08:00
Kathy Wu 88032cf5c5 feat: Support MCP prompts
Add support for MCP prompts via the McpInstructionProvider class, which can be specified as an agent's instruction.

Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 828166051
2025-11-04 15:48:21 -08:00
Kathy Wu 11571c37ab fix: Reduce logging spam for MCP tools without authentication
Users were getting spammed with this log even though their tools didn't require authentication. To fix, reduce the log level to DEBUG so that it doesn't show up by default.

Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 828161281
2025-11-04 15:34:24 -08:00
Hangfei Lin 432d30af48 chore: Add Community Repo section to README
This change introduces a new section in the README.md to highlight the `adk-python-community` GitHub repository, describing it as a place for community-contributed tools and integrations.

Co-authored-by: Hangfei Lin <hangfei@google.com>
PiperOrigin-RevId: 828155205
2025-11-04 15:17:48 -08:00
Google Team Member 54db3d4434 fix: update the contribution analysis tool to use original write mode
PiperOrigin-RevId: 828126582
2025-11-04 14:05:28 -08:00
Kathy Wu 6e5c0eb6e0 feat: Add token usage to live events for bidi streaming
Populate the usage_metadata field for live events with the metadata provided by the Gemini live API.

Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 828124232
2025-11-04 14:01:25 -08:00
Eliza Huang 4f85e86fc3 feat: Add support for extracting cache-related token counts from LiteLLM usage
Closes #3049

Co-authored-by: Eliza Huang <heliza@google.com>
PiperOrigin-RevId: 828091671
2025-11-04 12:43:06 -08:00
Yifan Wang abdc2bb954 chore: update adk web for adk web builder: https://github.com/google/adk-web/pull/248
Co-authored-by: Yifan Wang <wanyif@google.com>
PiperOrigin-RevId: 828061540
2025-11-04 11:27:48 -08:00
George Weale ce91a8ef73 fix: Pass drop_params to LiteLLM completion API
This lets users to specify `drop_params` when initializing `LiteLlm`, which will be forwarded to LiteLLM's `acompletion` or `completion` calls

Close #1718

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 828058105
2025-11-04 11:19:58 -08:00
Shan Cao d4c63fc562 chore: Add model tracking to LiteLlm and introduce a LiteLLM with fallbacks demo
Related: #2292

Co-authored-by: Shan Cao <caoshan@google.com>
PiperOrigin-RevId: 828024955
2025-11-04 10:10:09 -08:00
George Weale e25beb4bce docs: Refine ADK triaging agent labeling guidelines and response format
Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 828022792
2025-11-04 10:05:20 -08:00
George Weale 489c39db01 fix: Remove redundant format field from LiteLLM content objects
LiteLLM providers can extract the MIME type from the data URI. Removing the separate `format` field avoids redundancy and potential issues with backends that may reject requests containing this field.

Close #2017

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 828014286
2025-11-04 09:44:38 -08:00
Google Team Member 38ea749c9c feat: Extend Bigquery detect_anomalies tool to support future data anomaly detection
ARIMA supports both historical data and future data anomaly detection. This CL add how the tool support future table anomaly detection.

PiperOrigin-RevId: 827803748
2025-11-03 23:02:02 -08:00
Haegyun Lee d2888a3766 fix: Fix typo in several files
Merge https://github.com/google/adk-python/pull/3365

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

fix typo for several files.

### 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.
- [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

_Add any other context or screenshots about the feature request here._

Co-authored-by: Liang Wu <wuliang@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3365 from UlookEE:fix_typo 1469de4ea354d1c205268b999183ee86c9d6a1d5
PiperOrigin-RevId: 827724001
2025-11-03 18:07:34 -08:00
Xuan Yang 6a94af24bf chore: Disable SetModelResponseTool workaround for Vertex AI Gemini 2+ models
Gemini models now [support Function calling being used together with structured output on Vertex AI](https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling#structured-output-bp).

Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 827709903
2025-11-03 17:12:01 -08:00
Yifan Wang 8b6ee576d5 chore: remove working_in_progress for agent builder endpoints
Co-authored-by: Yifan Wang <wanyif@google.com>
PiperOrigin-RevId: 827698290
2025-11-03 16:37:38 -08:00
Haegyun Lee f81ebdb622 fix: Bug when callback_context_invocation_context is missing in GlobalInstructionPlugin
Merge #3163
END_PUBLIC

Hello,
Since global_instruction has been deprecated, I’m migrating to GlobalInstructionPlugin.
During the migration, I encountered an error and am submitting this PR to fix it.

In [df05ed6](https://github.com/google/adk-python/commit/df05ed6b3b7b218d85fddc1acd6617802cdf6f2a) ,
GlobalInstructionPlugin references invocation_context, but CallbackContext actually contains _invocation_context.
This mismatch always causes an error during execution.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3180 from UlookEE:fix_global_instruction_plugin e289a12d69812f0abcfe77db0114fdb2045b31bc
PiperOrigin-RevId: 827682501
2025-11-03 15:54:54 -08:00
George Weale c33a680b54 docs: Add instructions to prevent tool hallucination
Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 827632446
2025-11-03 13:41:03 -08:00
Josh Soref aa1233608a chore: Fix spelling
Merge https://github.com/google/adk-python/pull/2447

This PR corrects misspellings identified by the [check-spelling action](https://github.com/marketplace/actions/check-spelling)

The misspellings have been reported at https://github.com/jsoref/adk-python/actions/runs/16840838898/attempts/1#summary-47711379253

The action reports that the changes in this PR would make it happy: https://github.com/jsoref/adk-python/actions/runs/16840839269/attempts/1#summary-47711380479

Note: while I use tooling to identify errors, the tooling doesn't _actually_ provide the corrections, I'm picking them on my own. I'm a human, and I may make mistakes.

I've included a couple of changes to make CI happy. Personally, I object to CI being in a state of "random drive by person who adds a blank line in the middle of a file must fix all the preexisting bugs in the file", but that appears to be the state for this repository.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2447 from jsoref:spelling d85398e7fd154d124d477c6af6181481a01f34e0
PiperOrigin-RevId: 827629615
2025-11-03 13:33:53 -08:00
Google Team Member 8dff85099d fix: Support models slash prefix in model name extraction
Support "models/" prefix in model name extraction

PiperOrigin-RevId: 827557443
2025-11-03 10:32:49 -08:00
Xuan Yang 92a7d19573 fix: Undo adding MCP tools output schema to FunctionDeclaration
Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 827557144
2025-11-03 10:31:58 -08:00
Kacper Jawoszek a02f321f1b chore(otel): Change default of trace_to_cloud to None for Agent Engine deploy
Also added --no-trace_to_cloud to allow for explicit disablement.

This is needed to distinguish between default-on telemetry and explicit disablement via old enable_tracing/trace_to_cloud flags. Same change was done to ADK templates - see https://github.com/googleapis/python-aiplatform/pull/5917/files#diff-54084046c0ff3ec289916eefbb00d04f797ebd02dc15b417fc4fc88137fd2123R439.

Co-authored-by: Kacper Jawoszek <jawoszek@google.com>
PiperOrigin-RevId: 827552868
2025-11-03 10:21:12 -08:00
G. Hussain Chinoy 308da620c1 docs: updates CONTRIBUTING.md
Merge https://github.com/google/adk-python/pull/2286

Clarity for statement, corrects misspelling

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2286 from ghchinoy:patch-1 f50d59858dee4c7412f108dcebbe05697491cdcc
PiperOrigin-RevId: 827541249
2025-11-03 09:54:31 -08:00
nikkie 2c6d6e1594 fix: fix typo for --save_session option in adk run --resume help
Merge https://github.com/google/adk-python/pull/2326

`adk run --help` (adk 1.9.0)

```
  --resume FILE      The json file that contains a previously saved session
                     (by--save_session option). The previous session will be
                     re-displayed. And user can continue to interact with the
                     agent.
```

## testing plan

N/A (because this is a simple string correction)

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2326 from ftnext:fix-typo-run-help-resume a896fa38e223b13e7edd8125d7b38139f1ca3712
PiperOrigin-RevId: 827311506
2025-11-02 21:23:39 -08:00
Jeroen Overschie 44aa82195a docs: fix spelling error in response_for_auth_required parameter docstring
Merge https://github.com/google/adk-python/pull/2680

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2680 from dunnkers:docs/fix-spelling-error-in-parameter-docstring 39782ac73381f6aa6b5392356eb9374b0680d611
PiperOrigin-RevId: 827163203
2025-11-02 08:56:00 -08:00
nikkie 4124f54a36 refactor: Remove unnecessary branching in run_cli
Merge https://github.com/google/adk-python/pull/2537

Streamlined code flow by removing redundant if/else logic

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2537 from ftnext:refactor-run-cli d799e17a7dd7beb0adecd0bd28237a5e09949a6c
PiperOrigin-RevId: 827153566
2025-11-02 08:04:56 -08:00
FingerLiu c4c127df23 fix: fix typo in local_eval_service.py
Merge https://github.com/google/adk-python/pull/2586

_perform_inference_sigle_eval_item -> _perform_inference_single_eval_item

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2586 from FingerLiu:main 78083cb5d4ba1cc90785ad5d727756d467737e08
PiperOrigin-RevId: 826666447
2025-10-31 16:21:25 -07:00
Ankur Sharma b1ff85fb23 chore: Add support for specifying logging level for adk eval cli command
One can now control the logging levels for adk eval cli commands.

Co-authored-by: Ankur Sharma <ankusharma@google.com>
PiperOrigin-RevId: 826654122
2025-10-31 15:41:07 -07:00
Kathy Wu e8526f7e06 fix: Fix credential manager so that it supports the ServiceAccountCredentialExchanger
This fixes MCP authentication for gcloud service accounts. Previously it was failing to authenticate tool calls.

Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 826639044
2025-10-31 14:55:06 -07:00
Yifan Wang a0df75b6fa chore: Add support for reversed proxy in adk web, users can use an optional param --root_path for proxy's path
Co-authored-by: Yifan Wang <wanyif@google.com>
PiperOrigin-RevId: 826632932
2025-10-31 14:37:26 -07:00
Lavi Nigam 0487eea2ab feat: add run_debug() helper method for quick agent experimentation
Merge https://github.com/google/adk-python/pull/3345

Add run_debug() helper method to InMemoryRunner that reduces agent execution boilerplate from 7-8 lines to just 2 lines, making it ideal for quick experimentation, notebooks, and getting started with ADK.

**Key changes:**
• Introduce run_debug() to reduce boilerplate from 7-8 lines to 2 lines
• Enable quick testing in notebooks, REPL, and during development
• Support single or multiple messages with automatic session management
• Add verbose flag to show/hide tool calls and intermediate processing
• Add quiet flag to suppress console output while capturing events
• Extract event printing logic to reusable utility (utils/_debug_output.py)
• Include comprehensive test suite with 21 test cases covering all part types
• Provide complete working example with 8 usage patterns
• **This is a convenience method for experimentation, not a replacement for run_async()**

### Link to Issue or Description of Change

**1. Link to an existing issue (if applicable):**

* N/A - New feature to improve developer experience

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

**Problem:**

Developers need to write 7-8 lines of boilerplate code just to test a simple agent interaction during development. This creates friction for:

* New developers getting started with ADK
* Quick experimentation in Jupyter notebooks or Python REPL
* Debugging agent behavior during development
* Writing examples and tutorials
* Rapid prototyping of agent capabilities

**Solution:**

Introduce `run_debug()` as a convenience helper method specifically designed for quick experimentation and getting started scenarios. This method:

* **Is NOT a replacement for `run_async()`** - it's a developer convenience tool
* **Reduces boilerplate** from 7-8 lines to just 2 lines for simple testing
* **Handles session management automatically** with sensible defaults
* **Provides debugging visibility** with optional verbose flag for tool calls
* **Supports common patterns** like multiple messages and event capture
* **Type-safe implementation** using direct attribute access instead of getattr()

### Before vs After Comparison

**BEFORE - Current approach requires 7-8 lines of boilerplate:**

```python
from google.adk import Agent
from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService
from google.genai import types

# Define a simple agent
agent = Agent(
    model="gemini-2.5-flash",
    instruction="You are a helpful assistant"
)

# Need all this boilerplate just to test the agent
APP_NAME = "default"
USER_ID = "default"
session_service = InMemorySessionService()
runner = Runner(agent=agent, app_name=APP_NAME, session_service=session_service)
session = await session_service.create_session(
    app_name=APP_NAME, user_id=USER_ID, session_id="default"
)
content = types.Content(role="user", parts=[types.Part.from_text("Hello")])
async for event in runner.run_async(
    user_id=USER_ID, session_id=session.id, new_message=content
):
    if event.content and event.content.parts:
        print(event.content.parts[0].text)
```

**AFTER - With run_debug() helper, just 2 lines:**

```python
from google.adk import Agent
from google.adk.runners import InMemoryRunner

# Define the same agent
agent = Agent(
    model="gemini-2.5-flash",
    instruction="You are a helpful assistant"
)

# Test it with just 2 lines!
runner = InMemoryRunner(agent=agent)
await runner.run_debug("Hello")
```

### API Design

```python
async def run_debug(
    self,
    user_messages: str | list[str],
    *,
    user_id: str = 'debug_user_id',
    session_id: str = 'debug_session_id',
    run_config: RunConfig | None = None,
    quiet: bool = False,
    verbose: bool = False,
) -> list[Event]:
```

**Parameters:**

* `user_messages`: Single message string or list of messages (required)
* `user_id`: User identifier (default: 'debug_user_id')
* `session_id`: Session identifier for conversation continuity (default: 'debug_session_id')
* `run_config`: Optional advanced configuration
* `quiet`: Suppress console output (default: False)
* `verbose`: Show detailed tool calls and responses (default: False)

**Key Features:**

* **Always returns events** - Simplifies API, no conditional return type
* **Type-safe implementation** - Uses direct attribute access on Pydantic models
* **Text buffering** - Consecutive text parts printed without repeated author prefix
* **Smart truncation** - Long tool args/responses truncated for readability
* **Clean session management** - Get-then-create pattern, no try/except
* **Reusable printing logic** - Extracted to utils/_debug_output.py for other tools

### Implementation Highlights

**1. Event Printing Utility (utils/_debug_output.py):**
* Modular print_event() function for displaying events
* Text buffering to combine consecutive text parts
* Configurable truncation for different content types:
  - Function args: 50 chars max
  - Function responses: 100 chars max
  - Code output: 100 chars max
* Supports all ADK part types (text, function_call, executable_code, inline_data, file_data)

**2. Session Management:**
```python
# Clean get-then-create pattern (no try/except)
session = await self.session_service.get_session(
    app_name=self.app_name, user_id=user_id, session_id=session_id
)
if not session:
    session = await self.session_service.create_session(
        app_name=self.app_name, user_id=user_id, session_id=session_id
    )
```

**3. Type-Safe Event Processing:**
* Direct attribute access on Pydantic models (no getattr() or hasattr())
* Proper handling of all part types
* Leverages `from __future__ import annotations` for duck typing

### Important Note on Scope

`run_debug()` is a **convenience method for experimentation only**. For production applications requiring:

* Custom session services (Spanner, Cloud SQL)
* Fine-grained event processing control
* Error recovery and resumability
* Performance optimization
* Complex authentication flows

Continue using the standard `run_async()` method. The `run_debug()` helper is specifically designed to lower the barrier to entry and speed up the development/testing cycle.

### Testing Plan

**Unit Tests (21 test cases in tests/unittests/runners/test_runner_debug.py):**

**Core functionality (7 tests):**
*  Single message execution and event return
*  Multiple messages in sequence
*  Quiet mode (suppresses output)
*  Custom session_id configuration
*  Custom user_id configuration
*  RunConfig passthrough
*  Session persistence across calls

**Part type handling (8 tests):**
*  Tool calls and responses (verbose mode)
*  Executable code parts
*  Code execution result parts
*  Inline data (images)
*  File data references
*  Mixed part types in single event
*  Long output truncation
*  Verbose flag behavior (show/hide tools)

**Edge cases (6 tests):**
*  None text filtering
*  Existing session handling
*  Empty parts list
*  None event content
*  Verbose=False hides tool calls
*  Verbose=True shows tool calls

**All 21 tests passing in 3.8s** ✓

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

Tested all 8 example patterns in contributing/samples/runner_debug_example/main.py:

1.  Minimal 2-line usage
2.  Multiple sequential messages
3.  Session persistence across calls
4.  Multiple user sessions (Alice & Bob)
5.  Verbose mode for tool visibility
6.  Event capture with quiet mode
7.  Custom RunConfig integration
8.  Before/after comparison

### Files Changed

**Core implementation:**
* src/google/adk/runners.py - Added run_debug() method (~60 lines)
* src/google/adk/utils/_debug_output.py - Event printing utility (~106 lines)

**Tests:**
* tests/unittests/runners/test_runner_debug.py - Comprehensive test suite (21 tests)

**Examples:**
* contributing/samples/runner_debug_example/agent.py - Sample agent with tools
* contributing/samples/runner_debug_example/main.py - 8 usage examples
* contributing/samples/runner_debug_example/README.md - Complete documentation

### 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 (21/21 passing)
- [x] I have manually tested my changes end-to-end (8 examples tested)
- [x] Code follows ADK style guide (relative imports, type hints, 2-space indentation)
- [x] Ran ./autoformat.sh before committing
- [x] Any dependent changes have been merged and published in downstream modules

### Additional Context

**Example with Tools (verbose mode):**

```python
# Create agent with tools
agent = Agent(
    model="gemini-2.5-flash",
    instruction="You can check weather and do calculations",
    tools=[get_weather, calculate]
)

# Test with verbose to see tool calls
runner = InMemoryRunner(agent=agent)
await runner.run_debug("What's the weather in SF?", verbose=True)

# Output:
# User > What's the weather in SF?
# agent > [Calling tool: get_weather({'city': 'San Francisco'})]
# agent > [Tool result: {'result': 'Foggy, 15°C (59°F)'}]
# agent > The weather in San Francisco is foggy, 15°C (59°F).
```

**Complete Example Included:**

The PR includes a full working example in `contributing/samples/runner_debug_example/` with:
* Agent with weather and calculator tools
* 8 different usage patterns
* Comprehensive README with troubleshooting
* Safe AST-based expression evaluation

**Breaking Changes:** None - this is purely additive.

**Security:** Example uses AST-based expression evaluation instead of eval().

**Code Quality:**
* Type-safe implementation (no getattr() or hasattr())
* Modular design (printing logic separated into utility)
* Follows ADK conventions (relative imports, from __future__ import annotations)
* Comprehensive error handling (gracefully handles None content, empty parts)
* Well-documented with docstrings and inline comments
END_PUBLIC
```

---

## Key Changes from Original:

1.  Updated parameter name: `user_queries` → `user_messages`
2.  Updated parameter name: `session_name` → `session_id`
3.  Updated parameter name: `print_output` → `quiet`
4.  Removed `return_events` parameter
5.  Updated test count: 23 → 21
6.  Changed "queries" → "messages" throughout
7.  Added implementation highlights section
8.  Added details about utils/_debug_output.py
9.  Updated default values to debug_user_id/debug_session_id
10.  Noted type-safe implementation
11.  Added Code Quality section
12.  Updated API signature to match final refactored version
13.  Removed optional return type (always returns list[Event])

Co-authored-by: Wei Sun (Jack) <weisun@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3345 from lavinigam-gcp:adk-runner-helper e0050b9f152d0f0e49e6501610d2c59a754fc571
PiperOrigin-RevId: 826607817
2025-10-31 13:28:02 -07:00
Google Team Member 0b56f2287b refactor(bigquery): Remove dataset_id from logging schema
Removes the dataset_id field from the BigQuery table schema and from each log entry created by the BigQueryAgentAnalyticsPlugin. This field is redundant, as all rows logged to a specific table belong to the same dataset.

To ensure the plugin can still target the correct dataset, dataset_id is now a required argument in the BigQueryAgentAnalyticsPlugin constructor, and its default value has been removed.

The BigQuery client user_agent is also updated with plugin version info to help identify traffic originating from this plugin. Unit tests have been updated to reflect the removal of dataset_id from log entries.

PiperOrigin-RevId: 826596499
2025-10-31 12:57:54 -07:00
Dongyu Jia 156d235479 feat: Allow injecting a custom Runner into agent_to_a2a
This change adds an optional `runner` parameter to the `to_a2a` function, enabling users to provide a pre-configured `Runner` instance instead of always using the default in-memory services. A new test case has been added to verify this functionality.

closes #3104

Co-authored-by: Dongyu Jia <dongyuj@google.com>
PiperOrigin-RevId: 826526861
2025-10-31 09:54:59 -07:00
Dongyu Jia 338c3c89c6 fix: Add example and fix for loading and upgrading old ADK session databases
This change introduces a sample (`migration_session_db`) demonstrating how to load a session database created with an older version of ADK (e.g., 1.15.0) and make it compatible with the current version. It includes a script (`db_migration.sh`) to alter the SQLite schema automatically. to_event is updated to handle potential discrepancies in pickled `EventActions` by using `model_copy` to ensure compatibility with the latest `EventActions` model definition.

Related to #3272 #3197, Closes #3197 #3272

Co-authored-by: Dongyu Jia <dongyuj@google.com>
PiperOrigin-RevId: 826524368
2025-10-31 09:47:53 -07:00
Eliza Huang a2c6a8a85c feat: Expose the Python code run by the code interpreter in the logs
Co-authored-by: Eliza Huang <heliza@google.com>
PiperOrigin-RevId: 826521391
2025-10-31 09:38:53 -07:00
Google Team Member 546c2a6816 feat: Remove custom polling logic for Vertex AI Session Service since LRO polling is supported in express mode
PiperOrigin-RevId: 826226731
2025-10-30 16:13:43 -07:00
Ayush Agrawal dea7668d1a chore: Allow google-cloud-storage >=3.0.0
Fixes #3012

Co-authored-by: Ayush Agrawal <ayushagra@google.com>
PiperOrigin-RevId: 826207388
2025-10-30 15:21:50 -07:00
Ankur Sharma 5cb35db921 chore: Avoid rendering empty columns as part of detailed results rendering of eval results
It is common for expected response and expected tool calls column to be empty for user simulated conversations. So, we don't render those.

Co-authored-by: Ankur Sharma <ankusharma@google.com>
PiperOrigin-RevId: 826202867
2025-10-30 15:08:07 -07:00
Kevin Qian b8a2b6c570 fix: include delimiter when matching events from parent nodes in content processor
Previously we only do a simple prefix string matching, thus `agent_00` will match with `agent_0`

With this new change, we either check directly equality, or must expect seeing `agent_0.`. See added test for branches we now match / skip.

TBF `.` is also not a perfect delimiter (I would imagine users might put dot in agent names). We might consider a follow up that bans such agent names.

Tested with script in the linked issue (I updated prompt so we see which agent they see from):

Before:

```
[agent_8]: 73
[agent_0]: 97
[agent_1]: 73
[agent_5]: 97
[agent_4]: 73
[agent_2]: 73
[agent_3]: 73
[agent_9]: 93
[agent_6]: 73
[agent_7]: 1
[agent_70]: 1 (agent_7)
[agent_20]: 73 (agent_2)
[agent_30]: 73 (agent_3)
[agent_00]: 97 (agent_0)
[agent_40]: 73 (agent_4)
[agent_80]: 73 (agent_8)
[agent_50]: 97 (agent_5)
[agent_90]: 93 (agent_9)
[agent_10]: 73 (agent_1)
[agent_60]: 73 (agent_6)
```

After:
```
[agent_9]: 73
[agent_6]: 73
[agent_2]: 73
[agent_7]: 93
[agent_4]: 73
[agent_1]: 73
[agent_3]: 73
[agent_5]: 97
[agent_0]: 73
[agent_8]: 87
[agent_50]: 0
[agent_80]: 0
[agent_10]: 0
[agent_90]: 0
[agent_30]: 0
[agent_20]: 0
[agent_60]: 0
[agent_00]: 0
[agent_40]: 0
[agent_70]: 0
```

Closes #2948

Co-authored-by: Kevin Qian <kqian@google.com>
PiperOrigin-RevId: 826187198
2025-10-30 14:26:39 -07:00
Google Team Member 2274c4f304 feat: Add "final_session_state" to the EvalCase data model
This will allow setting a golden expectation on the session state for agents that will modify the states.

PiperOrigin-RevId: 826166904
2025-10-30 13:38:27 -07:00
Wei Sun (Jack) 610e219a9f ci: Fixes the copybara-pr-handler.yml file location, it should be under workflow folder
Co-authored-by: Wei Sun (Jack) <weisun@google.com>
PiperOrigin-RevId: 826143689
2025-10-30 12:37:56 -07:00
Jaroslav Pantsjoha 34d9b53f37 feat: Enhance error messages for tool and agent not found errors
Merge https://github.com/google/adk-python/pull/3219

## Summary

Enhance error messages for tool and agent not found errors to provide actionable guidance and reduce developer debugging time from hours to minutes.

Fixes #3217

## Changes

### Modified Files

1. **`src/google/adk/flows/llm_flows/functions.py`**
   - Enhanced `_get_tool()` error message with:
     - Available tools list (formatted, truncated to 20 for readability)
     - Possible causes
     - Suggested fixes
     - Fuzzy matching suggestions

2. **`src/google/adk/agents/llm_agent.py`**
   - Enhanced `__get_agent_to_run()` error message with:
     - Available agents list (formatted, truncated to 20 for readability)
     - Timing/ordering issue explanation
     - Fuzzy matching for agent names
   - Added `_get_available_agent_names()` helper method

### New Test Files

3. **`tests/unittests/flows/llm_flows/test_functions_error_messages.py`**
   - Tests for enhanced tool not found error messages
   - Fuzzy matching validation
   - Edge cases (no close matches, empty tools dict, 100+ tools)

4. **`tests/unittests/agents/test_llm_agent_error_messages.py`**
   - Tests for enhanced agent not found error messages
   - Agent tree traversal validation
   - Fuzzy matching for agents
   - Long list truncation

## Testing Plan

### Unit Tests

```bash
pytest tests/unittests/flows/llm_flows/test_functions_error_messages.py -v
pytest tests/unittests/agents/test_llm_agent_error_messages.py -v
```

**Results**:  8/8 tests passing

```
tests/unittests/flows/llm_flows/test_functions_error_messages.py::test_tool_not_found_enhanced_error PASSED
tests/unittests/flows/llm_flows/test_functions_error_messages.py::test_tool_not_found_fuzzy_matching PASSED
tests/unittests/flows/llm_flows/test_functions_error_messages.py::test_tool_not_found_no_fuzzy_match PASSED
tests/unittests/flows/llm_flows/test_functions_error_messages.py::test_tool_not_found_truncates_long_list PASSED
tests/unittests/agents/test_llm_agent_error_messages.py::test_agent_not_found_enhanced_error PASSED
tests/unittests/agents/test_llm_agent_error_messages.py::test_agent_not_found_fuzzy_matching PASSED
tests/unittests/agents/test_llm_agent_error_messages.py::test_agent_tree_traversal PASSED
tests/unittests/agents/test_llm_agent_error_messages.py::test_agent_not_found_truncates_long_list PASSED

8 passed, 1 warning in 4.38s
```

### Example Enhanced Error Messages

#### Before (Current Error)

```
ValueError: Function get_equipment_specs is not found in the tools_dict: dict_keys(['get_equipment_details', 'query_vendor_catalog', 'score_proposals'])
```

#### After (Enhanced Error)

```
Function 'get_equipment_specs' is not found in available tools.

Available tools: get_equipment_details, query_vendor_catalog, score_proposals

Possible causes:
  1. LLM hallucinated the function name - review agent instruction clarity
  2. Tool not registered - verify agent.tools list
  3. Name mismatch - check for typos

Suggested fixes:
  - Review agent instruction to ensure tool usage is clear
  - Verify tool is included in agent.tools list
  - Check for typos in function name

Did you mean one of these?
  - get_equipment_details
```

## Community Impact

- **Addresses 3 active issues**: #2050, #2933 (12 comments), #2164
- **Reduces debugging time** from 3+ hours to < 5 minutes (validated in production multi-agent RFQ solution for recent partner nanothon initiative)
- **Improves developer experience** for new ADK users

## Implementation Details

- Uses standard library `difflib` for fuzzy matching (no new dependencies)
- Error path only (no performance impact on happy path)
- Measured performance: < 0.03ms per error
- Truncates long lists to first 20 items to prevent log overflow
- Fully backward compatible (same exception types)

## Checklist

- [x] Unit tests added and passing (8/8 tests)
- [x] Code formatted with `./autoformat.sh` (isort + pyink)
- [x] No new dependencies (uses standard library `difflib`)
- [x] Docstrings updated
- [x] Tested with Python 3.11
- [x] Issue #3217 created and linked

## Related Issues

- Fixes #3217
- Addresses #2050 - Tool verification callback request
- Addresses #2933 - How to handle "Function is not found in the tools_dict" Error
- Addresses #2164 - ValueError: {agent} not found in agent tree

---

**Note**: For production scenarios where LLM tool hallucinations occur, ADK's built-in [`ReflectAndRetryToolPlugin`](https://github.com/google/adk-python/blob/main/src/google/adk/plugins/reflect_retry_tool_plugin.py) can automatically retry failed tool calls (available since v1.16.0). This PR's enhanced error messages complement that by helping developers quickly identify and fix configuration issues during development.

Cheers, JP

Co-authored-by: Yvonne Yu <yyyu@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3219 from jpantsjoha:feat/better-error-messages a4df8bfb031685dce9e528d8eb7006f53447b75b
PiperOrigin-RevId: 826132579
2025-10-30 12:08:13 -07:00
Ayush Agrawal 5eca72f9bf fix: Correct message part ordering in A2A history
Merges test case from https://github.com/google/adk-python/pull/3262

Fixes: #3260

Co-authored-by: Ayush Agrawal <ayushagra@google.com>
PiperOrigin-RevId: 826119626
2025-10-30 11:36:38 -07:00
Shubham Saboo b0017aed44 chore: Revise README for clarity and consistency
Merge https://github.com/google/adk-python/pull/3335

Updated terminology in README for clarity and consistency.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3335 from Shubhamsaboo:patch-1 57d574e2e28c539e97fcb7f5d82bc1d00ca7149e
PiperOrigin-RevId: 826105701
2025-10-30 11:02:27 -07:00
George Weale 1e6a9daa63 fix: Change instruction insertion to respect tool call/response pairs
Make sure _add_instructions_to_user_content skips over user messages that carry function_response parts so tool_use/tool_result blocks stay together

Close #3229

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 826076141
2025-10-30 09:54:49 -07:00
Eliza Huang d3796f9b33 feat: Add example for using ADK with Fast MCP sampling
Close #2893

Co-authored-by: Eliza Huang <heliza@google.com>
PiperOrigin-RevId: 826070077
2025-10-30 09:39:36 -07:00
Wei Sun (Jack) 9704d27dfb ci: Add a github action to automatically close the PR imported and committed by Copybara
Include a manual mode for testing first and will remove after verifying it works.

When a commit with `Merge https://github.com/google/adk-python/pull/3333` in description is pushed by copybara, the workflow will automatically close the PR.

Co-authored-by: Wei Sun (Jack) <weisun@google.com>
PiperOrigin-RevId: 826058313
2025-10-30 09:09:19 -07:00
Ieva Grublyte ec86608734 docs: Add sample agent to test support of output_schema, tools and subagents at the same time for gemini model
Co-authored-by: Ieva Grublyte <ievagrublyte@google.com>
PiperOrigin-RevId: 826006607
2025-10-30 06:35:09 -07:00
Ieva Grublyte c0892c725c chore: remove legacy validation that forbids co-exist of agent transfer and output_schema. Closes #3318
Remove validation for output_schema and agent transfer flags.

The check that prevented `output_schema` from co-existing with agent transfer capabilities (`disallow_transfer_to_parent` or `disallow_transfer_to_peers` being False) has been removed. The agent will no longer automatically set these transfer flags to True when `output_schema` is present.

Co-authored-by: Ieva Grublyte <ievagrublyte@google.com>
PiperOrigin-RevId: 825998224
2025-10-30 06:06:26 -07:00
Ayam ce8f674a28 fix: Allow LLM request to override the model used in the generate content async method in LiteLLM
Merge https://github.com/google/adk-python/pull/3066

Close #3065

Co-authored-by: Raman Mangla <ramanmangla@google.com>
PiperOrigin-RevId: 825880794
2025-10-29 23:34:33 -07:00
Xuan Yang 3814d8b80f docs: Update agent builder assistant to query knowledge base through HTTP instead of a2a
Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 825848638
2025-10-29 21:32:48 -07:00
hung12ct fc15c9a0c3 fix: Update DynamicPickleType to support MySQL dialect
Merge https://github.com/google/adk-python/pull/3282

The `process_bind_param` and `process_result_value` methods in the `DynamicPickleType` class have been modified to handle MySQL dialect in addition to Spanner. This change ensures that pickled values are correctly processed for both database types.

**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

**1. Link to an existing issue (if applicable):**

- Closes: #3283

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

_If applicable, please follow the issue templates to provide as much detail as
possible._

**Problem:**
When using `DatabaseSessionService` with MySQL backend in google-adk v1.17.0, the application crashes with the following error: app.resources.runner:event_generator:260 - Error in event_generator: (builtins.TypeError) 'tuple' object cannot be interpreted as an integer
<img width="1237" height="129" alt="image" src="https://github.com/user-attachments/assets/0a5fc223-600a-4a92-8443-4d37fb1267f6" />

Root cause: The `DynamicPickleType` class in `database_session_service.py` configures MySQL dialect to use `LONGBLOB` for storing pickled data (line 117-118), but the `process_bind_param` and `process_result_value` methods only handle pickle serialization/deserialization for Spanner dialect, not MySQL. This causes MySQL to attempt storing raw Python objects instead of pickled bytes, leading to serialization errors and potential data corruption.

**Solution:**
Added MySQL to the pickle serialization logic in both `process_bind_param` and `process_result_value` methods, treating it the same way as Spanner dialect. This ensures that:
- Data is properly pickled to bytes before being stored in MySQL's LONGBLOB column
- Data is properly unpickled when retrieved from the database
- No breaking changes to existing functionality for other dialects (SQLite, PostgreSQL)

### Testing Plan

_Please describe the tests that you ran to verify your changes. This is required
for all PRs that are not small documentation or typo fixes._

**Unit Tests:**

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

**Summary of `pytest` results:**
<img width="929" height="306" alt="image" src="https://github.com/user-attachments/assets/3d548b96-ac49-4101-8405-a289a722293c" />

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

_Please provide instructions on how to manually test your changes, including any
necessary setup or configuration. Please provide logs or screenshots to help
reviewers better understand the fix._

### 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

_Add any other context or screenshots about the feature request here._

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3282 from hung12ct:fix/mysql-pickle-serialization d9df37adb7dfbbfd8502a0fe65c4f8bca3d0d978
PiperOrigin-RevId: 825834360
2025-10-29 20:39:58 -07:00
Eliza Huang f9569bbb1a fix: Enable usage metadata in LiteLLM streaming
Closes #3181

Co-authored-by: Eliza Huang <heliza@google.com>
PiperOrigin-RevId: 825833660
2025-10-29 20:37:54 -07:00
Eliza Huang 01b48c09ad feat: Add example demonstrating JSON passing between agents
Co-authored-by: Eliza Huang <heliza@google.com>
PiperOrigin-RevId: 825831151
2025-10-29 20:29:45 -07:00
Eliza Huang 71aa5645f6 fix: Propagate LiteLLM finish_reason to LlmResponse for use in callbacks
Closes #3114.

Co-authored-by: Eliza Huang <heliza@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3319 from lizzij:fix/litellm-finish-reason-3109 da6ed0aec514231fc274fee744f885ae95b9d45c
PiperOrigin-RevId: 825783229
2025-10-29 17:55:03 -07:00
Dongyu Jia 64294572c1 feat: Add get_job_info tool to BigQuery toolset
This CL introduces a new tool, get_job_info, to the BigQuery toolset. This tool allows retrieving metadata about a BigQuery job, such as slot usage, job configuration, statistics, and job status.

Closes #2928

Co-authored-by: Dongyu Jia <dongyuj@google.com>
PiperOrigin-RevId: 825762399
2025-10-29 16:46:31 -07:00
Ankur Sharma 72a8d8d85b fix: Session input file are required for creating an eval case
Session input file contains fields that are needed to run evals and later be able retrieve the session generated by them.

Co-authored-by: Ankur Sharma <ankusharma@google.com>
PiperOrigin-RevId: 825742522
2025-10-29 15:53:45 -07:00
Hangfei Lin b23eed6a85 feat: Remove @experimental from App class
This change marks the `App` class as no longer experimental.

Co-authored-by: Hangfei Lin <hangfei@google.com>
PiperOrigin-RevId: 825739749
2025-10-29 15:45:56 -07:00
Google Team Member 9014a849ea feat: Add api key argument to Vertex Session and Memory services for Express Mode support
We also change VertexAiSessionService and VertexAiMemoryBankService to both use keyword arguments for project, location, agent engine id, and express mode api key

PiperOrigin-RevId: 825719331
2025-10-29 14:54:12 -07:00
Jack Sun d45b31fb45 chore: Ignore AI coding tool project-specific configs in .gitignore
Merge https://github.com/google/adk-python/pull/3333

## Summary

Add ignore patterns for popular AI coding assistant configuration files to prevent committing developer-specific settings. This aligns with the project's approach of providing `AGENTS.md` as a general starting point that developers can symlink or copy and customize locally.

## Changes

Added `.gitignore` patterns for 10 popular AI coding tools:

- **Claude Code** - `.claude/`, `CLAUDE.md`
- **Cursor** - `.cursor/`, `.cursorrules`, `.cursorignore`
- **Windsurf** - `.windsurfrules`
- **Aider** - `.aider*`
- **Continue.dev** - `.continue/`
- **Codeium** - `.codeium/`
- **GitHub Next** - `.githubnext/`
- **Roo Code** - `.roo/`, `.rooignore`
- **Bolt** - `.bolt/`
- **v0** - `.v0/`

## Rationale

Each developer may want different AI tool configurations and personal instructions. By ignoring these files, we:
- Prevent accidental commits of personal AI assistant settings
- Keep the repository clean of developer-specific configurations
- Allow developers to customize their AI tools without affecting others
- Maintain consistency with the project's `AGENTS.md` approach

Co-authored-by: Yvonne Yu <yyyu@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3333 from google:chore/ignore-ai-tool-configs 0abe4ccdf130ac93c3d2c353556f0ce7c305c429
PiperOrigin-RevId: 825682646
2025-10-29 13:24:15 -07:00
Google Team Member 04dbc42e50 feat: Improve Tau-bench ADK colab stability
PiperOrigin-RevId: 825675599
2025-10-29 13:08:12 -07:00
Google Team Member 592c5d870e feat: Add initial colab to run GEPA on Tau-bench with ADK
PiperOrigin-RevId: 825675276
2025-10-29 13:07:24 -07:00
Google Team Member c0c67c8698 feat: Add ADK-based agent factory for Tau-bench
PiperOrigin-RevId: 825674874
2025-10-29 13:06:24 -07:00
Google Team Member 87f415a7c3 feat: Add util to run ADK LLM Agent with simulation environment
PiperOrigin-RevId: 825674499
2025-10-29 13:05:33 -07:00
Google Team Member e7f7705eba ADK changes
PiperOrigin-RevId: 825644096
2025-10-29 11:52:10 -07:00
Wei Sun (Jack) 2216fe7c04 docs: Update AGENTS.md with latest development guidelines and make it general for all AI coding tools
Usage: you can create symlink to AGENTS.md with the file name required by the specific AI coding tool.

Co-authored-by: Wei Sun (Jack) <weisun@google.com>
PiperOrigin-RevId: 825627185
2025-10-29 11:14:48 -07:00
George Weale 0ce2d564f2 chore: Update agent triaging rules and owners
PiperOrigin-RevId: 825572235
2025-10-29 09:06:12 -07:00
Vishwa Murugan c8e5340962 fix: Propagate MCP tools output schema to FunctionDeclaration
PiperOrigin-RevId: 825380145
2025-10-28 23:03:47 -07:00
Google Team Member 1ee93c8bcb fix: do not consider events with state delta and no content as final response
Previously this will return true for events yielded from before_agent_callback when there are state changes.

Note with this change, it will also return false for state delta only callbacks even after main response, but this is fine as long as the actual final response event has it to be true.

Closes #2992

PiperOrigin-RevId: 825313208
2025-10-28 19:36:34 -07:00
Kevin Qian 6bdac02dfc fix: do not consider events with state delta and no content as final response
Previously this will return true for events yielded from before_agent_callback when there are state changes.

Note with this change, it will also return false for state delta only callbacks even after main response, but this is fine as long as the actual final response event has it to be true.

Closes #2992

PiperOrigin-RevId: 825279439
2025-10-28 17:41:03 -07:00
Omar Elcircevi 74a3500fc5 fix: #3036 parameter filtering for CrewAI functions with **kwargs
Merge https://github.com/google/adk-python/pull/3037

fix: [#3036](https://github.com/google/adk-python/issues/3036)

- Fix FunctionTool parameter filtering to support CrewAI-style tools
- Functions with **kwargs now receive all parameters except 'self' and 'tool_context'
- Maintains backward compatibility with explicit parameter functions
- Add comprehensive tests for **kwargs functionality

Fixes parameter filtering issue where CrewAI tools using **kwargs pattern would receive empty parameter dictionaries, causing search_query and other parameters to be None.

#non-breaking

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3037 from omarcevi:fix/function-tool-kwargs-parameter-filtering 012bbfcfd68e83a29635ac74718a1bd1323c5187
PiperOrigin-RevId: 825275686
2025-10-28 17:30:59 -07:00
Ayush Agrawal 15afbcd158 feat: Add ADK_DISABLE_LOAD_DOTENV environment variable that disables automatic loading of .env when running ADK cli, if set to true or 1
Fixes #3228

PiperOrigin-RevId: 825273905
2025-10-28 17:25:40 -07:00
Ayush Agrawal ee8acc58be chore: Allow tenacity 9.0.0
Fixes #2962

PiperOrigin-RevId: 825269865
2025-10-28 17:13:05 -07:00
Xinran (Sherry) Tang 420de9c5be test: Add a test case for resuming any invocation
PiperOrigin-RevId: 825266283
2025-10-28 17:03:07 -07:00
Ayush Agrawal 2f72ceb49b chore: Do not treat FinishReason.STOP as error case for LLM responses containing candidates with empty contents
Fixes #2905

PiperOrigin-RevId: 825263302
2025-10-28 16:54:50 -07:00
Artem Oroberts 8eeff35b35 feat: Demonstrate CodeExecutor customization for environment setup
This change introduces a powerful pattern for customizing code execution environments by extending a base `CodeExecutor`. It showcases how to inject setup code to prepare the environment before a user's code is run, enabling advanced use cases that require specific configurations.

As a practical example, this change implements `CustomCodeExecutor`, a subclass of `VertexAiCodeExecutor`, to solve the problem of rendering non-standard characters in `matplotlib` plots (Issue #2993). The custom executor programmatically adds a Japanese font to the `matplotlib` font manager at runtime.

This is achieved by overriding the `execute_code` method to add font files to execution input and prepend the necessary font-loading logic. This approach is not limited to fonts and can be adapted for other setup tasks.

Fixes: #2993
PiperOrigin-RevId: 825240143
2025-10-28 15:53:03 -07:00
Artem Oroberts edfe553942 feat: Add sample agent for VertexAiCodeExecutor
This change introduces a new sample agent and documentation to demonstrate the usage of the `VertexAiCodeExecutor`.

The new agent, located at `vertex_code_execution/agent.py`, is a direct counterpart to the existing sample at `code_execution/agent.py`. The key difference is that this new agent uses `VertexAiCodeExecutor` to execute code within the Vertex AI Code Interpreter Extension, whereas the original sample uses `BuiltInCodeExecutor` to run code in the model's built-in sandbox.

A `README.md` file is also included to provide an overview, setup instructions, and sample usage for the new agent.

Related: #2993
PiperOrigin-RevId: 825239758
2025-10-28 15:52:14 -07:00
Ankur Sharma 1aa9bb13b3 chore: Update vertex ai in example store and rag retrieval to use proxy
PiperOrigin-RevId: 825237803
2025-10-28 15:46:38 -07:00
Wei Sun (Jack) 61adfcd69a refactor: Adds a util method to check the enablement of any env variable
PiperOrigin-RevId: 825199260
2025-10-28 14:18:45 -07:00
Liang Wu 971eafab96 feat: Add crewai[tools] to pyproject.toml test section
This dependency is added for Python versions 3.10 and above to support CrewaiTool unit tests. https://github.com/google/adk-python/actions/runs/18813223838/job/53801335597?pr=3037.

PiperOrigin-RevId: 825189153
2025-10-28 13:49:01 -07:00
Google Team Member 9851340ad1 feat: Add Bigquery detect_anomalies tool
This change introduces a new `detect_anomalies` tool in `query_tool.py` which uses BigQuery ML's `CREATE MODEL` with `ARIMA_PLUS` type and `ML.DETECT_ANOMALIES` to detect anomalies. The new function is also added to the `bigquery_toolset`.

PiperOrigin-RevId: 825181489
2025-10-28 13:30:04 -07:00
George Weale 74d8361a7e fix: Add a fallback user message to LiteLLM requests if the last user message is empty
Related to #3255
Close #2560

PiperOrigin-RevId: 825143315
2025-10-28 11:56:47 -07:00
SOORAJ TS 240ef5beea feat: Added support for enums as arguments for function tools (#3088)
* feat: Added support for enums as arguments for function tools

* feat: Add default value support for function tools
fix: Add more test cases inside `test_build_function_declaration.py` for passing Enums as arguments

* fix: format code with pyink

---------

Co-authored-by: Wei Sun (Jack) <weisun@google.com>
Co-authored-by: Yvonne Yu <150068659+yyyu-google@users.noreply.github.com>
2025-10-28 10:35:02 -07:00
Ankur Sharma b17c8f19e5 chore: Marked expected_invocation as optional field on evaluator interface
ADK already has a set of metrics that don't rely expected_invocations. Also, for eval cases with conversation scenario, this would be the main line case.

PiperOrigin-RevId: 825101481
2025-10-28 10:27:47 -07:00
Shangjie Chen 9ab17f2afd fix: Yield the long running tool response before pausing execution
PiperOrigin-RevId: 825056377
2025-10-28 08:41:47 -07:00
Wei Sun (Jack) 86f01550bd docs: Fixes null check for reflect_retry plugin sample
PiperOrigin-RevId: 824836190
2025-10-27 22:13:06 -07:00
Hoonji Baek 6c3882f2d6 fix: Creates evalset directory on evalset create
PiperOrigin-RevId: 824746602
2025-10-27 17:26:32 -07:00
Google Team Member 87dcb3f7ba feat: Add ApigeeLlm as a model that let's ADK Agent developers to connect with an Apigee proxy
PiperOrigin-RevId: 824712152
2025-10-27 15:53:33 -07:00
Ankur Sharma 00d147d62f fix: check if eval config file exists
PiperOrigin-RevId: 824709118
2025-10-27 15:45:14 -07:00
Google Team Member b7dbfed4a3 feat: Add BigQueryLoggingPlugin for event logging to BigQuery
Introduces the `BigQueryLoggingPlugin` for capturing and sending ADK lifecycle events to Google BigQuery. This allows for persistent storage and analysis of agent and tool interactions. The plugin supports asynchronous logging, automatic dataset/table creation, and comprehensive event capture.

Also refactors common formatting utilities (_format_content, _format_args) for shared use.

PiperOrigin-RevId: 824703739
2025-10-27 15:30:56 -07:00
George Weale 0a87e02ffd fix: Rename agent config files to match the agent name
PiperOrigin-RevId: 824702674
2025-10-27 15:27:45 -07:00
George Weale 19f52467db docs: Update ADK agent builder instructions for model callback signatures
PiperOrigin-RevId: 824690587
2025-10-27 14:58:32 -07:00
George Weale 1ca82068fd docs: Automatically create __init__.py files when writing Python files
PiperOrigin-RevId: 824690193
2025-10-27 14:57:34 -07:00
Marlin Ranasinghe ab00c41fc9 fix: nullable types with gen ai bump
Merge https://github.com/google/adk-python/pull/3280

Fixes: #3281
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3280 from MarlzRana:marlzrana/fix-nullable-types-w-gen-ai-bump ad28b82cbdbb7980406086787e098bbe6478a354
PiperOrigin-RevId: 824659954
2025-10-27 13:43:50 -07:00
Shangjie Chen e194ebb33c feat: Implement artifact_version related methods in GcsArtifactService
PiperOrigin-RevId: 824646770
2025-10-27 13:13:07 -07:00
Google Team Member 1a4261ad4b fix: Fix issue with MCP tools throwing an error
Fixes: https://github.com/google/adk-python/issues/3082
PiperOrigin-RevId: 824620839
2025-10-27 12:08:43 -07:00
Xuan Yang 36ca4f1204 feat: Add on_tool_error_callback in LlmAgent
PiperOrigin-RevId: 824598502
2025-10-27 11:16:36 -07:00
Google Team Member 496f8cd6bb fix: output file uploading to artifact service should handle both base64 encoded and raw bytes
PiperOrigin-RevId: 824590321
2025-10-27 10:58:39 -07:00
Shangjie Chen f7e2a7a40e chore: Make VertexAiSessionService fully asynchronous
This CL refactors VertexAiSessionService to use the asynchronous aio client for all Vertex AI API calls. This ensures that the service methods are non-blocking and can be used effectively in an asyncio environment.

PiperOrigin-RevId: 824573356
2025-10-27 10:19:25 -07:00
Liang Wu 48ddd07894 chore:clarify the behavior of disallow_transfer_to_parent
The original description is not clear enough and can create confusion like https://github.com/google/adk-python/issues/3081.

PiperOrigin-RevId: 824564227
2025-10-27 10:01:21 -07:00
Wei Sun (Jack) e0e5384e33 chore: Limits fastapi to <0.119, so that swagger api can still render
Temp workaround for #3173.

PiperOrigin-RevId: 824279228
2025-10-26 16:44:27 -07:00
Wei Sun (Jack) 16d4b9acca docs: Revise BaseAgent.after_agent_callback to be more clear
Clarify the behavior raised in #3266

PiperOrigin-RevId: 824273003
2025-10-26 16:10:42 -07:00
Max Ind e6f7363220 fix: set execute_tool {tool.name} span attributes even when exception occurs during tool's execution
PiperOrigin-RevId: 824165197
2025-10-26 06:07:25 -07:00
Google Team Member 5d9a7e7f79 feat: enable persistent browser sessions in the computer use sample
The computer_use sample now supports launching with a `user_data_dir` to maintain browser state across runs. The sample agent is updated to use a shared temporary directory for the browser profile, preserving login sessions and other data.

PiperOrigin-RevId: 823749082
2025-10-24 19:15:10 -07:00
George Weale f8a9672b38 docs: Make sure LlmAgent as the immutable root agent in ADK configurations
PiperOrigin-RevId: 823699363
2025-10-24 16:10:24 -07:00
Kathy Wu fb96d17230 fix: Fix import for live bidi streaming single agent
While testing the bidi streaming sample agent, I noticed that the import was erroring and I think it's a typo -- the other bidi sample agents all import `from google.adk.agents.llm_agent`.

PiperOrigin-RevId: 823662586
2025-10-24 14:17:04 -07:00
Keyur Joshi 54c4ecc733 feat: Adds LLM-Backed User Simulator
Details:
- Adds the `LlmBackedUserSimulator` which uses an LLM to generate user prompts until it decides that the conversation is complete.
- Adds unit tests for the new functionality.
PiperOrigin-RevId: 823557910
2025-10-24 09:24:12 -07:00
Shangjie Chen 97a224fe46 chore: Clean up rag memory dependencies
PiperOrigin-RevId: 823556599
2025-10-24 09:19:49 -07:00
Google Team Member 64d9d6909c chore: Remove rogue print statement from agent_evaluator.py
PiperOrigin-RevId: 823552039
2025-10-24 09:06:06 -07:00
Hangfei Lin d767fccd5b chore: Add Community Events section to README
This change adds a new section to the README.md, detailing past community events. The first entry is for the completed ADK's 1st community meeting, with links to the recording and deck.

PiperOrigin-RevId: 823322924
2025-10-23 21:10:48 -07:00
George Weale d193c396d6 docs: Add root agent requirement to instructions so it does not create workflow agents as root agent
PiperOrigin-RevId: 823256724
2025-10-23 17:46:11 -07:00
George Weale 53209f1bb9 docs: Clarify research tool instructions in YAML agent
PiperOrigin-RevId: 823255928
2025-10-23 17:43:20 -07:00
Xuan Yang 0d0fb4d034 ci: Remove reviewer assignment in the PR triaging agent
PiperOrigin-RevId: 823255296
2025-10-23 17:40:57 -07:00
George Weale 0660779ff0 docs: Update agent builder instructions to restrict fields on workflow agents
PiperOrigin-RevId: 823254695
2025-10-23 17:39:07 -07:00
Al Duncanson 0dbfb43052 fix: Update _evaluate_single_inference_result documentation
Merge https://github.com/google/adk-python/pull/3123

Update `_evaluate_single_inference_result` documentation

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3123 from alDuncanson:spelling-fix b7bb4d4180a481794a42a60817536e426e55cdb3
PiperOrigin-RevId: 823193022
2025-10-23 14:39:22 -07:00
Ankur Sharma bb32a6356c chore: Adding traceback logging to inference step of eval
Right now the failure eats up the traceback information and there is no clear way for the developer to know what went wrong. Adding this traceback info could give them the needed debugging information.

PiperOrigin-RevId: 823179833
2025-10-23 14:05:06 -07:00
Google Team Member ba631764a5 feat: Introduce custom_metadata field to run_config and propagate a2a request metadata to that field
PiperOrigin-RevId: 823066539
2025-10-23 09:14:19 -07:00
Ankur Sharma 955632ce2c feat:Allow agent evaluation from modules ending in ".agent"
PiperOrigin-RevId: 822888194
2025-10-22 23:11:48 -07:00
Ankur Sharma 6d4d72a499 chore: Update vertexai & rouge scorer dependencies in eval to use a proxy
PiperOrigin-RevId: 822881672
2025-10-22 22:44:53 -07:00
Vrajesh Babu A V 45a2168e0e chore: Adds a new sample agent that demonstrates how to integrate PostgreSQL databases using the Model Context Protocol (MCP)
## What's Added

- **PostgreSQL MCP Agent** ([mcp_postgres_agent/agent.py](cci:7://file:///Users/admin/git%20repos/adk-python/contributing/samples/mcp_postgres_agent/agent.py:0:0-0:0)): A fully functional agent that connects to PostgreSQL databases via the `postgres-mcp` MCP server
- **Comprehensive README** ([mcp_postgres_agent/README.md](cci:7://file:///Users/admin/git%20repos/adk-python/contributing/samples/mcp_postgres_agent/README.md:0:0-0:0)): Documentation with setup instructions, configuration details, and example queries
- **Environment Configuration**: Support for secure credential management via `.env` files

## Key Features

- **MCP Integration**: Demonstrates proper use of `MCPToolset` with `StdioConnectionParams`
- **Zero Installation**: Uses `uvx` to run the MCP server without manual installation
- **Secure Credentials**: Database connection strings passed via environment variables
- **Production-Ready**: Uses Gemini 2.0 Flash with unrestricted access mode for full database operations

## Technical Details

- **Model**: Gemini 2.0 Flash
- **MCP Server**: `postgres-mcp` (via `uvx`)
- **Connection**: StdioConnectionParams with 60-second timeout
- **Environment Variable**: Maps `POSTGRES_CONNECTION_STRING` to `DATABASE_URI`

## Testing

The agent has been tested with:
- PostgreSQL database connections (local and remote)
- Schema inspection queries
- Data querying operations
- Table listing and management

## Example Queries

Users can interact with the agent using natural language queries like:
- "What tables are in the database?"
- "Show me the schema for the users table"
- "Query the first 10 rows from the products table"

This sample serves as a reference implementation for developers looking to integrate PostgreSQL databases with ADK agents using MCP.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3182 from Vrajesh-Babu:postgres-mcp f3b3846abae37ae376d3554624ac2b1be82f7adc
PiperOrigin-RevId: 822865931
2025-10-22 21:44:25 -07:00
George Weale 9cf7ab11a8 docs: Update agent builder instructions for clarity and best practices for ADK specific requirements
PiperOrigin-RevId: 822862453
2025-10-22 21:31:40 -07:00
Hangfei Lin 055e86a9d4 chore: Update ADK README with new features
The "What's new" section has been updated to highlight: Custom API Registration, Rewind functionality, and a new CodeExecutor utilizing the Vertex AI Code Execution Sandbox API. Previous updates on context compaction, resumability, ReflectRetryToolPlugin, and search tool support have been removed.

PiperOrigin-RevId: 822848112
2025-10-22 20:36:30 -07:00
Hangfei Lin 33fd712e29 chore: Remove community call announcement from README
The section detailing the first ADK community call scheduled for Oct 15, 2025, including date, time, meeting links, and agenda, has been removed.
The section detailing the first ADK community call scheduled for Oct 15, 2025, including date, time, meeting links, and agenda, has been removed.

PiperOrigin-RevId: 822843889
2025-10-22 20:21:55 -07:00
Ankur Sharma 23092a273a feat: Consolidate external dependencies in a single place
PiperOrigin-RevId: 822771891
2025-10-22 15:55:33 -07:00
George Weale 4c58b767e5 docs: Update ADK Agent Builder Assistant instructions for workflow tools
PiperOrigin-RevId: 822756480
2025-10-22 15:11:16 -07:00
Google Team Member c426c48005 No public description
PiperOrigin-RevId: 822754668
2025-10-22 15:07:00 -07:00
George Weale f1e01ea4b0 docs: Update ADK Agent Builder Assistant instructions and clarified built-in tool naming
PiperOrigin-RevId: 822752065
2025-10-22 14:59:50 -07:00
George Weale c9647f3536 docs: Update agent builder instructions to require explicit agent_class
PiperOrigin-RevId: 822742468
2025-10-22 14:31:32 -07:00
Xuan Yang e28d3c55f8 chore: Add a pull request template
PiperOrigin-RevId: 822736669
2025-10-22 14:15:18 -07:00
Liang Wu 3ee1cd24db chore:Update conformance create command to record in documentation
PiperOrigin-RevId: 822736103
2025-10-22 14:14:06 -07:00
Hangfei Lin 91cc03e96f chore: Bump ADK version to 1 17 0
This release includes updates to the changelog with new features across Core, Evals, Integrations, Observability, Services, Tools, and UI, along with various bug fixes and improvements. The base CL number has also been updated.

PiperOrigin-RevId: 822730595
2025-10-22 14:01:26 -07:00
Kathy Wu d8c66fe688 fix: Update the saving artifact text for BuiltInCodeExecutor to be more human readable
Since it appears in the same bubble as the rest of the LLM's response text, make it more human readable so it doesn't look out of place.

PiperOrigin-RevId: 822729061
2025-10-22 13:57:41 -07:00
Liang Wu c6cf11cb74 chore:Rename conformance create command to record
PiperOrigin-RevId: 822708044
2025-10-22 13:03:37 -07:00
Yifan Wang 2724819622 chore: update adk web, fixing cursor color, and thought bubble
PiperOrigin-RevId: 822693836
2025-10-22 12:27:28 -07:00
Alexey Guseynov 2f4f5611bd fix:Remove unnecessary Aclosing
PiperOrigin-RevId: 822496695
2025-10-22 02:40:07 -07:00
Wei Sun (Jack) 4df926388b fix: Returns dict as result from McpTool
The `BaseTool` expects the run_async to return a json-serializable object. By model_dump the McpTool result explicitly can allow what ADK runtime sees is identical to what is persisted in the session event list.

Before the change, runtime sees CallToolResult instance and Session persists its serialized dict.

https://github.com/modelcontextprotocol/python-sdk/blob/main/src/mcp/types.py#L916-L922

PiperOrigin-RevId: 822465432
2025-10-22 00:58:04 -07:00
Wei Sun (Jack) d4dc645478 chore: Fixes MCPToolset --> McpToolset in various places
PiperOrigin-RevId: 822377517
2025-10-21 19:42:37 -07:00
Wei Sun (Jack) 7d5c6b9acf fix: Fixes the identity prompt to be one line and add ending period after description statement
From

```
You are an agent. Your internal name is "agent".

 The description about you is "test description"
```

to

```
You are an agent. Your internal name is "agent". The description about you is "test description".
```

PiperOrigin-RevId: 822358196
2025-10-21 18:31:48 -07:00
Yifan Wang aab2504ebd chore: update adk web
PiperOrigin-RevId: 822341297
2025-10-21 17:31:20 -07:00
Shangjie Chen 391628fcdc feat: Add a service registry to provide a generic way to register custom service implementations to be used in FastAPI server
To register a custom service:
- Create a factory function that takes a URI and returns an instance of your custom service. This function will parse any details it needs from the URI.
- Register your factory with the global service registry. You need to define a unique URI scheme for your service (e.g., custom).

PiperOrigin-RevId: 822310466
2025-10-21 15:58:51 -07:00
Luis Pabon 409df1378f feat: Granular Per Agent Speech Configuration
Merge https://github.com/google/adk-python/pull/3170

Addresses Feature Request: #3116

This PR adds a `speech_config` to the **LLM Agent configuration** for the **live use case**. When an **asynchronous LLM** call is made to the **Gemini Live API**, it prioritizes the most specific agent configuration's speech_config. If that is null, it then uses the run configuration's speech_config. Unit tests have been added to verify this behavior.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3170 from qyuo:bidi_agent_speech_config af1bd277d4f95c4a7d9aa0b16828ba3de826ce08
PiperOrigin-RevId: 822305427
2025-10-21 15:44:00 -07:00
Shangjie Chen 2a901d12f4 chore: Raise AlreadyExistsError when trying to create a resource with same ID
Move the dedupe logic into session service so that the internal error can be surfaced to client

PiperOrigin-RevId: 822294430
2025-10-21 15:11:33 -07:00
Xuan Yang c850da3a07 fix: Fix the broken langchain importing caused their 1.0.0 release
PiperOrigin-RevId: 822279014
2025-10-21 14:30:34 -07:00
Parham MohammadAlizadeh ed37e343f0 feat(tools): support additional headers for google api toolset #non-breaking
Merge https://github.com/google/adk-python/pull/3194

Allow Google API toolsets to accept optional per-request headers
#3105

## Testing Plan

### Unit Tests
-  Added `test_init_with_additional_headers` in `test_google_api_tool.py` to verify headers are passed to RestApiTool
-  Added `test_prepare_request_params_merges_default_headers` in `test_rest_api_tool.py` to verify custom headers are merged into requests
-  Added `test_prepare_request_params_preserves_existing_headers` in `test_rest_api_tool.py` to verify critical headers (Content-Type, User-Agent) are not overridden by additional_headers
-  Updated `test_init` and `test_get_tools` in `test_google_api_toolset.py` to verify the parameter is properly stored and passed through

### Manual Testing
Tested with Google Ads API scenario (the original use case from issue #3105):

```python
import os
from google.adk.tools.google_api_tool import GoogleApiToolset

# Create toolset with developer-token header required by Google Ads API
google_ads_toolset = GoogleApiToolset(
    client_id=os.environ["CLIENT_ID"],
    client_secret=os.environ["CLIENT_SECRET"],
    api_name="googleads",
    api_version="v21",
    additional_headers={"developer-token": os.environ["GOOGLE_ADS_DEV_TOKEN"]}
)

# Verify headers are included in API requests
tools = await google_ads_toolset.get_tools()
# Successfully made requests with the developer-token header
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3194 from Prhmma:feature/google-api-toolset-additional-headers-3105 e10489e82bfde5cf2bfd3f1bced3e1f5cea1f8b2
PiperOrigin-RevId: 822273582
2025-10-21 14:16:37 -07:00
Kathy Wu ce3418a69d fix: Fix BuiltInCodeExecutor so that it can support visualizations
Previously BuiltInCodeExecutor was missing the logic to save output files from executed code as artifacts, so images/visualizations wouldn't show up in the UI. This fix will iterate through all parts of the LlmResponse, and if any of them are images, it will save the image data using artifact_service (similar to what is done in VertexAICodeExecutor).

This fixes the backend, but there are still UI bugs that should be fixed -- events without content are currently ignored, so the image doesn't appear even though it is saved. We will add the UI fix in a separate change.

PiperOrigin-RevId: 822245140
2025-10-21 13:06:43 -07:00
George Weale fe1fc75c15 chore: Improve hint message in agent loader
PiperOrigin-RevId: 822216833
2025-10-21 11:54:32 -07:00
George Weale dc4975dea9 fix: relax runner app-name enforcement
- let _enforce_app_name_alignment warn instead of raising while caching the hint that now augments the existing “Session not found …” error
- tighten _infer_agent_origin so it ignores hidden folders (like .venv)
- make AgentTool reuse the parent runner’s app_name, stopping internal runners from conflicting in multi-agent setups

PiperOrigin-RevId: 822205860
2025-10-21 11:30:21 -07:00
Google Team Member aeaec859bf feat: Adds Static User Simulator and User Simulator Provider
Details:
- Adds the `StaticUserSimulator` which implements the current functionality of supplying a fixed set of user prompts for an EvalCase.
- Adds the `UserSimulatorProvider` which determines the type of user simulator required for an EvalCase (StaticUserSimulator or LlmBackedUserSimulator).
- Integrates the UserSimulatorProvider and UserSimulator into the CLI and evaluation infrastructure.
- Updates and adds unit tests for the new functionality.
- Miscellaneous updates to lay groundwork for a full implementation of the LlmBackedUserSimulator in the future.
PiperOrigin-RevId: 822198401
2025-10-21 11:15:11 -07:00
Jaroslav Pantsjoha 4a842c5a13 fix(cli): Improve error message when adk web is run in wrong directory
Merge https://github.com/google/adk-python/pull/3196

## Summary
Enhances the `AgentLoader` error message to provide clear guidance when users run `adk web` from incorrect directories.

## Motivation
During internal workshops, multiple teams encountered confusion when starting `adk web` from the wrong directory. This often happened when:
- Running `adk web my_agent/` instead of `adk web .`
- Being inside an agent directory when executing the command
- Configuring incorrect start paths during development

## Changes
- **Smart detection**: Checks if `agent.py` or `root_agent.yaml` exists in the current directory
- **Visual diagram**: Shows expected directory structure with actual agent name
- **Explicit command**: Includes `adk web <agents_dir>` usage example
- **Conditional hint**: Provides targeted guidance when user is detected to be inside an agent directory

## Example Error Message

### Before
```
ValueError: No root_agent found for 'my_agent'. Searched in 'my_agent.agent.root_agent', 'my_agent.root_agent' and 'my_agent/root_agent.yaml'. Ensure 'path/my_agent' is structured correctly, an .env file can be loaded if present, and a root_agent is exposed.
```

### After
```
ValueError: No root_agent found for 'my_agent'. Searched in 'my_agent.agent.root_agent', 'my_agent.root_agent' and 'my_agent/root_agent.yaml'.

Expected directory structure:
  <agents_dir>/
    my_agent/
      agent.py (with root_agent) OR
      root_agent.yaml

Then run: adk web <agents_dir>

Ensure 'path/my_agent' is structured correctly, an .env file can be loaded if present, and a root_agent is exposed.

HINT: It looks like you might be running 'adk web' from inside an agent directory. Try running 'adk web .' from the parent directory that contains your agent folder, not from within the agent folder itself.
```

## Testing
-  Existing unit tests pass (17/22, with 5 pre-existing failures unrelated to this change)
-  `test_agent_not_found_error` passes, confirming error message enhancement works correctly
-  Code follows ADK contribution guidelines

## Type
- [x] Bug fix (improved error messaging)
- [ ] Feature
- [ ] Breaking change
- [ ] Documentation

## Related
Fixes #3195

---

**Tags**: #non-breaking

🤖 Generated with [Claude Code](https://claude.com/claude-code)

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3196 from jpantsjoha:fix/improve-adk-web-error-message a73b190f5b021dbe0afa8426172696ee9eeae8da
PiperOrigin-RevId: 822186700
2025-10-21 10:47:30 -07:00
Wei Sun (Jack) 0bdba30263 docs: format README.md for samples
PiperOrigin-RevId: 822180731
2025-10-21 10:35:43 -07:00
Shangjie Chen 6a5eac0bdc feat: Allow passing extra kwargs to create_session of VertexAiSessionService
This can be used to set ttl and other configs.

PiperOrigin-RevId: 821782343
2025-10-20 13:34:07 -07:00
ejfn 0b73a6937b fix: Handle App objects in eval and graph endpoints
Merge https://github.com/google/adk-python/pull/3060

## Description

Fixes #3059

This PR fixes two endpoints in `adk web` that fail when using App objects instead of bare agents.

## Changes

- **Eval execution endpoint** (line ~969): Extract root_agent from App objects before passing to LocalEvalService
- **Graph visualization endpoint** (line ~1308): Extract root_agent from App objects before graph operations

Both endpoints now properly handle both BaseAgent and App objects by checking the type and extracting `.root_agent` when needed.

## Testing Plan

### Manual E2E Testing with ADK Web

Tested with an App object that includes context caching:

```python
from google.adk.apps import App
from google.adk.agents import LlmAgent

root_agent = LlmAgent(name="MyAgent", model="gemini-1.5-pro-002")
app = App(
    name="my_agent",
    root_agent=root_agent,
    context_cache_config=ContextCacheConfig(...)
)
```

**Before fix:**
- Graph visualization failed (tried to call agent methods on App object)
- Eval execution failed (LocalEvalService received App instead of agent)

**After fix:**
- Graph visualization works correctly
- Eval execution works correctly
- Both endpoints properly extract root_agent from App objects

## Checklist

- [x] Code follows project style (autoformat.sh passed)
- [x] Changes are focused and minimal
- [x] Issue #3059 created and referenced
- [x] Manual E2E testing completed

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3060 from ejfn:ejfn/bugfix-app-object-endpoints 01c30191bfd9487a8c8463ccf24b297cb9a4ce37
PiperOrigin-RevId: 821746910
2025-10-20 12:11:26 -07:00
Google Team Member ee39a89110 feat: introduces a new AgentEngineSandboxCodeExecutor class that supports executes agent generated code
The AgentEngineSandboxCodeExecutor uses the Vertex AI Code Execution Sandbox API to execute code

PiperOrigin-RevId: 821699641
2025-10-20 10:14:34 -07:00
Shangjie Chen d327538724 chore: Throw 409 already exist error when trying to create a session with existing id
Resolves https://github.com/google/adk-python/issues/2950

PiperOrigin-RevId: 821362008
2025-10-19 11:21:36 -07:00
Google Team Member a5b742b360 feat: introduces a new AgentEngineSandboxCodeExecutor class that supports executes agent generated code
The AgentEngineSandboxCodeExecutor uses the Vertex AI Code Execution Sandbox API to execute code

PiperOrigin-RevId: 821197794
2025-10-18 20:24:04 -07:00
Wei Sun (Jack) af74eba695 test: Skips test_langchain_tool.py temporarily after their new 1.0.0 release breaks existings deps of langchain
PiperOrigin-RevId: 820875043
2025-10-17 16:53:11 -07:00
Google Team Member dbd818be0b feat: introduces a new AgentEngineSandboxCodeExecutor class that supports executes agent generated code
The AgentEngineSandboxCodeExecutor uses the Vertex AI Code Execution Sandbox API to execute code

PiperOrigin-RevId: 820854185
2025-10-17 15:42:24 -07:00
Xiang (Sean) Zhou a2d9f13fa1 chore: Add span for context caching handling and new cache creation
PiperOrigin-RevId: 820852233
2025-10-17 15:37:35 -07:00
Wei Sun (Jack) 0df67599c0 chore: Checks gemini version for 2 and above for gemini-builtin tools
PiperOrigin-RevId: 820848897
2025-10-17 15:27:47 -07:00
Shangjie Chen 8b3ed059c2 chore: Refactor and fix state management in the session service
Also refactoring the test cases to focus on the expected behaviors

PiperOrigin-RevId: 820734484
2025-10-17 10:04:36 -07:00
Ankur Sharma cf3403231d chore: Fix evaluation test cases to only use pytest features
PiperOrigin-RevId: 820700378
2025-10-17 08:25:17 -07:00
Shangjie Chen 9dce06f9b0 feat: Add rewind_async to support rewinding the session to before a previous invocation
PiperOrigin-RevId: 820552460
2025-10-16 23:24:40 -07:00
George Weale 307896aece fix: Exclude additionalProperties from Gemini schemas
PiperOrigin-RevId: 820542466
2025-10-16 22:40:43 -07:00
Kathy Wu 6dcbb5aca6 feat: Support dynamic per-request headers in MCPToolset
Add a header_provider param which is a callable[ReadonlyContext, Dict[str, Any]] for users to build headers in MCPToolset
fix: https://github.com/google/adk-python/issues/3156
PiperOrigin-RevId: 820412372
2025-10-16 15:12:43 -07:00
Xiang (Sean) Zhou 2a8fdd94e1 chore: Add computer use sample agent
PiperOrigin-RevId: 820407078
2025-10-16 14:59:27 -07:00
Xuan Yang 37a153ef94 ci: Fix the logs importing for PR triaging agent
PiperOrigin-RevId: 820395414
2025-10-16 14:27:18 -07:00
Giovanni Galloro ce4638651f docs: Bump models in llms and llms-full to Gemini 2.5
Merge https://github.com/google/adk-python/pull/3166

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3166 from ggalloro:model-updates e741c8b266ef8cd7def203f94e8d9f8608c06685
PiperOrigin-RevId: 820381464
2025-10-16 13:53:45 -07:00
Doug Gebert e6e2767c39 chore: Update gemini_llm_connection.py - typo spelling correction
Merge https://github.com/google/adk-python/pull/3168

Fixed misspelling on line 228 from:
- logger.info('Redeived session...

To:
- logger.info('Received session...
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3168 from DHHHG:patch-1 90b76d72ba474cd0092b2cc8d955b918c18d05bd
PiperOrigin-RevId: 820369618
2025-10-16 13:23:58 -07:00
Kacper Jawoszek e50f05a9fc feat(otel): env variable for disabling llm_request and llm_response in spans
The default without the variable set is to keep the content in spans to keep backward compatible behavior for existing users.

This allows to enable tracing without potential PII data from request and response. Google GenAI instrumentation lib requires an explicit opt-in to enable request and response content - see https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/instrumentation-genai/opentelemetry-instrumentation-google-genai#enabling-message-content.

PiperOrigin-RevId: 820351154
2025-10-16 13:07:27 -07:00
Xuan Yang 9dc00360e3 ci: Add state info for PR triaging agent
PiperOrigin-RevId: 820340584
2025-10-16 13:07:18 -07:00
Google Team Member 5a543c00df feat: implement new methods in in-memory artifact service
* save_artifact with custom_metadata
* list_artifact_versions
* get_artifact_version

PiperOrigin-RevId: 820321444
2025-10-16 13:07:09 -07:00
Alexey Guseynov 1e1d63f34c fix: Internal change
PiperOrigin-RevId: 820159440
2025-10-16 13:07:00 -07:00
Xuan Yang f51380f9ea feat: Extend ReflectAndRetryToolPlugin to support hallucinating function calls
PiperOrigin-RevId: 820051762
2025-10-16 13:06:51 -07:00
Xuan Yang 3734ceaa6c fix: Use the agent's model when creating Google search agent tool
PiperOrigin-RevId: 819980797
2025-10-16 13:06:41 -07:00
Google Team Member 86097afe49 feat: Update AgentEvaluator to handle async ADK agent definitions
AgentEvaluator should recognize root_agent and get_agent_async as valid structures for ADK agent definitions.

PiperOrigin-RevId: 819976635
2025-10-16 13:06:31 -07:00
Google Team Member a17f3b2e6d feat: Allow custom request and event converters in A2aAgentExecutor
This change introduces type aliases for request and event conversion functions:
- `A2ARequestToADKRunArgsConverter`: For converting A2A `RequestContext` to an `ADKRunArgs` Pydantic model.
- `AdkEventToA2AEventsConverter`: For converting ADK `Event` to a list of A2A `A2AEvent` objects.

The `convert_a2a_request_to_adk_run_args` function now returns a structured `ADKRunArgs` model instead of a generic dictionary, improving type safety.

These converter types can now be provided via the `A2aAgentExecutorConfig` to customize the conversion logic used by the `A2aAgentExecutor`. The executor defaults to the existing `convert_a2a_request_to_adk_run_args` and `convert_event_to_a2a_events` functions if no custom converters are specified.

This allows users to inject their own logic for handling request and event conversions, for example, to add custom metadata or transform data types, without modifying the core executor.

PiperOrigin-RevId: 819934960
2025-10-16 13:06:21 -07:00
Shangjie Chen 6ab1498aa0 fix: Add usage_metadata and citation_metadata to DatabaseSessionService
PiperOrigin-RevId: 819900773
2025-10-16 13:05:52 -07:00
Google Team Member 2424d6a3b1 feat: Reorder create_time and mime_type to ArtifactVersion
Before: http://sponge2/ba05f9ac-c13d-43b6-bb8a-3e1b029cc705(failed)
After: http://sponge2/a623ba76-62c1-4d17-b4b6-22044333a801
PiperOrigin-RevId: 819896989
2025-10-15 13:46:12 -07:00
Lin Nikaido 36c96ec5b3 fix: #2883 pickle data was truncated error in database session using MySql
Merge https://github.com/google/adk-python/pull/2884

closes: #2883
# Fix
When put leage data into event and load it. the _pickle.UnpicklingError was occurred.
The root caurse is `DynamicPickleType` mapping `BLOB` as default in case of MySql, not `LONGBLOB`. And learge data will be able to cut off tail of data. And raise pickle error.

# What todo
Defined `LONFBLOB` as default explicitly.

# Question
Where should we code the test code like this case? I cannot found the test code the DB and table was created expectedly.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2884 from Lin-Nikaido:fix/#2883-mysql-datatype-fix 2be9b38fc3f5d5083b0b6715a2bf7b4eff5d947b
PiperOrigin-RevId: 819891727
2025-10-15 13:33:22 -07:00
Shangjie Chen a985cc38ec feat: Support return all sessions when user id is none
PiperOrigin-RevId: 819884236
2025-10-15 13:14:24 -07:00
machache b650181384 feat: add support for ContetxtWindowCompressionConfig in RunConfig
Merge https://github.com/google/adk-python/pull/2206

### Summary

This PR adds support for `ContextWindowCompressionConfig` in `RunConfig`.
This enables context window compression using a `trigger_tokens` threshold and a sliding window with a `target_tokens` limit.

This feature is useful for managing long-running audio inputs.

### Related Issue

Closes #2188

### Testing Plan

- Added new unit test: `test_streaming_with_context_window_compression_config`

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2206 from ac-machache:support/add-context-compression-config c8a5b15cae2d2b72f331797d07ae0bbaf977ed3c
PiperOrigin-RevId: 819855786
2025-10-15 12:00:21 -07:00
Kathy Wu 78e74b5bf2 feat: Add require_confirmation param for MCP tool/toolset
This allows users to require human approval for using MCP tools.

PiperOrigin-RevId: 819800747
2025-10-15 09:58:31 -07:00
Ankur Sharma d82c492140 chore: Remove deprecated convert_session_to_eval_format function
This change removes the `convert_session_to_eval_format` function and its associated unit tests. New tests for `create_gcs_eval_managers_from_uri` are also added.

PiperOrigin-RevId: 819576620
2025-10-14 22:37:49 -07:00
Xuan Yang 05aa3fa38b fix: Remove the PR triaging agent's dependence on "bot triaged" label
PiperOrigin-RevId: 819427872
2025-10-14 15:35:59 -07:00
Google Team Member f9c09ef075 feat: Support returning all sessions when user_id is none in the request
resolves https://github.com/google/adk-python/issues/3154

PiperOrigin-RevId: 819417330
2025-10-14 15:10:41 -07:00
Shangjie Chen 141318f775 feat: Support returning all sessions when user_id is none in the request
resolves https://github.com/google/adk-python/issues/3154

PiperOrigin-RevId: 819401023
2025-10-14 14:30:47 -07:00
Google Team Member 85c95a8cbf feat: Add create_time and mime_type to ArtifactVersion
PiperOrigin-RevId: 819396924
2025-10-14 14:21:02 -07:00
Hangfei Lin cb6d583cad chore: Add RSVP link to ADK Community Call
This change adds a link to a Qualtrics form for RSVPing to the ADK Community Call in the README.

PiperOrigin-RevId: 819376219
2025-10-14 13:36:33 -07:00
Shangjie Chen 2c7a342593 feat: Add create_time and mime_type to ArtifactVersion
PiperOrigin-RevId: 819372593
2025-10-14 13:29:24 -07:00
Joseph Pagadora 9fbed0b15a fix: Overall eval status should be NOT_EVALUATED if no invocations were evaluated
PiperOrigin-RevId: 819322513
2025-10-14 11:36:33 -07:00
Xuan Yang bae21027d9 chore: Disable the scheduled execution for issue triage workflow
PiperOrigin-RevId: 819312327
2025-10-14 11:15:12 -07:00
George Weale 89344da813 chore: Update agent builder instructions and remove run command details
PiperOrigin-RevId: 819299339
2025-10-14 10:46:53 -07:00
Xiang (Sean) Zhou d22b8bf890 chore: Clarify how to use adk built-in tool in instruction
PiperOrigin-RevId: 818987709
2025-10-13 21:43:37 -07:00
George Weale dfb8638eae chore: fix the cleanup_unused_files tool in yaml agent to use the same directory as other tools
PiperOrigin-RevId: 818846060
2025-10-13 15:01:36 -07:00
George Weale 3c0b99a19e fix: rollback of add structured JSON logging with Cloud Trace correlation Close #1683
PiperOrigin-RevId: 818844025
2025-10-13 14:57:23 -07:00
George Weale d8548aabd2 feat: add structured JSON logging with Cloud Trace correlation Close #1683
- add a shared --structured_logs flag to adk web and adk api_server so users can opt into JSON-formatted output
- introduce CloudTraceJSONFormatter that emits structured entries and attaches current Cloud Trace/Span IDs when an OpenTelemetry context is active
- update CLI logging setup to clear duplicate stdout handlers when Cloud Logging is enabled and to reconfigure existing handlers (like from Uvicorn) so they also pick up the structured format and requested log level

With the flag disabled the CLIs keep their existing text logs; when enabled, the services now produce Cloud Logging–friendly JSON that can be correlated with distributed traces.

PiperOrigin-RevId: 818823818
2025-10-13 14:08:45 -07:00
Google Team Member df05ed6b3b feat: migrate invocation_context to callback_context
Update plugin manager and built-in plugins to prioritize CallbackContext. Keep InvocationContext access for legacy plugins with adapter. Change callback docs/tests to cover the new context.

PiperOrigin-RevId: 818822267
2025-10-13 14:05:44 -07:00
Google Team Member 2158b3c915 fix: correctly populate context_id in remote_a2a_agent library when constructing a2a request
PiperOrigin-RevId: 818813897
2025-10-13 13:45:54 -07:00
George Weale e2072af69f feat: migrate invocation_context to callback_context
Update plugin manager and built-in plugins to prioritize CallbackContext. Keep InvocationContext access for legacy plugins with adapter. Change callback docs/tests to cover the new context.

PiperOrigin-RevId: 818798087
2025-10-13 13:09:15 -07:00
Xiang (Sean) Zhou fa84bcb575 chore: Correct the callback signatures
PiperOrigin-RevId: 818781277
2025-10-13 12:30:37 -07:00
Shangjie Chen bb1ea74924 chore: Delegate the agent state reset logic to LoopAgent
This is so we don't need to worry about side effect of Loop in all agent type. Custom agent should do the same if there exists loop inside.

PiperOrigin-RevId: 818766305
2025-10-13 11:53:59 -07:00
Xiang (Sean) Zhou 214986ebeb chore: Adjust the instruction about default model
PiperOrigin-RevId: 818765464
2025-10-13 11:52:11 -07:00
Ankur Sharma 348e552ba6 chore: Remove deprecated run_evals from cli_eval.py
This change removes the `run_evals` function and its helper `_get_evaluator` from `cli_eval.py`, as they were marked as deprecated. Corresponding test mocks and patches in `test_fast_api.py` are also removed.

PiperOrigin-RevId: 818719422
2025-10-13 10:13:12 -07:00
Google Team Member e212ff558e feat: Add new methods in the artifact service interface
PiperOrigin-RevId: 818473733
2025-10-12 21:19:20 -07:00
Xuan Yang e63180cb62 feat: Add the support for returning struct_data.uri in DiscoveryEngineSearchTool
For https://github.com/google/adk-python/issues/3146

PiperOrigin-RevId: 818458080
2025-10-12 20:28:08 -07:00
Google Team Member 6da7274858 feat: Set default for bypass_multi_tools_limit to False for GoogleSearchTool and VertexAiSearchTool
PiperOrigin-RevId: 818053371
2025-10-11 09:57:36 -07:00
Xuan Yang b21d0a50d6 fix: Add more clear instruction to the doc updater agent about one PR for each recommended change
PiperOrigin-RevId: 817831087
2025-10-10 16:37:12 -07:00
Joe Fernandez 16b030b2b2 fix: Add a guideline to avoid content deletion
Directs agent to avoid deleting existing content

PiperOrigin-RevId: 817823999
2025-10-10 16:12:16 -07:00
Xinran (Sherry) Tang 59670d240e feat: Support resuming from a paused invocation starting from a sub-agent
PiperOrigin-RevId: 817766247
2025-10-10 13:24:02 -07:00
Google Team Member bddc70b5d0 fix: Better handling the A2A streaming tasks so calling Agent can tell whether it's in progress updates (thought) or the final response
PiperOrigin-RevId: 817682171
2025-10-10 09:46:54 -07:00
George Weale 85ed500871 fix: Add support for file URIs in LiteLLM content conversion to fix issue #3131
changed the LiteLLM content conversion so Part.file_data.file_uri (like the gs://…) becomes a file object with file_id, making sure GCS-backed files reach LiteLLM proxies instead of being dropped add unit tests covering both _get_content and _content_to_message_param paths for file URIs

PiperOrigin-RevId: 817658432
2025-10-10 08:39:17 -07:00
Ankur Sharma 998264a5b1 fix: Only exclude scores that are None
Scores with values 0 (or 0.0) were also getting excluded.

PiperOrigin-RevId: 817658059
2025-10-10 08:38:18 -07:00
Xuan Yang 9a6b8507f0 feat: Add bypass_multi_tools_limit option to GoogleSearchTool and VertexAiSearchTool
PiperOrigin-RevId: 817493869
2025-10-09 23:05:02 -07:00
Ankur Sharma 64646e0002 chore: Remove deprecated static methods from TrajectoryEvaluator
This change removes the `evaluate`, `_evaluate_row`, `are_tools_equal`, `_remove_tool_outputs`, `_report_failures`, and `_print_results` static methods from `TrajectoryEvaluator`, along with their corresponding unit tests. These methods were previously marked as deprecated.

PiperOrigin-RevId: 817477494
2025-10-09 22:02:24 -07:00
Hangfei Lin 81913c85f4 chore: Update README md with recent ADK features
This CL updates the "What's new" section to include Resumability, ReflectRetryToolPlugin, Context compaction, and Search tool support. It also moves "Agent Config" and "Tool Confirmation" from "What's new" to "Key Features".

PiperOrigin-RevId: 817469210
2025-10-09 21:23:37 -07:00
Xiang (Sean) Zhou 9e0b1fb62b fix: Create context cache only when prefix matches with previous request
PiperOrigin-RevId: 817468275
2025-10-09 21:19:28 -07:00
Hangfei Lin 731bb9078d chore: Announce the first ADK Community Call in the README
The added section provides details for the community call on Oct 15, 2025, including the agenda and links to join and add to calendars.

PiperOrigin-RevId: 817457276
2025-10-09 20:35:47 -07:00
Ankur Sharma ae139bb461 feat: ADK cli allows developers to create an eval set and add an eval case
Agent developers can now create an eval set and add eval cases through command line itself. Adding an eval case is limited only to specifying conversation scenarios.

Sample comamnds:
- Create an eval set:
adk eval_set create \
    contributing/samples/hello_world \
    set_01

- Add an eval case with scenario file
Content of scenarios.json file:
'{"scenarios": [{"starting_prompt": "hello", "conversation_plan": "world"}]}'

adk eval_set add_eval_case \
    contributing/samples/hello_world \
    set_01 \
    --scenarios scenarios.json

PiperOrigin-RevId: 817456117
2025-10-09 20:31:01 -07:00
Xinran (Sherry) Tang 9939e0b087 feat: Support resuming a parallel agent with multiple branches paused on tool confirmation requests
PiperOrigin-RevId: 817373403
2025-10-09 16:04:55 -07:00
Xiang (Sean) Zhou cc24d616f8 feat: Support ContentUnion as static instruction
PiperOrigin-RevId: 817278990
2025-10-09 11:52:24 -07:00
Wei Sun (Jack) 0aede9f1a1 docs: Update CHANGELOG with [847df16](https://github.com/google/adk-python/commit/847df1638cbf1686aa43e8e094121d4e23e40245)
PiperOrigin-RevId: 817267158
2025-10-09 11:24:48 -07:00
George Weale 847df1638c fix: handle App instances returned by agent_loader.load_agent
The `agent_loader.load_agent` method can now return an `App` object. This change unwraps the `App` to get its `root_agent` before passing it to the graph builder, makes sure a `BaseAgent` instance is always used

PiperOrigin-RevId: 817209601
2025-10-09 09:00:30 -07:00
Kacper Jawoszek 55aa6f669b feat(otel): set default_log_name for GCP logging exporter
Uses value of GCP_DEFAULT_LOG_NAME env var if it exists, defaults to literal adk-otel.

PiperOrigin-RevId: 817125337
2025-10-09 04:38:26 -07:00
Xuan Yang 9b8a4aad6f chore: Add an sample agent for the ReflectAndRetryToolPlugin
PiperOrigin-RevId: 817024977
2025-10-08 23:05:25 -07:00
Xiang (Sean) Zhou cac9fae829 chore: Don't label 'bot triaged' for PR
PiperOrigin-RevId: 816959715
2025-10-08 19:21:35 -07:00
Wei Sun (Jack) 24342e95f8 chore: Remove temp state deltas before appending an event
PiperOrigin-RevId: 816902208
2025-10-08 16:13:52 -07:00
Ankur Sharma cbe60c47aa feat: Adds data model to support UserSimulation
Details:
- Introduces a concept of `ConversationScenario` to represent a scenario that user simulator is supposed to follow.
- Introduces a `UserSimulator` interface, that one should implement. UserSimulator interface will be integrated with LocalEvalService in subsequent PRs.
PiperOrigin-RevId: 816883699
2025-10-08 15:23:57 -07:00
Xiang (Sean) Zhou 2efaa57575 chore: Don't label issue as bot triaged
PiperOrigin-RevId: 816873967
2025-10-08 14:58:49 -07:00
Xinran (Sherry) Tang 32f2ec3a78 feat: Set agent_state in invocation context right before yielding the checkpoint event
PiperOrigin-RevId: 816804179
2025-10-08 12:01:57 -07:00
Shangjie Chen 75179243b4 chore: Update human_tool_confirmation agent to use resumability feature
PiperOrigin-RevId: 816793131
2025-10-08 11:35:13 -07:00
Wei Sun (Jack) 03f051d3ed chore: Bumps version to v1.16.0 and updates CHANGELOG
PiperOrigin-RevId: 816788551
2025-10-08 11:26:58 -07:00
George Weale e858dc0799 chore: change how agent builder assistant instructions for model selection asking, to make it ask once for plan and one for model selection
PiperOrigin-RevId: 816788530
2025-10-08 11:22:54 -07:00
Google Team Member 0e3c0f78f5 feat: Make session_id optional in BaseArtifactService methods
PiperOrigin-RevId: 816782982
2025-10-08 11:08:41 -07:00
Xiang (Sean) Zhou f2bed14c4b chore: Adjust the LLM Request logging
1. function declarations is not necessary in the first tool
2. log the config

PiperOrigin-RevId: 816547534
2025-10-07 23:07:18 -07:00
Haoming Chen 30212669ff docs: Update BigQuery samples README
Add the new analyze_contribution tool and renumbering as the Github cannot display it correctly.

PiperOrigin-RevId: 816517893
2025-10-07 21:19:40 -07:00
Hangfei Lin 3f2b457efd fix: fix compaction logic
When there are multiple intervals and compactions, the original implementation only keep the last one. The right implementation is to keep as many compaction events/summary as the requested internals.

PiperOrigin-RevId: 816516662
2025-10-07 21:16:07 -07:00
Che Liu e55b8946d6 feat: Add ReflectRetryToolPlugin to reflect from errors and retry with different arguments when tool errors
This plugin intercepts tool failures, provides structured guidance to the LLM for reflection and correction, and retries the operation up to a configurable limit.

**Key Features:**

- **Concurrency Safe:** Uses locking to safely handle parallel tool
executions
- **Configurable Scope:** Tracks failures per-invocation (default) or globally
  using the `TrackingScope` enum.
- **Extensible Scoping:** The `_get_scope_key` method can be overridden to
  implement custom tracking logic (e.g., per-user or per-session).
- **Granular Tracking:** Failure counts are tracked per-tool within the
  defined scope. A success with one tool resets its counter without affecting
  others.
- **Custom Error Extraction:** Supports detecting errors in normal tool
responses
that
  don't throw exceptions, by overriding the `extract_error_from_result`
  method.

**Example:**
```python
from my_project.plugins import ReflectAndRetryToolPlugin, TrackingScope

# Example 1: (MOST COMMON USAGE):
# Track failures only within the current agent invocation (default).
error_handling_plugin = ReflectAndRetryToolPlugin(max_retries=3)

# Example 2:
# Track failures globally across all turns and users.
global_error_handling_plugin = ReflectAndRetryToolPlugin(max_retries=5,
scope=TrackingScope.GLOBAL)

# Example 3:
# Retry on failures but do not throw exceptions.
error_handling_plugin =
  ReflectAndRetryToolPlugin(max_retries=3,
  throw_exception_if_retry_exceeded=False)

# Example 4:
# Track failures in successful tool responses that contain errors.
class CustomRetryPlugin(ReflectAndRetryToolPlugin):
  async def extract_error_from_result(self, *, tool, tool_args,tool_context,
  result):
    # Detect error based on response content
    if result.get('status') == 'error':
        return result
    return None  # No error detected
error_handling_plugin = CustomRetryPlugin(max_retries=5)
```
PiperOrigin-RevId: 816456549
2025-10-07 17:56:54 -07:00
Douglas Reid 2b5acb98f5 feat(models): add support for gemma model via gemini api
Merge https://github.com/google/adk-python/pull/2857

Adds support for invoking Gemma models via the Gemini API endpoint. To support agentic function, callbacks are added which can extract and transform function calls and responses into user and model messages in the history.

This change is intended to allow developers to explore the use of Gemma models for agentic purposes without requiring local deployment of the models. This should ease the burden of experimentation and testing for developers.

A basic "hello world" style agent example is provided to demonstrate proper functioning of Gemma 3 models inside an Agent container, using the dice roll + prime check framework of similar examples for other models.

## Testing

### Testing Plan
- add and run integration and unit tests
- manual run of example `multi_tool_agent` from quickstart using new `Gemma` model
- manual run of `hello_world_gemma` agent

### Automated Test Results:
| Test Command | Results |
|----------------|---------|
| pytest ./tests/unittests | 4386 passed, 2849 warnings in 58.43s |
| pytest ./tests/unittests/models/test_google_llm.py | 100 passed, 4 warnings in 5.83s |
| pytest ./tests/integration/models/test_google_llm.py | 5 passed, 2 warnings in 3.73s |

### Manual Testing

Here is a log of `multi_tool_agent` run with locally-built wheel and using Gemma model.
```
❯ adk run multi_tool_agent
Log setup complete: /var/folders/bg/_133c0ds2kb7cn699cpmmh_h0061bp/T/agents_log/agent.20250904_152617.log
To access latest log: tail -F /var/folders/bg/_133c0ds2kb7cn699cpmmh_h0061bp/T/agents_log/agent.latest.log
/Users/<redacted>/venvs/adk-quickstart/lib/python3.11/site-packages/google/adk/cli/cli.py:143: UserWarning: [EXPERIMENTAL] InMemoryCredentialService: This feature is experimental and may change or be removed in future versions without notice. It may introduce breaking changes at any time.
  credential_service = InMemoryCredentialService()
/Users/<redacted>/venvs/adk-quickstart/lib/python3.11/site-packages/google/adk/auth/credential_service/in_memory_credential_service.py:33: UserWarning: [EXPERIMENTAL] BaseCredentialService: This feature is experimental and may change or be removed in future versions without notice. It may introduce breaking changes at any time.
  super().__init__()
Running agent weather_time_agent, type exit to exit.
[user]: what's the weather like today?
[weather_time_agent]: Which city are you asking about?

[user]: new york
[weather_time_agent]: OK. The weather in New York is sunny with a temperature of 25 degrees Celsius (77 degrees Fahrenheit).
```

And here is a snippet of a log generated with DEBUG level logging of the `hello_world_gemma` sample. It demonstrates how function calls are extracted and inserted based on Gemma model interactions:

```
...
2025-09-04 15:32:41,708 - DEBUG - google_llm.py:138 -
LLM Request:
-----------------------------------------------------------
System Instruction:
None
-----------------------------------------------------------
Contents:
{"parts":[{"text":"\n      You roll dice and answer questions about the outcome of the dice rolls.\n      You can roll dice of different sizes...\n"}],"role":"user"}
{"parts":[{"text":"Hi, introduce yourself."}],"role":"user"}
{"parts":[{"text":"Hello! I am data_processing_agent, a hello world agent that can roll many-sided dice and check if numbers are prime. I'm ready to assist you with those tasks. Let's begin!\n\n\n\n"}],"role":"model"}
{"parts":[{"text":"Roll a die with 100 sides and check if it is prime"}],"role":"user"}
{"parts":[{"text":"{\"args\":{\"sides\":100},\"name\":\"roll_die\"}"}],"role":"model"}
{"parts":[{"text":"Invoking tool `roll_die` produced: `{\"result\": 82}`."}],"role":"user"}
{"parts":[{"text":"{\"args\":{\"nums\":[82]},\"name\":\"check_prime\"}"}],"role":"model"}
{"parts":[{"text":"Invoking tool `check_prime` produced: `{\"result\": \"No prime numbers found.\"}`."}],"role":"user"}
{"parts":[{"text":"The die roll was 82, and it is not a prime number.\n\n\n\n"}],"role":"model"}
{"parts":[{"text":"Roll it again."}],"role":"user"}
-----------------------------------------------------------
Functions:

-----------------------------------------------------------

2025-09-04 15:32:41,708 - INFO - models.py:8165 - AFC is enabled with max remote calls: 10.
2025-09-04 15:32:42,693 - INFO - google_llm.py:180 - Response received from the model.
2025-09-04 15:32:42,693 - DEBUG - google_llm.py:181 -
LLM Response:
-----------------------------------------------------------
Text:
{"args":{"sides":100},"name":"roll_die"}
-----------------------------------------------------------
...
```
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2857 from douglas-reid:add-gemma-via-api e6d015f6a9ccbcf20ef7a7af8e4bbe1e9a5936b6
PiperOrigin-RevId: 816451001
2025-10-07 17:38:35 -07:00
Hangfei Lin 84f2f417f7 fix: Rollback compaction handling from _get_contents
The sorting may cause problems in complex cases so rolling it back. Will implement it with a non-sorting approach.

PiperOrigin-RevId: 816420710
2025-10-07 16:11:36 -07:00
Google Team Member 8110e41b36 fix: VertexSessionService with adding base_url override to base api override without removing initialized http_options
PiperOrigin-RevId: 816409410
2025-10-07 15:43:17 -07:00
Xuan Yang b0f0698ec2 chore: Add a sample agent to demonstrate that built-in google search tool and VertexAiSearchTool can be used together with other tools
PiperOrigin-RevId: 816396360
2025-10-07 15:08:53 -07:00
Xinran (Sherry) Tang db41f54e7b chore: When processing pending tool confirmation requests, only look at events in the same branch
PiperOrigin-RevId: 816387687
2025-10-07 14:48:19 -07:00
Shangjie Chen 636def3687 fix: Add AuthConfig json serialization in vertex ai session service
Resolves https://github.com/google/adk-python/issues/2035

PiperOrigin-RevId: 816387628
2025-10-07 14:47:28 -07:00
Xiang (Sean) Zhou 3f86760e0b chore: Remove unnecessary check tool type and tool attribute
tool in config.tools cann't be ToolDict and must have computer_use attr

PiperOrigin-RevId: 816368064
2025-10-07 14:01:53 -07:00
Yifan Wang 5ac446d947 chore: add invocation_id to AgentRunRequest for resuming long running functions
PiperOrigin-RevId: 816362937
2025-10-07 13:49:50 -07:00
Xuan Yang 2699ad7aff chore: fix the test_llm_agent_fields.py by adding a mock for google.auth.default
PiperOrigin-RevId: 816319357
2025-10-07 12:05:48 -07:00
Xuan Yang 4485379a04 ADK changes
PiperOrigin-RevId: 816288113
2025-10-07 10:59:19 -07:00
Xiang (Sean) Zhou 0989d64688 chore: Remove unnecessary check tool type and tool attribute
tool in config.tools cann't be ToolDict and must have computer_use attr

PiperOrigin-RevId: 816283438
2025-10-07 10:48:48 -07:00
Shangjie Chen 90d4c19c51 feat: Migrate vertex ai session service to use agent engine sdk
PiperOrigin-RevId: 816259798
2025-10-07 09:58:27 -07:00
Xiang (Sean) Zhou 3be9cd844c chore: Let tools to handle root directory resolvement and model only knows the project name and always use relative path
PiperOrigin-RevId: 816213558
2025-10-07 08:11:06 -07:00
Hangfei Lin 3f4bd67b49 fix: Make compactor optional in EventsCompactionConfig and add a default
If `EventsCompactionConfig` is provided without a `compactor`, a `SlidingWindowCompactor` is now automatically instantiated using the `root_agent`'s LLM. This simplifies configuration by providing a sensible default.

PiperOrigin-RevId: 816038579
2025-10-06 22:20:49 -07:00
Bo Yang 238472d083 fix: Updates the load_artifacts tool so that the model can reliability call it for follow up questions about the same artifact
PiperOrigin-RevId: 816025399
2025-10-06 21:34:51 -07:00
Hangfei Lin f1abdb1938 fix: Rename SlidingWindowCompactor to LlmEventSummarizer and refine its docstring
The class is now named `LlmEventSummarizer` to better reflect that its primary function is to use an LLM to summarize events. The docstring has been updated to clarify that this class is responsible *only* for the LLM-based summarization of a given set of events, while the logic for determining *when* and *which* events form the sliding window is handled by an external component, such as an ADK Runner.

PiperOrigin-RevId: 815976264
2025-10-06 18:54:20 -07:00
Hangfei Lin 68402bda49 fix: Set default response modality to AUDIO in run_session
Some native audio models require the modality to be set, so we default to AUDIO if not specified in `RunConfig`.

PiperOrigin-RevId: 815952039
2025-10-06 17:37:10 -07:00
Xiang (Sean) Zhou 90e1e3e10c chore: Add sample agent for testing oatuh2 client credentials grant type
PiperOrigin-RevId: 815863131
2025-10-06 13:34:09 -07:00
Haoming Chen 4bb089d386 feat: Add BigQuery analyze_contribution tool
This change introduces a new `analyze_contribution` function in `query_tool.py` which uses BigQuery ML's `CREATE MODEL` with `CONTRIBUTION_ANALYSIS` type and `ML.GET_INSIGHTS` to analyze the contribution of different dimensions to a given metric. The new function is also added to the `bigquery_toolset`.

PiperOrigin-RevId: 815849281
2025-10-06 12:59:09 -07:00
Xiang (Sean) Zhou 5c6cdcd197 feat: Support Oauth2 client credentials grant type
PiperOrigin-RevId: 815813477
2025-10-06 11:28:17 -07:00
George Weale 46d73be41a chore: Add more info to "Session not found" error message in ADK runners for differently named app and folder
PiperOrigin-RevId: 815795412
2025-10-06 10:48:28 -07:00
Hangfei Lin e0dd06ff04 feat: implementation of LLM context compaction
Provide a more efficient way to compact LLM context for better agentic performance.

PiperOrigin-RevId: 815785898
2025-10-06 10:28:46 -07:00
Xiang (Sean) Zhou ca6a4340f4 chore: Move adk knowledge agent out of adk agent builder folder
PiperOrigin-RevId: 815771308
2025-10-06 09:57:21 -07:00
George Weale 86de3ef7e3 chore: google.genai instead of `google.generativeai'
PiperOrigin-RevId: 815759570
2025-10-06 09:27:13 -07:00
Max Ind bd76b46ce2 feat(otel): Switch CloudTraceSpanExporter to telemetry.googleapis.com
PiperOrigin-RevId: 815675872
2025-10-06 05:14:32 -07:00
Xiang (Sean) Zhou 4b47a0a552 chore: Add instructions for callback signatures
PiperOrigin-RevId: 815549924
2025-10-05 21:47:53 -07:00
Xuan Yang 84c1faeeef chore: Introduce the remote A2A ADK Knowledge Agent to Agent Builder Assistant
PiperOrigin-RevId: 815543707
2025-10-05 21:21:19 -07:00
Xiang (Sean) Zhou c6dd444fc9 fix: Adapt to new computer use tool name in genai sdk 1.41.0
1.40.0 has some bug that caused some UT tests failures

PiperOrigin-RevId: 815098429
2025-10-04 08:53:13 -07:00
Google Team Member d1efc8461e feat: Migrate vertex_ai_session_service to use Agent Engine SDK
PiperOrigin-RevId: 814967790
2025-10-03 22:14:23 -07:00
Shangjie Chen 97b950b36b feat: Migrate vertex_ai_session_service to use Agent Engine SDK
PiperOrigin-RevId: 814948921
2025-10-03 21:00:15 -07:00
Google Team Member 960eda3d1f feat: Add dry_run functionality to BigQuery execute_sql tool
PiperOrigin-RevId: 814854520
2025-10-03 15:36:58 -07:00
Xiang (Sean) Zhou 0b84d3eea7 chore: Show relative path in response if root directory already set in session state
PiperOrigin-RevId: 814768273
2025-10-03 11:33:24 -07:00
Xiang (Sean) Zhou 611b604bdc chore: Emphasize not to ask for root_directory if it's set in the context
PiperOrigin-RevId: 814738676
2025-10-03 10:14:44 -07:00
Xiang (Sean) Zhou 33b2d495be chore: Emphasize "model" property can inherit from parent LlmAgent
PiperOrigin-RevId: 814715394
2025-10-03 09:06:33 -07:00
Max Ind 0162898707 ADK changes
PiperOrigin-RevId: 814614027
2025-10-03 02:56:51 -07:00
Xuan Yang 42db35111b chore: fix typo for GenerateContentConfig in Agent Builder Assistant
PiperOrigin-RevId: 814495803
2025-10-02 19:56:55 -07:00
George Weale dd0571ad09 chore: Clarify write_config_files usage for sub-agent YAML files
PiperOrigin-RevId: 814489632
2025-10-02 19:36:15 -07:00
George Weale a4ef7edcbb chore: add __init__.py prompt for tool imports
PiperOrigin-RevId: 814488943
2025-10-02 19:33:58 -07:00
Xiang (Sean) Zhou c5b976b306 chore: Create the context cache based on the token count of previous request
before this change, we estimate the token count of the contents to cache and use it to compare with the threshold user set. but that's not precise , so we use the actual prompt token count of previous llm request.

We won't create cache for the very initial request

PiperOrigin-RevId: 814484840
2025-10-02 19:22:00 -07:00
Xuan Yang 420df25f58 chore: add a remote A2A knowledge agent for Agent Builder Assistant
PiperOrigin-RevId: 814484204
2025-10-02 19:20:36 -07:00
Google Team Member a9b76b9061 ADK changes
PiperOrigin-RevId: 814417092
2025-10-02 15:49:48 -07:00
Google Team Member 65d6da081c ADK changes
PiperOrigin-RevId: 814413627
2025-10-02 15:49:35 -07:00
Shangjie Chen b170a84279 chore: Handle exception in preload_memory_tool to not fail the llm request
Resolves https://github.com/google/adk-python/issues/3069

PiperOrigin-RevId: 814391260
2025-10-02 14:41:27 -07:00
Wei Sun (Jack) 5b8d523a4b ADK changes
PiperOrigin-RevId: 814367778
2025-10-02 13:44:16 -07:00
Xuan Yang d3148dacc9 ADK changes
PiperOrigin-RevId: 814319961
2025-10-02 13:44:05 -07:00
George Weale 2e2d61b6fe fix: Set max_output_tokens for the agent builder
PiperOrigin-RevId: 814317909
2025-10-02 13:43:55 -07:00
Ankur Sharma 65554d6621 chore: Update AgentEvaluator to use EvalConfig
We updated the one of the public methods on AgentEvaluator to take in eval metric configurations using a more formal EvalConfig data model.

We also mark "criteria" field on the method as deprecated.

Updated some integration test cases.

PiperOrigin-RevId: 814314134
2025-10-02 13:43:44 -07:00
George Weale e68006386f fix: Fixes a bug that causes intermittent pydantic validation errors when uploading files
The root cause is an unsafe in-memory mutation. The `SaveFilesAsArtifactsPlugin` was saving a direct reference to the message part and then modifying the message list in-place. This created a race condition where downstream code could alter the original part *after* it had been saved as an artifact, leading to a corrupted state.
This CL saves a `copy.copy()` of the artifact, which create a snapshot of the data.
Also Changes the plugin to return a new `types.Content` object instead of modifying the original message in-place

PiperOrigin-RevId: 814308070
2025-10-02 13:43:34 -07:00
George Weale f667c7445e chore: deprecate global_instructions and make it a plugin instead
PiperOrigin-RevId: 814307563
2025-10-02 13:43:22 -07:00
Xiang (Sean) Zhou 29f18f4eea chore: Add a sample agent to test pydantic models as function tool argument
PiperOrigin-RevId: 814293450
2025-10-02 13:43:10 -07:00
Xiang (Sean) Zhou 571c802fba fix: Convert argument to pydantic model when tool declare to accept pydantic model as argument
PiperOrigin-RevId: 814273005
2025-10-02 13:43:00 -07:00
Xiang (Sean) Zhou c46308b7cf chore: Add session patch endpoint to api server for state update
This is allow user to update session state without running the agent. e.g. if I want to test some case when session has certain state on adk web.

PiperOrigin-RevId: 814252851
2025-10-02 13:42:49 -07:00
Hoonji Baek 822efe0065 feat: Adds adk web options for custom logo
Allows users to configure a custom text and logo for their ADK Web app using `--logo-text` and `--logo-image-url` flags.

PiperOrigin-RevId: 814016542
2025-10-02 13:42:38 -07:00
Shangjie Chen 55bc985821 chore: Fix vertexai import rule of memory service for google internal dependencies
PiperOrigin-RevId: 813941520
2025-10-02 13:42:23 -07:00
Google Team Member da62700d73 feat: Spanner ADK toolset supports customizable template SQL and parameterized SQL
PiperOrigin-RevId: 813909122
2025-10-01 14:15:01 -07:00
Google Team Member a5cf80b952 fix: Handling of A2ATaskStatusUpdateEvent when streaming in remote_a2a_agent
The proto has the Message object in the TaskStatus.

PiperOrigin-RevId: 813844289
2025-10-01 11:43:03 -07:00
Xuan Yang 29968d44ae chore: Remove get_working_directory_info from instruction template for agent builder assistant
PiperOrigin-RevId: 813495752
2025-09-30 17:29:33 -07:00
Yifan Wang ce2167861c chore: Adding builder endpoints, WIP
PiperOrigin-RevId: 813489379
2025-09-30 17:10:38 -07:00
Joseph Pagadora 8c73d29c75 feat: Add HallucinationsV1 evaluation metric
PiperOrigin-RevId: 813456369
2025-09-30 15:39:10 -07:00
Xuan Yang a239716930 ADK changes
PiperOrigin-RevId: 813321782
2025-09-30 10:18:30 -07:00
Google Team Member c51ea0b52e fix: VertexSessionService with adding base_url override to base api override without removing initialized http_options
PiperOrigin-RevId: 813319796
2025-09-30 10:14:58 -07:00
Liang Wu 8f3ca0359e fix: fix the instruction in workflow_triage example agent
PiperOrigin-RevId: 813305068
2025-09-30 09:37:54 -07:00
Joe Fernandez 745996212d fix: Added more agent instructions for doc content changes
Add directives for content updates and writing style

PiperOrigin-RevId: 813284600
2025-09-30 08:44:59 -07:00
Shangjie Chen 83fd045718 feat: Migrate VertexAiMemoryBankService to use Agent Engine SDK
PiperOrigin-RevId: 813104746
2025-09-29 23:14:50 -07:00
Shangjie Chen ce9c39f5a8 feat: Implement checkpoint and resume logic for LoopAgent
PiperOrigin-RevId: 813096880
2025-09-29 22:45:57 -07:00
Wei Sun (Jack) d5c46e4960 fix: Do not re-create App object when loader returns an App
PiperOrigin-RevId: 813083541
2025-09-29 22:02:19 -07:00
Xinran (Sherry) Tang fbf75761bb feat: Modify runner to support resuming an invocation (optionally with a function response)
PiperOrigin-RevId: 813008406
2025-09-29 17:35:18 -07:00
Xinran (Sherry) Tang f005414895 feat: Make resumable llm agents yield checkpoint events
PiperOrigin-RevId: 813001108
2025-09-29 17:08:58 -07:00
Ankur Sharma 609a2358eb chore: PrettyPrint the output of detailed results generated from adk eval cli command
PiperOrigin-RevId: 812912413
2025-09-29 13:09:31 -07:00
Xinran (Sherry) Tang 772658fd81 chore: Refactor runner run_async flow to extract out execution context setup logic
PiperOrigin-RevId: 812894540
2025-09-29 12:21:45 -07:00
Google Team Member 8e5f361264 fix: Update remote_a2a_agent to better handle streaming events and avoid duplicate responses
Currently, the A2A Task -> ADK event conversion is producing the same events on the last two update events (the last is a status update marking the task complete)

The change here based on A2AClientEvent(task, update):
 - if the update == None: handle the non-streaming task case and also streaming case for the initial task creation event
 - if the update = TaskStatusUpdateEvent AND a message is set: emit an event with that message
 - if a task status update AND no message is set: don't emit event (for example, the final status update)
 - if the update is ArtifactUpdateEvent and it's final artifact: emit the event

PiperOrigin-RevId: 812878869
2025-09-29 11:42:49 -07:00
Google Team Member b1ee013347 chore: Remove debug print from get_agent_graph
PiperOrigin-RevId: 812767234
2025-09-29 06:48:06 -07:00
Shangjie Chen 2f1040f296 feat: Implement checkpoint and resume logic for ParallelAgent
PiperOrigin-RevId: 812658378
2025-09-29 00:26:32 -07:00
Xiang (Sean) Zhou 943abec7c0 chore: Clarify the rule for getting tool name prefix in instruction
PiperOrigin-RevId: 812097390
2025-09-26 23:10:24 -07:00
Google Team Member 3f28e30c6d feat: add citation_metadata to LlmResponse
PiperOrigin-RevId: 811997009
2025-09-26 16:31:01 -07:00
Shangjie Chen 7b707cebea chore: Simplfiy the parallel agent py version handling logic
PiperOrigin-RevId: 811992425
2025-09-26 16:15:51 -07:00
Ankur Sharma c984b9e552 feat: Add Rubric based tool use metric
The PR does two main things:
1) Introduces a new rubric based tool use metric
2) Given that we now have two rubric based metric, we refactor and create a new RubricBasedEvaluator interface.

PiperOrigin-RevId: 811983514
2025-09-26 15:47:42 -07:00
Xuan Yang a959653cf3 chore: bump version to 1.15.1 with a patch for Agent Engine
PiperOrigin-RevId: 811981894
2025-09-26 15:42:12 -07:00
Shangjie Chen 1ee01cc05a feat: Implement checkpoint and resume logic for SequentialAgent
PiperOrigin-RevId: 811977004
2025-09-26 15:26:42 -07:00
Xinran (Sherry) Tang 28d44a365a test: Make testing_utils.InMemoryRunner support ADK App and add utils for extracting event contents for testing resumability
PiperOrigin-RevId: 811933527
2025-09-26 13:22:11 -07:00
Sasha Sobran e172811bc7 fix: unbreak client closed errors when using vertexai session service
PiperOrigin-RevId: 811911528
2025-09-26 12:16:37 -07:00
Xuan Yang da6f1d3653 chore: Release ADK 1.15.0
PiperOrigin-RevId: 811655912
2025-09-25 22:17:23 -07:00
Shangjie Chen 2c752934a8 feat: Skip running a workflow agent if it has no sub-agents
PiperOrigin-RevId: 811528166
2025-09-25 15:39:38 -07:00
Xinran (Sherry) Tang b2b80e7fa0 feat: Pause invocations on long running function calls for resumable apps
PiperOrigin-RevId: 811518771
2025-09-25 15:11:11 -07:00
Xuan Yang dd1ffad394 chore: Update google-genai version constraint
Fixes https://github.com/google/adk-python/issues/2968

PiperOrigin-RevId: 811475972
2025-09-25 13:21:45 -07:00
Shangjie Chen 8b081751ed feat: Add core checkpointing primitive for base agent
PiperOrigin-RevId: 811458903
2025-09-25 12:35:36 -07:00
Xinran (Sherry) Tang b5a65fb4f4 chore: Remove the too-detailed edge case descriptions for resumability
PiperOrigin-RevId: 811432962
2025-09-25 11:32:38 -07:00
Shangjie Chen 839d2e43bb feat: Define an AgentState to be used for resuming agent invocation
PiperOrigin-RevId: 811414736
2025-09-25 10:49:49 -07:00
Xiang (Sean) Zhou 1589fcdd86 chore: Replace github HTTP URIs with GCS HTTP URIs in static non-text content sample agent
mainly because http://github.com/robots.txt disallows `/*/raw/` path. using GCS HTTP URIs is more reliable with Gemini model.

PiperOrigin-RevId: 811409688
2025-09-25 10:38:04 -07:00
Max Ind e7528aebd4 feat(otel): adjust telemetry to follow OTLP 1.37 GenAI semconv
Changes include:
- Implementing missing attributes. e.g. 'gen_ai.agent.name'
- Specifying reasons for not filling out some conditionally required attributes. e.g. 'gen_ai.data_source.id'
- Specifying reasons for not including certain attributes which are specified in current semconv. e.g. inference attributes on agent spans

PiperOrigin-RevId: 811379706
2025-09-25 09:25:15 -07:00
Xinran (Sherry) Tang cbb6e4945a feat: Add a app level config for resumable applications
PiperOrigin-RevId: 811272046
2025-09-25 03:14:34 -07:00
Xiang (Sean) Zhou c6b6b6f3c6 chore: Add log-level parameter to cache analysis experiments
this is to allow turning on debug log for debugging if some unexpected behavior observed during running cache analysis experiments.

PiperOrigin-RevId: 811189954
2025-09-24 22:44:41 -07:00
Google Team Member c8c6cd70a4 feat: Introduce ExtendedOAuth2 scheme that auto-populates auth/token URLs
Use auto-discovered auth_endpoint and token_endpoint in CredentialManager.

PiperOrigin-RevId: 811183929
2025-09-24 22:21:07 -07:00
Xiang (Sean) Zhou f159bd9c87 fix: Use str() to calculate fingerprint instead of json.dumps
This is to avoid serialization issue for some fields that are not json serializable.
meanwhile restructure the debug logs in context cache manager for better debugging potential issues.

PiperOrigin-RevId: 811182492
2025-09-24 22:14:40 -07:00
Ankur Sharma d48679582d feat: Populate AppDetails to each Invocation
AppDetails require two pieces of information:
1) Instructions
2) Tools

Both these pieces of information are gathered using the llm_request that was passed to the model. This approach, slightly invasive, ensures that we capture the "exact" instructions and tools that were given to the model.

PiperOrigin-RevId: 811180648
2025-09-24 22:06:56 -07:00
Google Team Member 2a2da0fe03 feat: Introduce OAuth2DiscoveryManager to fetch metadata needed for OAuth
This is the first step to bring ADK to compliance with MCP Authorization Spec.

PiperOrigin-RevId: 811177152
2025-09-24 21:53:48 -07:00
Ankur Sharma 5a485b01cd feat: Adds Rubric based final response evaluator
The evaluator uses a set of rubrics to assess the quality of the agent's final response.

PiperOrigin-RevId: 811154498
2025-09-24 20:30:51 -07:00
Ankur Sharma 01923a9227 feat: Data model for storing App Details and data model for steps
Details:
1. Data model for storing App Details (the agentic system)
As we move towards LLM as Judge metrics, we see that some of these metrics need information about the Agentic system that was used for inferencing. We add a data model to capture that.

2. Data model for Steps
We refine the concept of intermediate data. Previously it stored data in the form of a multiple lists, thereby losing out on the chronological information. This information is needed for some of the metrics. So we refine the concept of intermediate data as series of logical steps that an Agent Take.

PiperOrigin-RevId: 811122784
2025-09-24 18:41:38 -07:00
Xiang (Sean) Zhou 08f3b48305 chore: Add sample agent to test non-text content in static instruction
PiperOrigin-RevId: 810999310
2025-09-24 13:03:11 -07:00
Xuan Yang 6db096a3f4 chore: remove unsupported 'type': 'unknown' in test_common.py for fastapi 0.117.1
PiperOrigin-RevId: 810673476
2025-09-23 19:44:49 -07:00
Xiang (Sean) Zhou 47bd34ac28 chore: Fix the type annotation
PiperOrigin-RevId: 810611299
2025-09-23 15:50:19 -07:00
Xiang (Sean) Zhou ae5592e242 chore: Add tests for instruction provider and merge test_static_instructions.py to test_intructions.py
PiperOrigin-RevId: 810610507
2025-09-23 15:47:46 -07:00
Xiang (Sean) Zhou 61213ce4d4 feat: Support non-text content in static instruction
move them to user contents and reference them from instruction

PiperOrigin-RevId: 810587466
2025-09-23 15:36:15 -07:00
Xuan Yang e86ca5762a chore: remove internal TODO comment
PiperOrigin-RevId: 810583734
2025-09-23 15:36:06 -07:00
Google Team Member cbb609233b chore: Sample Spanner RAG agent that wraps search_tool
Also modified README to add instructions on when to use which tool.

PiperOrigin-RevId: 810563458
2025-09-23 15:35:57 -07:00
George Weale 657369cffe fix: Adds plugin to save artifacts for issue #2176
PiperOrigin-RevId: 810522939
2025-09-23 15:35:48 -07:00
Xiang (Sean) Zhou c944a12e31 chore: Remove query schema mode, as it doesn't perform well as embedded schema mode
PiperOrigin-RevId: 810517055
2025-09-23 15:35:40 -07:00
Xiang (Sean) Zhou 26990c2622 chore: Add sample agent to test static instruction
PiperOrigin-RevId: 810516925
2025-09-23 15:35:31 -07:00
Xiang (Sean) Zhou f2ce990867 chore: Add experimental annotation to GeminiContextCacheManager
PiperOrigin-RevId: 810503537
2025-09-23 15:35:22 -07:00
shsha4 86dea5b53a fix(mcp): Initialize tool_name_prefix in MCPToolse
Merge https://github.com/google/adk-python/pull/2823

Description
  This change introduces a tool_name_prefix attribute to McpToolset and McpToolsetConfig. This allows for adding a prefix to the
  names of all tools within the toolset, which can help avoid naming collisions and provide better organization.

  The implementation involves updating the McpToolset's __init__ and from_config methods to handle the new tool_name_prefix and
  adding the corresponding field to McpToolsetConfig.

  Testing Plan
  A new unit test file has been added to ensure the functionality works as expected.

   - `tests/unittests/tools/test_mcp_toolset.py`:
     - The test_mcp_toolset_with_prefix test case verifies that the tool_name_prefix is correctly applied to the tool names
       retrieved from the toolset.
     - All tests were run via pytest and passed.

  Related Issue
   - Closes #2814

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2823 from shsha4:fix/issue-2814 e8e5b0d6d5f406d3875faf2229a96701725b7a5e
PiperOrigin-RevId: 810500616
2025-09-23 15:35:12 -07:00
Xiang (Sean) Zhou 6ca2aee829 ADK changes
PiperOrigin-RevId: 810492858
2025-09-23 15:35:02 -07:00
Xuan Yang 374522197f ADK changes
PiperOrigin-RevId: 810223422
2025-09-23 15:34:53 -07:00
Google Team Member aef1ee97a5 fix: make a copy of the columns instead of modifying it in place
This avoid unintentional modifications, especially in the case of a wrapped tool.

PiperOrigin-RevId: 810175539
2025-09-23 15:34:43 -07:00
Xiang (Sean) Zhou 38bbde6d56 chore: Annotate CachePerformanceAnalyzer as experimental
PiperOrigin-RevId: 809434619
2025-09-23 15:34:34 -07:00
TanejaAnkisetty 78fd4803d5 chore: Set role to user if new_message doesn't have role in Runner.run_async()
Merge https://github.com/google/adk-python/pull/2458

**Summary**
Verifies that user-provided messages are always passed to the LLM as 'user' role, regardless of whether the role is explicitly set in types.Content. Before the current fix, if the LlmRequest from the user doesn't have the 'user' role, but has the user content, then the text is being replaced with the standard text - "Handle the requests as specified in the System Instruction." and the content from the user is completely ignored and not passed into the LLM.

**Code to replicate the problem**

```
from google.adk.agents import LlmAgent
from google.adk.sessions import InMemorySessionService
from google.adk.runners import Runner
from google.genai.types import Content, Part
from google.adk.models.lite_llm import LiteLlm
from google.adk.models import LlmRequest
from google.genai import types
from pydantic import Field

import litellm
litellm._turn_on_debug()

import warnings
warnings.filterwarnings("ignore", category=UserWarning, message=".*InMemoryCredentialService.*")

import os
from dotenv import load_dotenv

# Load environment variables from the agent directory's .env file
load_dotenv()

OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")

# Define agent with output_key
root_agent = LlmAgent(
    name="name_of_agent",
    model=LiteLlm(model="azure/gpt-4o-mini"),
    instruction="You are a customer agent to help the users with their concerns."
)

# --- Setup Runner and Session ---
app_name, user_id, session_id = "state_app", "user1", "session1"

session_service = InMemorySessionService()

runner = Runner(
    agent=root_agent,
    app_name=app_name,
    session_service=session_service
)

print(f"Runner created for agent '{runner.agent.name}'.")

session = await session_service.create_session(
    app_name=app_name,
    user_id=user_id,
    session_id=session_id
)

# --- Run the Agent ---

async def call_agent_async(query: str, runner, user_id, session_id):

    user_message = Content(parts=[Part(text=query)])

    async for event in runner.run_async(
        user_id=user_id,
        session_id=session_id,
        new_message=user_message
    ):
        print("event")
        print(f"  [Event]\n  Author: {event.author}\n  Type: {type(event).__name__}",
        f"\n  Final: {event.is_final_response()}\n  Content: {event.content}")

    return event

event = await call_agent_async("What is the capital of India.",runner=runner,user_id=user_id,session_id=session_id)
```
**Before the fix (current adk-python code output)**
```
00:29:24 - LiteLLM:DEBUG: utils.py:348 -

00:29:24 - LiteLLM:DEBUG: utils.py:348 - Request to litellm:
00:29:24 - LiteLLM:DEBUG: utils.py:348 - litellm.acompletion(model='azure/gpt-4o-mini', messages=[{'role': 'developer', 'content': 'You are a customer agent to help the users with their concerns.\n\nYou are an agent. Your internal name is "name_of_agent".'}, {'role': 'user', 'content': 'Handle the requests as specified in the System Instruction.'}], tools=None, response_format=None)
```

**After the fix (after resolving the fix)**
```
00:28:46 - LiteLLM:DEBUG: utils.py:349 -

00:28:46 - LiteLLM:DEBUG: utils.py:349 - Request to litellm:
00:28:46 - LiteLLM:DEBUG: utils.py:349 - litellm.acompletion(model='azure/gpt-4o-mini', messages=[{'role': 'developer', 'content': 'You are a customer agent to help the users with their concerns.\n\nYou are an agent. Your internal name is "name_of_agent".'}, {'role': 'user', 'content': 'What is the capital of India.'}], tools=None, response_format=None)
```

**Testing**
Following unit test is created to test the applied changes and added in the location as suggested in the guidelines.
adk-python\tests\unittests\models\test_base_llm.py

```
import pytest
from google.genai import types
from google.adk.models.llm_request import LlmRequest
from google.adk.models.lite_llm import _get_completion_inputs

@pytest.mark.parametrize("content_kwargs", [
    # Case 1: Explicit role provided
    {"role": "user", "parts": [types.Part(text="This is an input text from user.")]},
    # Case 2: Role omitted, should still be treated as 'user'
    {"parts": [types.Part(text="This is an input text from user.")]}
])
def test_user_content_role_defaults_to_user(content_kwargs):
    """
    Verifies that user-provided messages are always passed to the LLM as 'user' role,
    regardless of whether the role is explicitly set in types.Content.

    The helper `_get_completion_inputs` should give normalize messages so that
    explicit 'user' and implicit (missing role) are equivalent.
    """
    llm_request = LlmRequest(
        contents=[types.Content(**content_kwargs)],
        config=types.GenerateContentConfig()
    )

    messages, _, _, _ = _get_completion_inputs(llm_request)

    assert all(
        msg.get("role") == "user" for msg in messages
    ), f"Expected role 'user' but got {messages}"
    assert any(
        "This is an input text from user." == (msg.get("content") or "")
        for msg in messages
    ), f"Expected the user text to be preserved, but got {messages}"
```

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2458 from TanejaAnkisetty:bug/agent-user-content 381b01418d249b9e6bd91ebb518ff25339a8e47b
PiperOrigin-RevId: 809281620
2025-09-23 15:34:21 -07:00
Google Team Member 632bf8b0bc fix: Filter out thought parts when saving agent output to state
PiperOrigin-RevId: 809270320
2025-09-19 18:58:59 -07:00
Wei Sun (Jack) 6e834d3fac feat(conformance): Skips recording for inner runner of AgentTool in conformance tests
PiperOrigin-RevId: 809252704
2025-09-19 17:36:18 -07:00
Xiang (Sean) Zhou 9be9cc2fee feat: Support static instructions
Static instructions:
Always added to system instructions for context caching

Dynamic instructions:
Added to system instructions when no static instruction exists (for backward compatibility), OR inserted before last batch of continuous user content when static instructions exist

PiperOrigin-RevId: 809170679
2025-09-19 13:46:36 -07:00
Xiang (Sean) Zhou f4e1fd962e chore: Add sample agent for content cache and basic profiling
PiperOrigin-RevId: 809166922
2025-09-19 13:37:57 -07:00
Xiang (Sean) Zhou c66245a3b8 feat: support context caching
1. add a context cache config in app level which will apply to all agents in the app
2. pass on cache config through invocation context to llm_reqeust
3. store cache metadata in llm_response
4. lookup old cache metadata from latest event for reusing old cache
5. create new cache if old cache cannot be reused

PiperOrigin-RevId: 809158578
2025-09-19 13:17:02 -07:00
Xinran (Sherry) Tang 13a95c463d feat: Add get_events util function in invocation_context
PiperOrigin-RevId: 809111315
2025-09-19 11:21:35 -07:00
Kacper Jawoszek f157b2ee4c feat(otel): support standard OTel env variables for exporter endpoints
ADK web server will automatically setup OTel providers with exporters if any of the .*_ENDPOINT variables from https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/ is set.

PiperOrigin-RevId: 809079453
2025-09-19 09:59:58 -07:00
Bastien Jacot-Guillarmod ccd0e12b42 chore: Internal change
PiperOrigin-RevId: 809077633
2025-09-19 09:55:17 -07:00
Kacper Jawoszek 3b80337faf feat(otel): temporarily disable Cloud Monitoring integration in --otel_to_cloud
Currently there is chance for Cloud Monitoring-related errors in logs during shutdown. Let's disable metrics part until it is fixed.

PiperOrigin-RevId: 808930635
2025-09-19 01:28:15 -07:00
Xuan Yang d4eaa06041 chore: update ADK release analyzer agent to use the compare link instead of commit link
PiperOrigin-RevId: 808900352
2025-09-18 23:44:12 -07:00
Xuan Yang 4d39563ea4 chore: add yaml files to the ADK Vertex AI Search datastore
PiperOrigin-RevId: 808895175
2025-09-18 23:27:34 -07:00
Wei Sun (Jack) 006a406f5b chore: Allow outputting non-acsii without escape and excludes fields in the dumped yaml files in the yaml_utils.py
Also excludes `_adk_recordings_config` for `adk conformance create` command.

PiperOrigin-RevId: 808865049
2025-09-18 21:24:14 -07:00
Wei Sun (Jack) f39df4155e feat(conformance): Supports content and state_delta in TestCase.user_messages and initial_state for session creation
PiperOrigin-RevId: 808827170
2025-09-18 18:55:38 -07:00
Hangfei Lin 1a91bb2a59 chore: Update comments in Compaction to clarify timestamp-based ranges
The docstrings for `compaction_range` and `compacted_content` are updated to reflect that compaction is based on timestamp ranges rather than sequence IDs, and to use consistent terminology ("compacted" instead of "summarized").

PiperOrigin-RevId: 808770610
2025-09-18 15:51:40 -07:00
Wei Sun (Jack) 9c2b7091ee refactor(comformance): Improves field comparison logic in replay plugin with nested exclude dict from pydantic v2
Also use `ReplayConfigError` to replace `ValueError`s

PiperOrigin-RevId: 808750606
2025-09-18 15:01:19 -07:00
Nikhil Purwant 21c26f92d4 chore: Added ADK Authentication End2End Samples
Merge https://github.com/google/adk-python/pull/2960

1. All in one authentication sample (has an IDP, Agent and the application) under `contributing/samples/authn-adk-all-in-one/`
2. Documented for all the steps.
3. OAuth 2.0 Authorization Code Grant type used by the agent.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2960 from nikhilpurwant:main dfcc821602d265c4ae7cc42eb1f5739beaad6f87
PiperOrigin-RevId: 808672120
2025-09-18 11:44:21 -07:00
guillaume blaquiere 25958242db feat: add endpoint to generate memory from session
Merge https://github.com/google/adk-python/pull/2900

In relation with #2416

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2900 from guillaumeblaquiere:add-session-to-memory 0507de43021c62f9223167dca8f53b536227ad04
PiperOrigin-RevId: 808658162
2025-09-18 11:13:21 -07:00
Kel Markert 6b49391546 feat: Add Google Maps Grounding Tool to ADK
This add `GoogleMapsGroundingTool`, a built-in tool for Gemini 2 models to ground query results with Google Maps. This tool operates internally within the model and is only available when using the VertexAI Gemini API.

PiperOrigin-RevId: 808650501
2025-09-18 10:54:27 -07:00
Xuan Yang 8a92fd18b6 fix: ignore empty function chunk in LiteLlm streaming response
Fixes https://github.com/google/adk-python/issues/1532

PiperOrigin-RevId: 808636127
2025-09-18 10:18:53 -07:00
Hangfei Lin c37bd2742c feat: Introduce LLM context compaction interface
Provide a more efficient way to compact LLM context for better agentic performance.

* `app`: the top level abstraction for an ADK application. It contains an root agent, and plugins.
* `content_strategy`: the abstraction for selecting the contents for LLM request.
* `compaction_strategy`: the abstraction for compacting the events.
* Added `sequence_id` and `summary_range` in event class.

PiperOrigin-RevId: 808634224
2025-09-18 10:14:12 -07:00
Wei Sun (Jack) e86647d446 feat(conformance): Implements adk conformance test cli with replay mode
PiperOrigin-RevId: 808633566
2025-09-18 10:12:43 -07:00
Afonso Menegola c9ea80af28 fix: Prevent escaping of Latin characters in LLM response
Merge https://github.com/google/adk-python/pull/2937

**Closes #2936**

This Pull Request addresses the issue where `LlmAgent` outputs, when configured with `output_schema` and `tools`, were presenting escaped Latin characters (e.g., `\xf3` for `ó`) in the final response. This behavior occurred because `json.dumps` was being called with `ensure_ascii=True` (its default), which is not ideal for human-readable output, especially when dealing with non-ASCII characters common in many languages like Portuguese.

**Changes Proposed:**

* Modified the `_OutputSchemaRequestProcessor` in `src/google/adk/flows/llm_flows/_output_schema_processor.py` to explicitly set `ensure_ascii=False` when calling `json.dumps` for the `set_model_response` tool's output.

**Impact:**

This change ensures that all non-ASCII characters in the structured model response are preserved in their natural form, improving the readability and user experience of agent outputs, particularly for users interacting in languages with accented characters or other special symbols.

**Testing:**

The fix was verified locally by running an `LlmAgent` with an `output_schema` and confirming that responses containing Latin characters (e.g., "ação", "caminhão", "ícone") are now correctly displayed without escaping.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2937 from amenegola:fix/issue-2936-escape-chars 6cac00f97aa4cd8d8ccaa97ec5fffc74f57995dc
PiperOrigin-RevId: 808622892
2025-09-18 09:48:03 -07:00
Xiang (Sean) Zhou 86ee6e3fa3 fix: Close runners after running eval
this fixes https://github.com/google/adk-python/issues/2196

PiperOrigin-RevId: 808618368
2025-09-18 09:36:56 -07:00
Wei Sun (Jack) bf4ff31009 feat(conformance): add CLI (adk conformance create) for generating conformance tests from spec.yaml file
- Add conformance command group with create subcommand
- Implement category/name/spec.yaml with generated-*.yaml files
- Support executing agents with queries and recording sessions
- Create test cases with recorded llm interactions and tool calls/results

Expected folder structure:

```

conformance_repo/
├── agents/                            # Agent definitions - contains all config-based agents shared by test cases.
│   ├── single_basic/
│   ├── multi_basic/
│   └── single_tool_builtin/
│
└── tests/                             # Test cases
    ├── core/                          # Test category
    │   ├── desc_001/                  # Individual test case
    │   │   ├── spec.yaml             # Human-written specification
    │   │   ├── generated-session.yaml
    │   │   ├── generated-recordings.yaml
    │   │   └── ...                   # Potential future generated files
    │   ├── f_001/
    │   │   ├── spec.yaml
    │   │   ├── generated-session.yaml
    │   │   ├── generated-recordings.yaml
    │   │   └── ...

```

Help text:

```
-> % adk conformance create --help
Usage: adk conformance create [OPTIONS] [PATHS]...

  Generate ADK conformance test YAML files from TestCaseInput specifications.

  NOTE: this is work in progress.

  This command reads TestCaseInput specifications from input.yaml files, executes the specified test cases against agents, and generates conformance test files with recorded agent interactions as
  test.yaml files.

  Expected directory structure: category/name/input.yaml (TestCaseInput) -> category/name/test.yaml (TestCase)

  PATHS: One or more directories containing test case specifications. If no paths are provided, defaults to 'tests/' directory.

  Examples:

  Use default directory: adk conformance create

  Custom directories: adk conformance create tests/core tests/tools

Options:
  --help  Show this message and exit.
```
PiperOrigin-RevId: 808609547
2025-09-18 09:14:05 -07:00
Hangfei Lin 4cb07ba05e chore: Update plugins in hello_world_app
Corrected `CountInvocationPlugin` to be a class reference and added `ContextFilterPlugin` to limit the number of tool invocations kept in the context to 3.

PiperOrigin-RevId: 808591608
2025-09-18 08:26:42 -07:00
Kacper Jawoszek cee365a13d feat(otel): Add GenAI Instrumentation if --otel_to_cloud is enabled
PiperOrigin-RevId: 808460137
2025-09-18 01:33:13 -07:00
Wei Sun (Jack) 712da1bd36 feat(conformance): Integrates RecordingsPlugin into AdkWebServer to record Llm interactions and tool calls
When start the server with `--extra_plugins=google.adk.cli.plugins.recordings_plugin.RecordingsPlugin`, it will trigger recording with expected state in session.

PiperOrigin-RevId: 808432022
2025-09-18 00:05:06 -07:00
Xiang (Sean) Zhou 99405d6a8a chore: Fix the starting folder for finding ADK source
PiperOrigin-RevId: 808371099
2025-09-17 20:20:58 -07:00
Hangfei Lin a06bf278cb feat: Adding the ContextFilterPlugin
This commit introduces a new ContextFilterPlugin which allows for filtering the LlmRequest contents before they are sent to the LLM. This helps in managing and potentially reducing the size of the LLM context.

The plugin provides two primary filtering mechanisms:

num_invocations_to_keep: Keeps only the specified number of the most recent user-model invocations. An invocation is defined as one or more user messages followed by a model response.
custom_filter: Allows for a user-defined callable to be applied to the contents for more flexible filtering.
Unit tests have been added to cover the different filtering scenarios, including:

Filtering by the last N invocations.
Filtering using a custom function.
Combining both filtering methods.
Handling cases with multiple user turns in a single invocation.
Ensuring no filtering occurs when options are not provided.
Gracefully handling exceptions from custom filter functions."

For example, when num_of_innovacations=2:
-----------------------------------------------------------
Contents:
{"parts":[{"text":"9"}],"role":"user"}
{"parts":[{"text":"I am sorry, I cannot fulfill this request. I need more information on what you would like me to do. I can roll a die or check prime numbers.\n"}],"role":"model"}
{"parts":[{"text":"1"}],"role":"user"}
{"parts":[{"text":"I am sorry, I cannot fulfill this request. I need more information on what you would like me to do. I can roll a die or check prime numbers.\n"}],"role":"model"}
{"parts":[{"text":"10"}],"role":"user"}
-----------------------------------------------------------
PiperOrigin-RevId: 808355316
2025-09-17 19:28:56 -07:00
Google Team Member 10cf377494 feat: Make the bigquery sample agent run with ADC out-of-the-box
Right now the bigquery sample agent is configured to run with OAuth, which requires some set up. This change makes it more readily usable, both locally and in AgentEngine, as Application Default Credentials (ADC) is easier to set up, and often local and AgentEngine environment already have it set up.

PiperOrigin-RevId: 808315879
2025-09-17 16:52:49 -07:00
Wei Sun (Jack) 3bd2f29f3a feat(conformance): Adds a replay plugin to replay the previously recorded llm/tool recordings for conformance tests
PiperOrigin-RevId: 807979314
2025-09-16 21:54:25 -07:00
Xiang (Sean) Zhou 14f118899d chore: Add example agent to get log probabilitis
see https://github.com/google/adk-python/issues/2764

PiperOrigin-RevId: 807972596
2025-09-16 21:23:21 -07:00
Wei Sun (Jack) c0554e4b13 feat(conformance): add an ADK plugin to record Llm request/response and tool call/result to recordings.yaml file
Also moves the `Recordings` pydantic models into this plugins/ package.

Key features:
- Records LLM requests/responses and tool calls/results to YAML files in `generated-recordings.yaml`.
- Use session state to determine where to read and output recordings.

PiperOrigin-RevId: 807969100
2025-09-16 21:10:09 -07:00
Google Team Member 6bd33e1be3 fix: Retain the consumers and transport registry when recreating the ClientFactory in remote_a2a_agent.py
PiperOrigin-RevId: 807762203
2025-09-16 10:58:46 -07:00
Xiang (Sean) Zhou f7bd3c111c feat: Expose log probs of candidates in LlmResponse
fixes https://github.com/google/adk-python/issues/2764

PiperOrigin-RevId: 807516910
2025-09-15 21:36:15 -07:00
Wei Sun (Jack) 1ce043a278 chore: Fixes BasePlugin#after_run_callback return type hint
`Optional[None]` is `Union[None, None]`, which is essentially None.

PiperOrigin-RevId: 807515970
2025-09-15 21:33:05 -07:00
Xuan Yang bd21847295 chore: add a step to load adk-bot SSH Private Key for the release analysis workflow
PiperOrigin-RevId: 807479079
2025-09-15 19:20:36 -07:00
Kacper Jawoszek 1ae0b82f56 feat(otel): add --otel_to_cloud experimental support
Cloud Trace, Cloud Monitoring and Cloud Logging integrations are set up via OTel if otel_to_cloud CLI param/fast_api arg is provided.

This is similar to current Cloud Trace integration via trace_to_cloud, just extended to Monitoring and Logging as well.

PiperOrigin-RevId: 807385680
2025-09-15 14:32:22 -07:00
Xiang (Sean) Zhou d6d4b144e9 chore: Update instructions not to ask for root folder if user doesn't intent to create or implement an agent
PiperOrigin-RevId: 807372074
2025-09-15 13:59:08 -07:00
Xinran (Sherry) Tang 4dbec15d26 test: Add unittest suites for testing HITL confirmation flow on runner level
PiperOrigin-RevId: 807327997
2025-09-15 12:00:49 -07:00
Wei Sun (Jack) 402f3626b3 feat(conformance): Replaces invocation_id with user_message_index in the Recording
`invocation_id` is per-request, so we just need user_message_index to help locate where to start replay.

PiperOrigin-RevId: 807300016
2025-09-15 10:49:13 -07:00
Google Team Member 6158075a65 fix: introduces a raw_mcp_tool method in McpTool to provide direct access to the underlying MCP tool
PiperOrigin-RevId: 807299777
2025-09-15 10:48:13 -07:00
Google Team Member b1312680f4 feat(otel): add --otel_to_cloud experimental support
Cloud Trace, Cloud Monitoring and Cloud Logging integrations are set up via OTel if otel_to_cloud CLI param/fast_api arg is provided.

This is similar to current Cloud Trace integration via trace_to_cloud, just extended to Monitoring and Logging as well.

PiperOrigin-RevId: 807285744
2025-09-15 10:11:12 -07:00
Google Team Member 103e88e95f test: Add evaluation for BigQuery tools
We should treat this as the first step towards building a robust eval story for BQ tools.

PiperOrigin-RevId: 807247053
2025-09-15 08:16:33 -07:00
Kacper Jawoszek 7870480c63 feat(otel): add --otel_to_cloud experimental support
Cloud Trace, Cloud Monitoring and Cloud Logging integrations are set up via OTel if otel_to_cloud CLI param/fast_api arg is provided.

This is similar to current Cloud Trace integration via trace_to_cloud, just extended to Monitoring and Logging as well.

PiperOrigin-RevId: 807230668
2025-09-15 07:22:19 -07:00
Bastien Jacot-Guillarmod b9735b2193 docs: Correct the documentation of after_agent_callback
The `after_agent_callback` in plugin works similarly as the `after_agent_callback` in `base_agent.py`, e.g. it only append new content, but cannot modify the previous content.

PiperOrigin-RevId: 807162139
2025-09-15 03:06:57 -07:00
Wei Sun (Jack) 8ec83d6c18 feat(conformance): Add data definitions used to create adn run conformance tests
PiperOrigin-RevId: 807100057
2025-09-14 23:30:44 -07:00
Xiang (Sean) Zhou 6ab87da592 chore: Add back the request logging in RemoteA2aAgent given the logging was already fixed
PiperOrigin-RevId: 806551434
2025-09-12 22:40:58 -07:00
Wei Sun (Jack) b53e6e3567 chore: bump version to 1.14.1 with a patch for A2A logging issue
Prepare a patch version for #2918

PiperOrigin-RevId: 806537425
2025-09-12 21:29:58 -07:00
Google Team Member c29d41f0d0 feat: add Spanner similarity_search tool
Similarity search tool supports similarity search on Spanner data by embedding a text query to a vector and run vector search with the embedded vector.

PiperOrigin-RevId: 806502499
2025-09-12 18:49:50 -07:00
Google Team Member 0c1f1fadeb fix: Fix logging issues with RemoteA2aAgent
Recent change to the updated A2A Client SDK broke the logging utilities. This updates those logging utilities to work with the new A2A SDK structure.

PiperOrigin-RevId: 806482017
2025-09-12 17:20:04 -07:00
Google Team Member bb148002f8 fix: Filter out thought parts when saving agent output to state
PiperOrigin-RevId: 806478056
2025-09-12 17:05:26 -07:00
Google Team Member 4c00b86e33 feat: Provide location config for BigQuery tools
Right now the tolls are always running against multi-region US by default. With this change the agent builder can scope the tools to data and compute in a particular BigQuery location.

PiperOrigin-RevId: 806473857
2025-09-12 16:52:16 -07:00
Xuan Yang b3b31a9ffb chore: add a main.py script for the ADK docs updater agent
PiperOrigin-RevId: 806468319
2025-09-12 16:33:06 -07:00
Hangfei Lin 463dcee58c chore: specify the default sides for roll dice agent in bidi
PiperOrigin-RevId: 806468232
2025-09-12 16:32:10 -07:00
Google Team Member 4f07228f57 chore: Move framework filled params to the end in the BigQuery forecast tool
This is for better readability of the tool, specially in relation to the examples in the docstring.

PiperOrigin-RevId: 806460056
2025-09-12 16:03:57 -07:00
Google Team Member c53c02f022 chore: add clientIdEnum for CA API usage tracking
PiperOrigin-RevId: 806453560
2025-09-12 15:44:28 -07:00
Hangfei Lin 4e6b31a860 chore: Improve bug report template for Google ADK
Update the bug report issue template to request minimal reproducible examples, error/stacktrace, clarify OS options, and include questions about LiteLLM usage and specific model details.

PiperOrigin-RevId: 806435953
2025-09-12 14:53:03 -07:00
Hangfei Lin afebb5227b chore: Update ADK Live documentation on handling audio and transcriptions
Add guidelines for saving transcriptions as session Events and audio as artifacts with references in Events.

PiperOrigin-RevId: 806424916
2025-09-12 14:20:02 -07:00
Hangfei Lin 168c724866 test: Add test to ensure RunConfig instances do not share audio transcription configs
The new test verifies that `output_audio_transcription` and `input_audio_transcription` attributes are unique to each `RunConfig` instance, preventing unintended side effects from modifying one instance.

PiperOrigin-RevId: 806405671
2025-09-12 13:26:31 -07:00
Xiang (Sean) Zhou 05e3f73451 chore: Remove _in_memory_session_service from InMemoryRunner
PiperOrigin-RevId: 806385604
2025-09-12 12:29:23 -07:00
Hangfei Lin 23834e8a02 chore: Remove unused _get_audio_transcription_from_session function
This function is no longer called or needed within the `BaseLlmFlow` class.

PiperOrigin-RevId: 806351470
2025-09-12 11:02:37 -07:00
Xuan Yang de1c889a83 chore: create an initial ADK docs updater agent to create doc update PRs
PiperOrigin-RevId: 806348675
2025-09-12 10:55:36 -07:00
Hangfei Lin 2d98b2c30f chore: Update default model in live bidi streaming sample
Switched the active model from `gemini-live-2.5-flash-preview` (for AI Studio) to `gemini-2.0-flash-live-preview-04-09` (for Vertex).

PiperOrigin-RevId: 806348640
2025-09-12 10:54:41 -07:00
Xuan Yang 4cf00702a0 chore: re-structure adk_documentation folder so that agents in it can share the common files
PiperOrigin-RevId: 806348410
2025-09-12 10:53:44 -07:00
Hangfei Lin a7f4e02dc7 chore: Clarify that LLMResponse.content should only contain user/model-generated content
PiperOrigin-RevId: 806157090
2025-09-12 00:19:21 -07:00
Hangfei Lin 908757b47f chore: Add Tool Confirmation to README
This change updates the open-source workspace README to include "Tool Confirmation" in the list of new features.

PiperOrigin-RevId: 806127595
2025-09-11 22:34:01 -07:00
Wei Sun (Jack) 91528890db chore: Adds indent to YAML sequence by default for better visual readability
Both are valid YAML, just with indent, it's more visually friend to see the data structure hierarchy.

Before

```
items:
- item1
- item2
- item3
```

After

```
items:
  - item1
  - item2
  - item3
```
PiperOrigin-RevId: 806117290
2025-09-11 21:59:20 -07:00
Hangfei Lin f73ae6e101 chore: Remove redundant attribute descriptions from docstrings
The attributes are already defined as fields in the Pydantic models, making the docstring descriptions unnecessary.

PiperOrigin-RevId: 806091305
2025-09-11 20:15:19 -07:00
Google Team Member 9862b7b1e2 fix: Remove the logging method in remote a2a agent lib which is expecting a wrong type
The a2a_request is in type Message where the function expecting SendMessageRequest type

PiperOrigin-RevId: 806001430
2025-09-11 15:09:00 -07:00
Hangfei Lin ab69ef8de8 feat: Move livebidi agents esp multi-agent to use session/events
The old live/bidi agents are using a cache to store context/history during agent transfer etc. As we have added support for session for live/bidi, we are now migrating the context/history cache to it. This improves scalability, efficiency and maintainability.

It introduces several changes:
* AudioTranscriber support is removed as now we are using native transcription from models.
* Transcription is returned as input_transcription/output_transcription fields and no longer as contents.
* We will return a new event with artifact references of file type of audio/pcm.(in addition to existing audio response event. So the users of this api need to do proper filtering here.)

PiperOrigin-RevId: 805997675
2025-09-11 14:58:33 -07:00
Hangfei Lin 873551d7b9 chore: Update model references in README
Changed all instances of "gemini-2.0-flash" to "gemini-2.5-flash" in the example code snippets within the README.

PiperOrigin-RevId: 805949871
2025-09-11 12:48:39 -07:00
Xuan Yang 921e5cb370 ci: minor fix for the "bot responded" label for the discussion answering agent
PiperOrigin-RevId: 805905926
2025-09-11 10:56:43 -07:00
Xuan Yang f52608328e ci: fix discussion answering agent main.py by removing the redundant json import
PiperOrigin-RevId: 805879980
2025-09-11 09:56:38 -07:00
Ankur Sharma c5613fb6f0 feat: Add Rubrics to EvalCase datamodel
For advanced eval use cases, we do expect agent developers to have rubrics that are specific to an Eval Case and in some cases even specific to a single invocation/turn in the eval case conversation.

A separate PR will be created to consume this data model changes in ADK Eval.

PiperOrigin-RevId: 805588808
2025-09-10 18:00:15 -07:00
Xiang (Sean) Zhou 0bc2ee64e3 ci: Fix discussion answering agent
a. dump the discussion content to a tmp file first to avoid github redaction of environment variable
b. instruct the agent to use get_discussion_and_comments only when discussion content json is not available.

PiperOrigin-RevId: 805581573
2025-09-10 17:33:54 -07:00
Xuan Yang f96f0ebd0d chore: add issues: write permission for the ADK release analysis Github workflow
PiperOrigin-RevId: 805563540
2025-09-10 16:36:27 -07:00
Hangfei Lin 894bec794e chore: Update default and example Gemini models to new versions
Changes references from `gemini-1.5-flash` and `gemini-1.5-pro` to `gemini-2.5-flash` and `gemini-2.5-pro` in docstrings, default values, sample agents, and tests.

PiperOrigin-RevId: 805536434
2025-09-10 15:22:52 -07:00
Hangfei Lin 3c433b7168 chore: bidi streaming example on run live fast api
This sample connects to adk agent api server with websocket, to exchange streaming audio/text.

PiperOrigin-RevId: 805531120
2025-09-10 15:08:26 -07:00
Hangfei Lin 707c1a7bd4 ADK changes
PiperOrigin-RevId: 805523988
2025-09-10 14:49:25 -07:00
Shangjie Chen 97cf724f14 chore: Release ADK 1.14.0
PiperOrigin-RevId: 805506354
2025-09-10 14:04:22 -07:00
Ankur Sharma e88e667770 feat: Data model for Rubric based metric and eval config
Details:
- We plan on introducing Rubric based metrics in subsequent changes. This change introduces the data model needed that allows agent developer to provide rubrics.

- We also introduce a data model for the config that the eval system has been using for quite some time. It was loosely and informally described as a dictionary of metric names and expected thresholds. In this change, we actually formalize it using a pydantic data model, and extend it allow developers to specify rubrics as a part of their eval config.

What is a rubric based metric?
A rubric based metric is the assessment of a Agent's response (final or intermediate) along some rubric. This evaluation of agent's response significantly differs from the strategy where one has to provide a golden response.

PiperOrigin-RevId: 805488436
2025-09-10 13:20:07 -07:00
George Weale 37228beddd fix: Enable saving input blobs as artifacts in ADK web server for issue #2176
The `run_config` for `run_agent` now includes `save_input_blobs_as_artifacts=True`.

PiperOrigin-RevId: 805472895
2025-09-10 12:39:42 -07:00
Xuan Yang 957dc628ab chore: set up Github workflow for ADK release analyzer for doc updates
PiperOrigin-RevId: 805434018
2025-09-10 11:02:59 -07:00
Hangfei Lin 7148e0e82e test: Add tests for Runner initialization constraints
These tests verify that `ValueError` is raised when `Runner` is initialized without providing either an `app` instance or both `app_name` and `agent`.

PiperOrigin-RevId: 805427256
2025-09-10 10:48:33 -07:00
Google Team Member 0935a40011 feat: Add Bigquery Forecast tool
This tool answers questions about structured data in BigQuery using natural language.

PiperOrigin-RevId: 805414952
2025-09-10 10:20:47 -07:00
Xuan Yang 3b428ec81f chore: let adk-bot respond to discussion when it is tagged
PiperOrigin-RevId: 805406204
2025-09-10 10:02:23 -07:00
GenkiNoguchi 5cda37adb3 chore: fix typos in multiple files
Merge https://github.com/google/adk-python/pull/2864

**Reason for this change:**

  Multiple typos were found in comments, docstrings, and code throughout the codebase, which could lead to confusion and reduce code readability.

  **Changes made:**

  Fixed the following typos across 8 files:

  1. contributing/samples/adk_answering_agent/utils.py:130: "extention" → "extension"
  2. llms-full.txt:15171: "fuction" → "function"
  3. src/google/adk/a2a/converters/part_converter.py:
    - Line 96: "Conver" → "Convert", "reponse" → "response"
    - Line 99: "suervice" → "service"
    - Line 100: "accordinlgy" → "accordingly"
    - Line 191: "Conver" → "Convert", "reponse" → "response"
    - Line 195: "accordinlgy" → "accordingly"
  4. src/google/adk/agents/base_agent.py:568: "custome" → "custom"
  5. src/google/adk/evaluation/agent_evaluator.py:572: "Retruns" → "Returns"
  6. src/google/adk/flows/llm_flows/basic.py:55: "outoput_schema" → "output_schema"
  7. src/google/adk/flows/llm_flows/contents.py:136: "fuction_response" → "function_response"
  8. src/google/adk/models/google_llm.py:138: "gemini_llm_connecton.py" → "gemini_llm_connection.py"

  **Impact:**

  This change will:
  - Improve code documentation clarity and professionalism
  - Make comments, docstrings, and code more readable and accurate
  - Help prevent confusion for developers reading the code
  - Ensure consistency in terminology throughout the codebase

  This is a non-breaking change that only affects comments, documentation strings, and improves code clarity.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2864 from ammmr:chore-fix-typos 3cea9fcf6f21edb006b63e9258d2b82930dd961d
PiperOrigin-RevId: 805227784
2025-09-10 00:08:15 -07:00
Google Team Member 3e6d91f9e2 docs: Update description of task_completed function in SequentialAgent
PiperOrigin-RevId: 805223251
2025-09-09 23:53:14 -07:00
Xuan Yang 8132d3b621 chore: add instructions for the ADK release analyzer agent to sort the recommended changes and recommend API reference changes
PiperOrigin-RevId: 805099909
2025-09-09 16:07:28 -07:00
Xiang (Sean) Zhou 43c96811da ci: Fix discussion answering github action workflow to escape the quote in the discussion content JSON
PiperOrigin-RevId: 805091905
2025-09-09 15:42:34 -07:00
Xuan Yang e3422c616d chore: create an initial ADK release analyzer agent to find the doc updates needed between releases
PiperOrigin-RevId: 805030050
2025-09-09 13:00:05 -07:00
Hangfei Lin 8174a29c6d chore: update contribution guide
PiperOrigin-RevId: 804985449
2025-09-09 11:09:40 -07:00
Google Team Member a645580aa6 ADK changes
PiperOrigin-RevId: 804937691
2025-09-09 09:11:08 -07:00
Xuan Yang 78eea1aa55 chore: skip PR triage for already triaged or Google-contributor PRs
The `agent-triage-pull-request` job will now only run if the pull request does not have the 'bot triaged' or 'google-contributor' labels, avoiding redundant and unnecessary triage actions.

PiperOrigin-RevId: 804732073
2025-09-08 22:20:19 -07:00
Google Team Member fa55354a1a feat: Update to ADK + A2A Remote Client to use A2A SDK ClientFactory
Use the A2A Python SDK for client support for A2A Remote clients. This enables A2A based agents that use gRPC or RESTful interfaces, as well as the jsonrpc support. This also simplifies creation of clients and provides simpler mechanisms to inject credentials and observability into the remote agent interactions.

PiperOrigin-RevId: 804711466
2025-09-08 21:03:27 -07:00
Google Team Member 64f11a6a67 chore: Avoid mutable default arguments in local_eval_service and runners
Changed default values for `session_service`, `artifact_service`, and `run_config` from instances of mutable classes to `None`. Instances are now created within the function body if the argument is not provided, preventing unexpected shared state across function calls.

PiperOrigin-RevId: 804624564
2025-09-08 16:11:24 -07:00
George Weale d56dd08072 fix: Enable saving input blobs as artifacts in ADK web server for issue #2176
The `run_config` for `run_agent` now includes `save_input_blobs_as_artifacts=True`.

PiperOrigin-RevId: 804589111
2025-09-08 14:30:03 -07:00
Shangjie Chen 8452d2bcba feat: Allow function tool to pass in a callable to decide whether it need confirmation
PiperOrigin-RevId: 804583437
2025-09-08 14:16:59 -07:00
George Weale 43eec82f84 fix: Add a NOTE to agent transfer instructions listing available agents
The system instructions for agent transfer now include a NOTE section that lists all agents available for the `transfer_to_agent` function. This also has the target agents and, if there is one that applies, the parent agent. New unit tests are added to verify the correct generation of this NOTE.

PiperOrigin-RevId: 804569691
2025-09-08 13:43:38 -07:00
George Weale 5b465fd71b chore: Avoid mutable default arguments in local_eval_service and runners
Changed default values for `session_service`, `artifact_service`, and `run_config` from instances of mutable classes to `None`. Instances are now created within the function body if the argument is not provided, preventing unexpected shared state across function calls.

PiperOrigin-RevId: 804560641
2025-09-08 13:21:05 -07:00
George Weale ca5f7f1ff0 chore: Reorder dependencies in pyproject.toml
PiperOrigin-RevId: 804559734
2025-09-08 13:18:41 -07:00
Yujun Zou 467df1a36f docs: Update root_agent description for clarity
Update description as: Coordinator agent to greet users.

PiperOrigin-RevId: 804553925
2025-09-08 13:01:47 -07:00
Google Team Member 72ff9c64a2 feat: Add GkeCodeExecutor for sandboxed code execution on GKE #non-breaking
Merge https://github.com/google/adk-python/pull/1629

close https://github.com/google/adk-python/issues/2170

### Summary

This PR introduces `GkeCodeExecutor`, a new code executor that provides a secure and scalable method for running LLM-generated code by leveraging GKE Sandbox. It serves as a robust alternative to local or standard containerized executors by leveraging the **GKE Sandbox** environment, which uses gVisor for workload isolation.

For each code execution request, it dynamically creates an ephemeral Kubernetes Job with a hardened Pod configuration, offering significant security benefits and ensuring that each code execution runs in a clean, isolated environment.

### Key Features of GkeCodeExecutor

* **Dynamic Job Creation**: Uses the Kubernetes `batch/v1` API to create a new Job for each code snippet.
* **Secure Code Mounting**: Injects code into the Pod via a temporary `ConfigMap`, which is mounted to a read-only file.
* **gVisor Sandboxing**: Enforces execution within a `gvisor` runtime for kernel-level isolation.
* **Hardened Security Context**: Pods run as non-root with all Linux capabilities dropped and a read-only root filesystem.
* **Resource Management**: Applies configurable CPU and memory limits to prevent abuse.
* **Automatic Cleanup**: Uses the `ttl_seconds_after_finished` feature on Jobs for robust, automatic garbage collection of completed Pods and Jobs.
* **Node Scheduling**: The executor uses Kubernetes `tolerations` in its Pod specification. This allows the k8s scheduler to place the execution Pod onto a **_pre-configured_** gVisor-enabled node.
* **Module Integration**: The `GkeCodeExecutor` is registered in the `code_executors/__init__.py`, making it available for use by agents. The `ImportError` handling is configured to check for the required `kubernetes` SDK.

### Execution Flow:

1.  Agent invokes `GkeCodeExecutor` with the LLM-generated code.
2.  The `GkeCodeExecutor` will `execute_code` – creates a temporary `ConfigMap`, and then create a k8s `Job` to run it.
3.  This Job runs a standard `python:3.11-slim` container. The image is pulled once to the node and cached. The Job will mount the ConfigMap as `/app/code.py`
4.  The GkeCodeExecutor will monitor the Job to completion, fetch `stdout/stderr` logs from the container, return `CodeExecutionResult` to the LlmAgent, and ensure all temp resources are deleted.
5.  The calling agent formats the result and provides a final response to the user. If the result contains error, it will retry up to `error_retry_attempts` times.

PiperOrigin-RevId: 804511467
2025-09-08 11:15:29 -07:00
Shangjie Chen e63fe0c0eb fix: Fix pagination of list_sessions in VertexAiSessionService
Resolves https://github.com/google/adk-python/issues/2860

PiperOrigin-RevId: 804511401
2025-09-08 11:14:32 -07:00
Max Ind bc6b5462a7 test: add functional telemetry tests
This includes:
- Test verifying multiple spans are written during E2E runner execution.
- Regression tests for the "ContextVar was created in a different Context" exceptions caused by the interplay of context based instrumentation and async generators getting indeterminately suspended.

PiperOrigin-RevId: 804333483
2025-09-08 02:23:10 -07:00
George Weale 1e23652968 fix: AttributeError and indentation in parameter processing. For issue #2776 and issue #2763
PiperOrigin-RevId: 804222317
2025-09-07 18:37:42 -07:00
Google Team Member 1979dcf496 fix: Allow AgentTool to inherit/use plugins from its invocation context when running
PiperOrigin-RevId: 803656189
2025-09-05 17:09:04 -07:00
Hangfei Lin fc90ce968f test: Add unit tests for the App class and improve Runner initialization tests
-   Added `tests/unittests/apps/test_apps.py` with basic tests for `App` initialization.
-   Modified `tests/unittests/test_runners.py` to include a test that verifies `Runner` raises a `ValueError` when both `app` and `app_name` are provided during initialization.

PiperOrigin-RevId: 803556826
2025-09-05 12:16:38 -07:00
Hangfei Lin decc19b188 chore: Update release cadence in README
The release cadence is now described as "roughly bi-weekly" instead of "weekly".

PiperOrigin-RevId: 803528472
2025-09-05 11:03:05 -07:00
Xiang (Sean) Zhou 25df6c22d5 chore: Tune instructions to not ask root directory if it's already provided in the context
PiperOrigin-RevId: 803512675
2025-09-05 10:23:34 -07:00
Google Team Member 45c1fcc84f feat: disallow setting non-existent properties in BigQuery tools and credentials config
This will save the agent builder getting wrong impression if by mistake they set a property that does not exist.

PiperOrigin-RevId: 803208559
2025-09-04 15:58:19 -07:00
Wei Sun (Jack) ebf2c98e41 feat(conformance): Adds a minimal AdkWebServer http client for conformance tests to interact with
PiperOrigin-RevId: 803208215
2025-09-04 15:56:53 -07:00
Hangfei Lin 7b077ac351 chore: Add community repo dependency group to pyproject toml
PiperOrigin-RevId: 803191617
2025-09-04 15:11:09 -07:00
Google Team Member b05fef9ba7 feat: Allow custom part converters in A2A classes
This change introduces type descriptions for the functions which convert between A2A and GenAI `Part`s. It then allows passing instances of those functions to the various A2A-related functions/classes, effectively allowing users to inject their own logic for how part conversion should occur.

The benefit of this pattern is that users can create decorators around the core `Part` conversion logic, which allows them to intercept the cases they care about while delegating the ones they do not to the core converter. This is a pattern we use a lot in the A2A Python SDK.

One example where this type of logic is useful is for extensions: this allows extension logic to, for example, interpret an A2A DataPart into a FunctionResponse using extension-specific logic.

PiperOrigin-RevId: 803186799
2025-09-04 14:57:15 -07:00
Hangfei Lin 4df79dd5c9 feat: Upgrade ADK stack to use App instead in addition to root_agent
The convention:
- If some fields(like plugin) are defined both at root_agent and app, then a error will be raised.
- app code should be located within agent.py.
- an instance named app should be created

PiperOrigin-RevId: 803155804
2025-09-04 13:38:00 -07:00
Wei Sun (Jack) 14484065c6 chore: Follow pydantic convention to make field_validator a public method
PiperOrigin-RevId: 802861986
2025-09-03 22:36:25 -07:00
Che Liu 7720616c5f chore: Update comment to clarify after_run callbacks
PiperOrigin-RevId: 802852137
2025-09-03 22:01:27 -07:00
Shangjie Chen cecf7e805d fix: Support saving text artifacts in GCS artifact service
Resolves https://github.com/google/adk-python/issues/2775

PiperOrigin-RevId: 802850139
2025-09-03 21:55:07 -07:00
Mark Scannell edda922791 feat: add audience and prompt as configurable for OAuth flows
Merge https://github.com/google/adk-python/pull/2738

Some OAuth servers require audience such as [Jira](https://developer.atlassian.com/cloud/confluence/oauth-2-3lo-apps/). This change allows the configuration of audience and prompt (if it needs to be changed) and adds some tests.

This is for issue [2755](https://github.com/google/adk-python/issues/2755).

Resolves #2755

Happy to provide changes/updates if needed.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2738 from mescanne:oauth-audience-prompt 87ce1100792d9156ada2a004bcfaf2fe5fc69602
PiperOrigin-RevId: 802850034
2025-09-03 21:53:54 -07:00
Xiang (Sean) Zhou a1679dae3f feat: Allow users to pass their own agent card to to_a2a method
PiperOrigin-RevId: 802763510
2025-09-03 16:54:33 -07:00
Wei Sun (Jack) a30851ee16 fix: Fixes thought handling in contents.py and refactors its unit tests
Before this change, other agent's reply with thought will still be inserted in the outgoing LlmRequest due to the wrong `else` statement for calling all other type of part.

This commit also refactors test_contents.py to be behavior-oriented tests, instead of implementation-oriented, and add more test cases to cover expected scenarios.

The tests are divided into the following files with different focus:

- test_contents.py: covers the basic logic of event filter;
- test_contents_branch.py: covers the behavior related to branch, which takes effect when ParallelAgent is used.
- test_contents_other_agent.py: covers the retelling behavior to include other agents' reply as context for the current agent.
- test_contents_function.py: covers the function_call/function_response rearrangement logic mainly for `LongRunningFunctionTool`.

PiperOrigin-RevId: 802759821
2025-09-03 16:42:20 -07:00
Wei Sun (Jack) fe8b37b0d3 fix(planner): Fixes the thought field handling in _planning.py
Before this change: `thought` flags was incorrectly removed if the current agent enables BuiltInPlanner.

After this change:

- When it's BuiltInPlanner, keep the thought flag in content history, so that model has full context of its previous thinking.
- When it's PlanReactPlanner, removes the `thought` flag in content history, so that model sees as-is when the content was generated.

PiperOrigin-RevId: 802737130
2025-09-03 15:41:29 -07:00
Xiang (Sean) Zhou 578fad7034 feat: Allow agent loader to load built-in agents from special directories in adk folder
PiperOrigin-RevId: 802716848
2025-09-03 14:48:22 -07:00
pguerra-ce a3410fab7b fix: Pass state_delta to runner in /run endpoint
Merge https://github.com/google/adk-python/pull/2791

Fixes #2789

## Summary
Forward `state_delta` from the FastAPI `/run` request to `Runner.run_async(...)`, aligning behavior with the documented
API and the `/run_sse` endpoint.

## Why
The documentation for `/run` explicitly includes:
> `state_delta` (object, optional): A delta of the state to apply before the run.

However, the non‑SSE `/run` handler did not pass this value through, so `Runner.run_async` always received `None`. The
`/run_sse` path already forwarded it correctly.

## Changes
- `src/google/adk/cli/adk_web_server.py`
    - Add `state_delta=req.state_delta` to the "/run" handler’s `runner.run_async(...)` call.
- `tests/unittests/cli/test_fast_api.py`
    - Add `test_agent_run_passes_state_delta` to test the fix.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2791 from pguerra-ce:fix-state-delta-missing-in-run 83eec8d28b80757e24ae900285eb59530863adbd
PiperOrigin-RevId: 802703072
2025-09-03 14:13:19 -07:00
Xiang (Sean) Zhou b4310727d9 chore: Use lazy % formatting in logging functions to fix pylint warnings
PiperOrigin-RevId: 802639682
2025-09-03 11:35:49 -07:00
Xiang (Sean) Zhou 66cc98801a chore: Adjust the instruction of agent builder assistant for how to use google_search tool and url_context tool
PiperOrigin-RevId: 802629718
2025-09-03 11:14:45 -07:00
Google Team Member 49acad1252 ADK changes
PiperOrigin-RevId: 802455693
2025-09-03 01:50:08 -07:00
Alejandro Cruzado-Ruiz 455dcbda4c ADK changes
PiperOrigin-RevId: 802410800
2025-09-02 22:52:51 -07:00
Shangjie Chen fb009d8ea6 fix: Add custom_metadata to DatabaseSessionService
Resolve https://github.com/google/adk-python/issues/2677

PiperOrigin-RevId: 802375768
2025-09-02 20:09:46 -07:00
Google Team Member aad153322e docs: update the ask_data_insights docstring
PiperOrigin-RevId: 802362601
2025-09-02 19:21:04 -07:00
Shangjie Chen 219815d2d7 chore: Update create_session endpoint to use Request message as post body
Also deprecate create_session_with_id which is not very RESTful.

PiperOrigin-RevId: 802357718
2025-09-02 18:56:45 -07:00
Xiang (Sean) Zhou a503a0c807 ci: Load discussion data from event content to avoid additional GraphQL API call
PiperOrigin-RevId: 802308383
2025-09-02 15:22:17 -07:00
Xiang (Sean) Zhou 408d3dfeb1 chore: refactor discussion answering agent to merge answer_discussions.py into main.py
mainly to dedup duplicated functionality in both file.

PiperOrigin-RevId: 802291102
2025-09-02 14:25:32 -07:00
Google Team Member 831e2e6d4d ADK changes
PiperOrigin-RevId: 801284664
2025-08-30 11:08:43 -07:00
Hangfei Lin dff733c6fc feat: Upgrade ADK stack to use App instead in addition to root_agent
The convention:
- If some fields(like plugin) are defined both at root_agent and app, then a error will be raised.
- app code should be located within agent.py.
- an instance named app should be created

PiperOrigin-RevId: 801252329
2025-08-30 08:01:53 -07:00
Xiang (Sean) Zhou 67f23df25a feat: Allow user specify embedding model for file retrieval
And use Gemini embedding model as default model if no embedding model is specified.

PiperOrigin-RevId: 801161505
2025-08-29 23:35:25 -07:00
Shangjie Chen 0c87907bcb fix: Enforce foreign key constraint for SQLite DB
Resolves https://github.com/google/adk-python/issues/2752

PiperOrigin-RevId: 801106660
2025-08-29 19:07:22 -07:00
Google Team Member 214f2884f5 feat: Upgrade ADK stack to use App instead in addition to root_agent
The convention:
- If some fields(like plugin) are defined both at root_agent and app, then a error will be raised.
- app code should be located within agent.py.
- an instance named app should be created

PiperOrigin-RevId: 801103084
2025-08-29 18:49:04 -07:00
Hangfei Lin a2e89a22a5 feat: Upgrade ADK stack to use App instead in addition to root_agent
The convention:
- If some fields(like plugin) are defined both at root_agent and app, then a error will be raised.
- app code should be located within agent.py.
- an instance named app should be created

PiperOrigin-RevId: 801084463
2025-08-29 17:33:38 -07:00
Xiang (Sean) Zhou 98b0426cd2 chore: Make UT of a2a consistent about how tests should be skipped when python verison < 3.10
PiperOrigin-RevId: 801040421
2025-08-29 14:59:27 -07:00
Google Team Member 2eddc5e4d3 feat: allow setting compute project for BigQuery tools
This will allow restricting BigQuery SQL executions to the specified project. The agent/LLM should resolve the `project_id` param for tools like `execute_sql` and sometimes they can resolve it to an unexpected value due to hallucination or ambiguity. This guardrail will protect against that situation.

PiperOrigin-RevId: 801039685
2025-08-29 14:56:47 -07:00
Shangjie Chen a17bcbb2aa feat: Add a tool confirmation flow that can guard tool execution with explicit confirmation and custom input
The existing `LongRunningTool` does not define a programmatic way to provide & validate structured input, also it relies on LLM to reason and parse the user's response.

For a quick start, annotate the function with `FunctionTool(my_function, require_confirmation=True)`. A more advanced flow is shown in the `human_tool_confirmation` sample.

The new flow is similar to the existing Auth flow:
- User request a tool confirmation by calling `tool_context.request_confirmation()` in the tool or `before_tool_callback`, or just using the `require_confirmation` shortcut in FunctionTool.
- User can provide custom validation logic before tool call proceeds.
- ADK creates corresponding RequestConfirmation FunctionCall Event to ask user for confirmation
- User needs to provide the expected tool confirmation to a RequestConfirmation FunctionResponse Event.
- ADK then checks the response and continues the tool call.

PiperOrigin-RevId: 801019917
2025-08-29 13:56:54 -07:00
Xiang (Sean) Zhou 3ed9097983 chore: Add initial version of agent builder assistant that assists user to build config based agent
PiperOrigin-RevId: 801014241
2025-08-29 13:42:31 -07:00
George Weale 9291daaa8e chore: Add warning for using Gemini models via LiteLLM
Recommend to use Gemini outside of LiteLLM

PiperOrigin-RevId: 800971705
2025-08-29 11:32:45 -07:00
Google Team Member fcd748e17f chore: add contributing Spanner tools RAG agent sample
PiperOrigin-RevId: 800938492
2025-08-29 10:00:43 -07:00
Xiang (Sean) Zhou bb4cfdec12 fix: inject artifact into instructions
a. complain when artifact is None
b. inject None value as empty string instead of `None`

PiperOrigin-RevId: 800930613
2025-08-29 09:38:01 -07:00
George Weale e45c3be238 fix: send full MIME types for image/video/pdf in get_content
Use full media types (image/jpeg, video/mp4, application/pdf) instead of suffixes (jpeg/mp4/pdf) when constructing LiteLLM payloads
This fxes compatibility with providers that validate media types (Anthropic)
Updated and added unit tests to assert full MIME types for image/video/pdf

PiperOrigin-RevId: 800685204
2025-08-28 18:02:18 -07:00
Google Team Member 11a2ffe35a feat: allow setting agent/application name for BigQuery tools
This will allow tracking of tool usage per agent/application.

PiperOrigin-RevId: 800607186
2025-08-28 14:10:01 -07:00
Jinning Li f4a8df0ba2 feat:Add tool_responses to IntermediateData
PiperOrigin-RevId: 800600571
2025-08-28 13:55:15 -07:00
Wei Sun (Jack) 8e43f0dd83 fix(deploy): Add back installing requirements.txt to Dockerfile template for cloud run
PiperOrigin-RevId: 800595427
2025-08-28 13:43:03 -07:00
Xiang (Sean) Zhou b92b288c97 chore: fix flaky unit tests: tests/unittests/flows/llm_flows/test_functions_simple.py
original tests assert too strict time boundary, now we only assert the parallel execution time should be less than sequential execution time

PiperOrigin-RevId: 800563929
2025-08-28 12:17:03 -07:00
Xiang (Sean) Zhou 8d6f138fbe chore: Update oauth calendar sample agent to test the case when a subsequent tool call happends right after a tool call that requires auth
context: this is for reproducing https://github.com/google/adk-python/issues/1944 and verify corresponding fix
PiperOrigin-RevId: 800561025
2025-08-28 12:10:43 -07:00
Xiang (Sean) Zhou 3b922a2f6d fix: Only process the auth responses in the last event with content (if applicable i.e. it's authored by user)
fixes : https://github.com/google/adk-python/issues/1944
PiperOrigin-RevId: 800560805
2025-08-28 12:09:21 -07:00
Google Team Member 7975e8e196 refactor: Extract a utility for aggregating partial streaming responses and emitting LlmResponses for them as needed
PiperOrigin-RevId: 800521404
2025-08-28 10:29:14 -07:00
Wei Sun (Jack) 3bc2d77b4d chore(config): Reimplements AgentConfig with pydantic v2 convention and allow all possible values for agent_class field in all Agent Configs
All below are valid values now.

```
agent_class: LlmAgent
agent_class: google.adk.agents.LlmAgent
agent_class: google.adk.agents.llm_agent.LlmAgent
```
PiperOrigin-RevId: 800228114
2025-08-27 17:07:53 -07:00
Yifan Wang f743c29d00 chore: Bump version number to 1.13.0
PiperOrigin-RevId: 800210332
2025-08-27 16:09:42 -07:00
Yeesian Ng 69eb2b50c5 feat: Add --agent_engine_config_file option to adk deploy agent_engine
PiperOrigin-RevId: 800171071
2025-08-27 14:19:43 -07:00
Wei Sun (Jack) 2dd432cc1f fix: add the missing from_config class method in BaseToolset
PiperOrigin-RevId: 799893557
2025-08-26 23:48:05 -07:00
Hangfei Lin 3b997a0a07 fix: change LlmResponse to use Content for transcriptions
The transcription change breaks the multi-agent transfer during live/bidi.

Updates `GeminiLlmConnection` to populate the `content` field of `LlmResponse` with `types.Content` and `types.Part` objects for both input and output transcriptions, instead of using dedicated transcription fields. Also removes a debug print from `audio_cache_manager.py`.

the transcription is not fully ready to be used yet so roll back the transcription change.

PiperOrigin-RevId: 799851950
2025-08-26 21:12:59 -07:00
Google Team Member bcf0dda8bc fix: AgentTool returns last content, instead of the content in the last event
This fixes the issue when inner agent has after_agent_callback updating state only, AgentTool will always return empty.

PiperOrigin-RevId: 799814933
2025-08-26 19:15:23 -07:00
Wei Sun (Jack) 4c70606129 chore: Renames MCPTool and MCPToolset to McpTool and McpToolset
- Keep original class names for backward-compatibility.
- Log warning if user instantiate the classes with original names.
- New names are more aligned with MCP SDKs convention.

PiperOrigin-RevId: 799777320
2025-08-26 17:02:41 -07:00
Ankur Sharma 216cb7aec0 fix: Update routes for run_eval, get_eval_result, list_eval_results and list_metrics_info
PiperOrigin-RevId: 799718430
2025-08-26 14:27:00 -07:00
Mofi Rahman ad81aa54de fix: Fix adk deploy docker file permission
Merge https://github.com/google/adk-python/pull/2563

Currently in adk deploy cloud_run or gke, the dockerfile copies the agent code after the file permission is set. This can lead to file permission not being set correctly for the container to open and read the file.

This PR will make sure the files are copied with the permission of the user that is set in the container.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2563 from moficodes:deploy-docker d7f6df4d893af75b360e6d96ffd2640ce6076ca2
PiperOrigin-RevId: 799371070
2025-08-25 20:03:37 -07:00
Google Team Member 47b88d2b06 feat: Add the ask_data_insights tool for natural language queries on BigQuery data
PiperOrigin-RevId: 799267061
2025-08-25 14:23:10 -07:00
Jack Wotherspoon 6806deaf88 feat: passthrough extra args for adk deploy cloud_run as Cloud Run args
Merge https://github.com/google/adk-python/pull/2544

The command `adk deploy cloud_run` supports limited `gcloud run deploy` args 😢.

Which makes the command fine for simple deployments...

It should support all current and future Cloud Run deployment args for the command to be widely adopted.

This can easily be done by passing through all extra args passed to `adk deploy cloud_run` to gcloud...

This PR assumes any extra args/flags passed after `AGENT_PATH` are gcloud flags.

## Example

```sh
# ADK flags
adk deploy cloud_run \
--project=$GOOGLE_CLOUD_PROJECT \
--region=$GOOGLE_CLOUD_LOCATION \
$AGENT_PATH \
# Use the -- separator for gcloud args
-- \
--min-instances=2 \
--no-allow-unauthenticated
```

This gives full Cloud Run feature support to ADK users 🤖 🚀

## Test Plan

To test you can just build locally or pip install feature branch directly:

```
uv venv
uv pip install git+https://github.com/jackwotherspoon/adk-python.git
```

Deploy to Cloud Run using additional arguments following `AGENT_PATH`, such as `--min-instance=2` or `--description="Cloud Run test"`:

```sh
uv run adk deploy cloud_run \
--project=$GOOGLE_CLOUD_PROJECT \
--region=$GOOGLE_CLOUD_LOCATION \
--with_ui \
$AGENT_PATH \
-- \
--labels=test-label=adk \
--min-instances=2
```

You can click on the Cloud Run service after deployment and check the service yaml, you should see the additional label etc.

<img width="1612" height="622" alt="image" src="https://github.com/user-attachments/assets/596a260a-0052-460b-9642-c18900ccf7c9" />

Fixes https://github.com/google/adk-python/issues/2351

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2544 from jackwotherspoon:main 184a4d73f8dbe6f565ff92cf1c1fe69bb163de5e
PiperOrigin-RevId: 799252544
2025-08-25 13:45:21 -07:00
Wei Sun (Jack) 2b2f0b52d8 chore: Fixes a2a tests for python 3.9
A more common approach is to just skip entire module in pytest.

PiperOrigin-RevId: 799164877
2025-08-25 10:03:19 -07:00
Wei Sun (Jack) 0eb65c07d5 chore: Ignore hidden files in autoformat.sh
PiperOrigin-RevId: 798490378
2025-08-23 00:38:42 -07:00
akshaypachpute-1998 0b89f1882d chore: replaced hard coded value for user_id to the value from the tool context from parent agent. Fixes google/adk-python#2407
Merge https://github.com/google/adk-python/pull/2409

Description:

This PR Fixes: #2407

The AgentTool in /google/adk/tools/agent_tool.py uses a hardcoded user_id='tmp_user' when creating a new session for the agent it wraps. This happens within the run_async method.

code snippet
... @override async def run_async( self, *, args: dict[str, Any], tool_context: ToolContext, ) -> Any: ... session = await runner.session_service.create_session( app_name=self.agent.name, user_id='tmp_user',  # <-- This is hardcoded state=tool_context.state.to_dict(), ) ...

Why is this a problem?
This hardcoding breaks the chain of user identity. When a parent agent calls a sub-agent via the AgentTool, the original user_id is lost. Any tool or logic inside the sub-agent that needs to perform user-specific actions (e.g., accessing user data from a database, retrieving user-specific memory, checking permissions) will fail or operate on the wrong context because it receives 'tmp_user' instead of the actual user's ID.

Impact:
This prevents the creation of robust, multi-agent applications where user context must be maintained across different agents and tools. It limits the utility of AgentTool to only stateless sub-agents that do not require user-specific information.

Suggested Fix:
The user_id should be retrieved from the parent context, which is available via the tool_context parameter passed into run_async. The create_session call should be updated to use the dynamic user_id from the parent session.For example, the fix might involve accessing the user ID from the tool_context.

code-snippet
session = await runner.session_service.create_session( app_name=self.agent.name, user_id=tool_context._invocation_context.user_id, state=tool_context.state.to_dict(), )

To Reproduce
Steps to reproduce the behavior:
To reproduce this bug, we need to set up a two-agent system: a ParentAgent that calls a ChildAgent using the AgentTool. The ChildAgent will have a tool designed to simply return the user_id it receives from its context.

Expected behavior
It should return the user_id of the user calling the agent,

but, in current situation we are getting tmp_user

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2409 from akshaypachpute-1998:fix-issue-2407-agent-tool-context-propogation 0c3e8656fdf11386e3ab13a3a1f2df99a396dbd1
PiperOrigin-RevId: 798315832
2025-08-22 13:10:07 -07:00
Xiang (Sean) Zhou 124fee64e5 chore: Remove unnecessary import in runners
PiperOrigin-RevId: 798285019
2025-08-22 11:38:37 -07:00
Wei Sun (Jack) a360bc2542 docs: Clean up docs in sample
PiperOrigin-RevId: 798284758
2025-08-22 11:36:58 -07:00
Ankur Sharma 75ba9689e3 fix: Update routes for list_eval_sets, add_session_to_eval_set, get_eval, update_eval and delete_eval
PiperOrigin-RevId: 798241789
2025-08-22 09:41:59 -07:00
Wei Sun (Jack) 2c088acc9b docs: Fixes root_agent.yaml in tool_mcp_stdio_notion_config for Agent Config sample and add README.md
PiperOrigin-RevId: 798241478
2025-08-22 09:40:31 -07:00
rcsantana777 7fe60641e3 feat: Add custom User-Agent header to RestApiTool requests
Merge https://github.com/google/adk-python/pull/2641

This PR adds a custom `User-Agent` header to all requests made via `RestApiTool`. This allows backend services to identify traffic originating from the ADK. The header format is `google-adk/<version> (tool: <tool_name>)`, where `<version>` is the current version of the `google-adk` package, fetched dynamically from `google.adk.version`, and `<tool_name>` is the name of the specific `RestApiTool` instance.

**Associated Issue**

Fixes #2676

**Testing Plan**

**Unit Tests**

I ran the full suite of unit tests locally to ensure the changes did not introduce any regressions. All tests passed successfully.
```bash
$ pytest ./tests/unittests
================================= 4202 passed, 2459 warnings in 44.68s ====================
```
The warnings are related to existing experimental features and are not affected by this change.

**Manual End-to-End (E2E) Test**

I performed a manual test to ensure the integrated flow works as expected.

*   **Setup:** Created a clean virtual environment (`~/venvs/adk-e2e-test`) and installed the locally built `google-adk` package using `uv venv --seed` and `pip install dist/google_adk-*.whl`. Ran a custom `mock_server.py` script (using Flask) in one terminal to listen for requests and print headers. Ran a custom `run_test_tool.py` script in a second terminal to send a request using the modified `RestApiTool`.

*   **Execution:** The `run_test_tool.py` script successfully sent a POST request to the mock server's `/test` endpoint. The mock server received the request and printed the headers.

    **`run_test_tool.py` Output:**
    ```json
    {
      "message": "Request received successfully!"
    }
    ```

    **`mock_server.py` Output (Headers):**
    ```text
    --- Request Received ---
    Headers:
      Host: 127.0.0.1:8000
      User-Agent: google-adk/1.12.0 (tool: TestTool)
      Accept-Encoding: gzip, deflate
      Accept: */*
      Connection: keep-alive
      Content-Type: application/json
      Content-Length: 2
    ------------------------
    ```
    The `User-Agent: google-adk/1.12.0 (tool: TestTool)` header confirms the change is working as intended, dynamically fetching the package version and including the tool name.

**Checklist**

*   [x] Associated issue linked
*   [x] Unit tests passed
*   [x] End-to-end test performed and results documented
*   [x] Code formatted with `./autoformat.sh`

---

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2641 from rcsantana777:feat/add-user-agent a9a9375306c18bb7ba501276cbf76693e70a87ad
PiperOrigin-RevId: 798232385
2025-08-22 09:11:16 -07:00
Xiang (Sean) Zhou 395a50b5dc chore: add triaging instructions for mcp
PiperOrigin-RevId: 798017380
2025-08-21 20:06:51 -07:00
Hangfei Lin ddb070ff07 feat: Add support for store audio and transcription into events/sessions and artifacts
PiperOrigin-RevId: 798011660
2025-08-21 19:50:26 -07:00
Ankur Sharma f660180854 fix: Update create_eval_set API to return the created EvalSet and it route
PiperOrigin-RevId: 797974571
2025-08-21 17:13:46 -07:00
Xiang (Sean) Zhou 157f73181d feat: Allow user to specify protocol for A2A RPC URL in to_a2a utility
this fixes https://github.com/google/adk-python/issues/2405

PiperOrigin-RevId: 797958771
2025-08-21 16:26:57 -07:00
Joe Fernandez ccab076ace docs: Add What's new section to README.md
Merge https://github.com/google/adk-python/pull/2668

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2668 from joefernandez:patch-1 7bc04963755af76fe289d1855341553057348a55
PiperOrigin-RevId: 797958558
2025-08-21 16:25:30 -07:00
Wei Sun (Jack) 80d188199b chore: Fixes a few lint error for tools
PiperOrigin-RevId: 797945021
2025-08-21 15:49:21 -07:00
Google Team Member 29bb75f975 fix: updating BaseAgent.clone() and LlmAgent.clone() to properly clone fields that are lists
PiperOrigin-RevId: 797855214
2025-08-21 11:52:31 -07:00
Google Team Member 167182be01 fix: make tool description for bigquery execute_sql for various write modes self contained
So far we had a default docstring for the `execute-sql` tool and for non-default write modes we were concatenating more content to it. This was working fine in Python 3.9-3.12 but broke in Python 3.13 because of a nuanced difference in the string concatenation to the `__doc__` property of a function b/433914562#comment4. This change makes the docstring management more robust and readable.

PiperOrigin-RevId: 797843736
2025-08-21 11:26:19 -07:00
Xiang (Sean) Zhou 3f3aa7b32d fix: Set invocation_id and branch for event generated when both output_schema and tools are used
fixes https://github.com/google/adk-python/issues/2631

PiperOrigin-RevId: 797843460
2025-08-21 11:24:43 -07:00
Kacper Jawoszek 826f554789 fix: rework parallel_agent.py to always aclose async generators
See https://github.com/google/adk-python/issues/1670#issuecomment-3115891100

PiperOrigin-RevId: 797838268
2025-08-21 11:12:35 -07:00
Kacper Jawoszek 9645cee3a6 chore: add test for parallel agent to verify correct handling of exceptions
PiperOrigin-RevId: 797825924
2025-08-21 10:43:16 -07:00
Kacper Jawoszek 70f50db653 chore: add test for parallel agent to verify correct ordering of agents
PiperOrigin-RevId: 797817063
2025-08-21 10:21:37 -07:00
Google Team Member 81a53b53d6 fix: add table metadata info into Spanner tool get_table_schema and fix the key usage info
This can help to provide more context and information about the table, like parent-child relationship, and row deletion policy etc.

PiperOrigin-RevId: 797562858
2025-08-20 19:30:52 -07:00
Xiang (Sean) Zhou 52a3d6cb8a chore: Bump version number to 1.12.0
PiperOrigin-RevId: 797542097
2025-08-20 18:07:13 -07:00
Wei Sun (Jack) 331978772a fix: Fixes deps in test extra dep
PiperOrigin-RevId: 797509357
2025-08-20 16:25:08 -07:00
Wei Sun (Jack) e93f861cde chore: Removes unused to_agent_config method in BaseAgentConfig
PiperOrigin-RevId: 797502656
2025-08-20 16:08:36 -07:00
Google Team Member 54ed079100 fix: Fix Spanner DatabaseSessionService support
Introduce `DynamicPickleType` to handle session actions, using sqlalchemy-spanner `SpannerPickleType` when the database dialect is Spanner.

Connects to a Spanner database to store session data persistently in tables.
# Example using Spanner database:
`session_service = DatabaseSessionService(db_url="spanner+spanner:///projects/project-id/instances/instance-id/databases/database-id")`

# Example adk web command:
`adk web --session_service_uri="spanner+spanner:///projects/project-id/instances/instance-id/databases/database-id"`

PiperOrigin-RevId: 797416610
2025-08-20 12:26:53 -07:00
Thiago Salvatore c144b5347c fix: Add support for required params
Merge https://github.com/google/adk-python/pull/2212

This PR closes issue #2202

ADK was not parsing the required attribute when using LiteLLM, letting the LLM decide what is required vs not, not respecting function definitions.

## Test Plan

There's a fork of adk-python that is being running live for over 2 weeks in our production environment with millions of requests per day.

Below you can find a screenshot of the unit tests passing. I've also added one change to the test cases to cover this scenario

<img width="1904" height="483" alt="image" src="https://github.com/user-attachments/assets/5a6eb069-63ae-45a3-baca-6b01543f56fb" />

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2212 from thiagosalvatore:main 7de4037d8016389313f3fb22df40c12bac578523
PiperOrigin-RevId: 797393698
2025-08-20 11:31:53 -07:00
Wei Sun (Jack) 5b999ed6fd chore: Uses pydantic Field for Agent configs, so that the generated AgentConfig.json json schema can carry field description
PiperOrigin-RevId: 797094012
2025-08-19 18:03:47 -07:00
George Weale bb8ebd15f9 chore: Update openai dependency version, based on correct OPENAI release
Bump the minimum required version of the `openai` package to `>=1.100.2` for compatibility with LiteLLM.

PiperOrigin-RevId: 797027214
2025-08-19 14:43:58 -07:00
Google Team Member fef5318a22 docs: add contributing bigtable sample
PiperOrigin-RevId: 797014958
2025-08-19 14:08:55 -07:00
Xiang (Sean) Zhou 018db79d13 fix: Lazy load VertexAiCodeExecutor and ContainerCodeExecutor
VertexAiCodeExecutor and ContainerCodeExecutor request additional dependencies, lazy load them so that when users import other names, they won't get impacted if they don't had those additional dependencies installed.
 Original codes swallow the exception and log a debug log is wrong and awkward, should follow the same style as what we did in https://github.com/google/adk-python/blob/main/src/google/adk/tools/retrieval/__init__.py

PiperOrigin-RevId: 796969332
2025-08-19 12:06:59 -07:00
Google Team Member 77ed1f5f15 feat: Add setdefault method to the ADK State object
This makes the ADK state more pythonic, with the State API being more like a python dict.

PiperOrigin-RevId: 796767559
2025-08-19 01:45:33 -07:00
George Weale 4afc9b2f33 feat: Add env var to suppress experimental warnings
Checked with local wheel and worked as intended. The harness shows suppression works: 0 warnings for all true-like values.

This CL adds ADK_DISABLE_EXPERIMENTAL_WARNING to let the users to suppress warning messages from features decorated with @experimental.

Previously, using experimental features would always trigger a UserWarning. This change creates a way to disable these warnings, which can be good to stop flooding logs.

The warning is suppressed if ADK_DISABLE_EXPERIMENTAL_WARNING is set to a truthy value such as "true", "1", "yes", or "on" (case-insensitive).

Added unit tests to make sure:
Warning suppression for functions and classes when the env var is set.
Case-insensitivity and various truthy values for the env var.
Loading the env var from a .env file.

PiperOrigin-RevId: 796649404
2025-08-18 17:59:13 -07:00
Xuan Yang f8fd6a4f09 chore: add the missing license header for core_callback_config init file
PiperOrigin-RevId: 796641146
2025-08-18 17:29:09 -07:00
Google Team Member a953807cce feat: add Bigtable tools
These tools support basic operations to interact with Bigtable table metadata and query results.

PiperOrigin-RevId: 796571736
2025-08-18 14:17:08 -07:00
Google Team Member fa64545a9d fix: Fix the path for agent card in A2A demo
`AGENT_CARD_WELL_KNOWN_PATH` already contains a leading slash so is not needed in the `agent_card` URL.

PiperOrigin-RevId: 796543208
2025-08-18 13:04:38 -07:00
George Weale 004a0a0f2d fix: litellm-test due to breaking change in dep library of extension extra
PiperOrigin-RevId: 796543071
2025-08-18 13:03:04 -07:00
Google Team Member a117cf0af3 fix: Fix the path for agent card in A2A demo
`AGENT_CARD_WELL_KNOWN_PATH` already contains a leading slash so is not needed in the `agent_card` URL.

PiperOrigin-RevId: 796537920
2025-08-18 12:49:20 -07:00
Wei Sun (Jack) 1fd58cb363 chore(config): Creates yaml_utils.py in utils to allow adk dump yaml in the same style
PiperOrigin-RevId: 796531710
2025-08-18 12:34:09 -07:00
Shangjie Chen f03f167779 chore: Return explict None type for DELETE endpoints
The HTTP response code will become 204 No Content instead of 200.

PiperOrigin-RevId: 796123628
2025-08-17 09:58:40 -07:00
Liang Wu 43f302ce1a chore(config): Add _config suffix to all yaml-based agent examples
Also expand agent folder name to full spelling, e.g. ma --> multi_agent

PiperOrigin-RevId: 795926902
2025-08-16 16:10:43 -07:00
Shangjie Chen ecaa7b4c98 chore: Rename run related method and request to align with the conventions
PiperOrigin-RevId: 795660109
2025-08-15 16:48:01 -07:00
Xiang (Sean) Zhou 279e4fedd0 fix: Using base event's invocation id when merge multiple function response event
fix https://github.com/google/adk-python/issues/1531

PiperOrigin-RevId: 795657473
2025-08-15 16:38:15 -07:00
Liang Wu b3b70035c4 feat: support deploying config agent to Agent Engine in CLI
Both pure config and config with code are successfully deployed.

PiperOrigin-RevId: 795645102
2025-08-15 16:01:50 -07:00
Dan Liebling 22f34e9d2c fix: avoid crash when there is no candidates_token_count, which is Optional
PiperOrigin-RevId: 795643665
2025-08-15 15:56:05 -07:00
Liang Wu ba6e85eb3f docs(config): fix core_callback example
PiperOrigin-RevId: 795619488
2025-08-15 14:44:53 -07:00
Terrence Ryan c84350345a feat: adding build image to deploy cloud_run options (#2502)
* feat: adding build image to deploy cloud_run options

Gives the ability for a user to set the build image for the deployment step to Cloud Run.  Currently it is hard coded to python:3.11-slim, and this is still the default, but this allows that value to be overriden.

* fix: applied formatting scripts

testing:

Added tests to ensure the behavior of the cli remains consistent with when used or omitted.

* chore: next time run the formatter before you commit.

---------

Co-authored-by: Ivan Cheung <ivans.mailbox@gmail.com>
2025-08-15 11:36:44 -07:00
Shangjie Chen a2b7909fc3 fix: Fix the packaging version comparison logic in adk cli
Resolves https://github.com/google/adk-python/issues/2503

PiperOrigin-RevId: 795519711
2025-08-15 10:16:45 -07:00
Google Team Member b66054dd0d fix: Add Spanner admin scope to Spanner tool default Oauth scopes
PiperOrigin-RevId: 795519063
2025-08-15 10:15:15 -07:00
Wei Sun (Jack) 8a9a271141 fix(config): Fixes SequentialAgent.config_type type hint
Without ClassVar, it will cause pydantic to generate warning.

PiperOrigin-RevId: 795518646
2025-08-15 10:13:39 -07:00
Xiang (Sean) Zhou a2832d5ac7 feat: Support custom tool_name_prefix in auto-generated GoogleApiToolset
PiperOrigin-RevId: 795508179
2025-08-15 09:44:16 -07:00
Wei Sun (Jack) 1328e6ef62 docs(config): Adds a minimal sample to demo how to use Agent Config to create a multi-agent setup
PiperOrigin-RevId: 795501478
2025-08-15 09:22:52 -07:00
Wei Sun (Jack) cd357bf5ae fix: Fixes the host in the ansi bracket of adk web
localhost cannot always open Web UI, since we only bind 127.0.0.1.

PiperOrigin-RevId: 795484904
2025-08-15 08:26:01 -07:00
Google Team Member a27927dc81 fix: Add spanner tool name prefix
PiperOrigin-RevId: 795339631
2025-08-14 22:14:18 -07:00
Liang Wu 6c217bad82 chore: update models in samples/ folder to be gemini 2.0+
Gemini 1.5 is obsolete and not accessible to new projects.

PiperOrigin-RevId: 795330977
2025-08-14 21:36:23 -07:00
Xuan Yang c32cb6eef9 chore: remove the "one commit" requirement from the contributing guide
PiperOrigin-RevId: 795217167
2025-08-14 15:13:19 -07:00
Hangfei Lin 80052700f6 chore: Bump version to 1.11.0
release for 1.11.0

PiperOrigin-RevId: 795195869
2025-08-14 14:19:15 -07:00
Google Team Member c8059428a2 chore: add contributing spanner sample
PiperOrigin-RevId: 795154839
2025-08-14 12:41:28 -07:00
Xuan Yang e63e2a7106 fix: add the missing required tool parameters for Anthropic models
Fixes #1692

PiperOrigin-RevId: 795125801
2025-08-14 11:31:00 -07:00
Wei Sun (Jack) 9ba8eec220 feat(tracing): Adds more OpenTelemetry convention attributes: gen_ai.request.max_tokens, gen_ai.request.top_p and gen_ai.response.finish_reasons
Fixes #1234

PiperOrigin-RevId: 795082815
2025-08-14 09:52:50 -07:00
Kacper Jawoszek 9cfe43334a fix: Uncomment OTel tracing in base_llm_flow.py
It was mistakenly commented out in the previous change.

PiperOrigin-RevId: 795048873
2025-08-14 08:20:07 -07:00
Xiang (Sean) Zhou 52284b1bae fix: A2A RPC URL got overriden by host and port param of adk api server
PiperOrigin-RevId: 794708721
2025-08-13 13:20:26 -07:00
George Weale a74d3344bc chore: Added upper version bounds to dependencies in "pyproject.toml"
This change keeps dependencies to their major versions, but for the pre 1.0.0 releases pinned to minor releases as they could have breaking changes.

PyYAML: Version 7.0 is in development and could have breaking changes

absolufy-imports: The package is archived and no longer maintained.

anyio: Follows SemVer, so version 5.0 could have breaking changes.

authlib: Follows a SemVer-like pattern, so version 2.0 could have breaking changes.

click: A mature library, version 9.0 is the expected boundary for breaking changes.

fastapi: As a pre-1.0 library, the next minor release could have breaking changes.

google-api-python-client: Although in maintenance, version 3.0 could still have breaking changes.

google-cloud-aiplatform: Follows SemVer, so breaking changes are expected in version 2.0.

google-cloud-secret-manager: A stable Google library, version 3.0 could lead to breaking changes.

google-cloud-speech: A stable Google library, version 3.0 could lead to breaking changes.

google-cloud-storage: A stable Google library.

google-genai: As an official Google SDK, version 2.0 is the expected boundary for breaking changes.

graphviz: As a pre-1.0 library, the next minor release could have breaking changes.

mcp: As an SDK, version 2.0 is the boundary for potential breaking changes.

opentelemetry-api: Follows SemVer; version 2.0 could have breaking changes.

opentelemetry-exporter-gcp-trace: It's tied to the v1 OpenTelemetry API, so version 2.0 would likely be a breaking change.

opentelemetry-sdk: It's coupled to the v1 API, so version 2.0 would likely be a breaking change.

pydantic: This stops upgrades to the incompatible version 3.0 after its major 2.0 rewrite.

python-dateutil: Follows to SemVer, making version 3.0 the boundary for potential breaking changes.

python-dotenv: Locks to stable version 1.0 major release.

requests: As a more mature library, version 3.0 is boundary for breaking changes.

sqlalchemy: This locks the dependency to the stable version 2.0 API after its major rewrite.

starlette: As a pre-1.0 library, the next minor release could have breaking changes.

tenacity: This is a mature library, version 9.0 is boundary for breaking changes.

typing-extensions: Major versions are tied to large typing changes in Python itself.

tzlocal: The library has a history of introducing breaking API changes between major versions.

uvicorn: As a pre-1.0 library, the next minor release could have breaking changes.

watchdog: As a stable library, version 7.0 could have breaking changes.

websockets: Follows SemVer, so version 16.0 is the boundary for breaking changes.
PiperOrigin-RevId: 794677571
2025-08-13 12:03:47 -07:00
George Weale ddf2e2194b chore: Update python-version in .github/workflows/python-unit-tests.yml to ["3.9", "3.10", "3.11", "3.12", "3.13"]
Verified with uv on Python 3.12 and 3.13 using the same ignores as CI.
3.12:
uv python install 3.12 && uv venv --python 3.12 .venv && source .venv/bin/activate
uv sync --extra test --extra eval --extra a2a
python -m pytest tests/unittests --ignore=tests/unittests/artifacts/test_artifact_service.py --ignore=tests/unittests/tools/google_api_tool/test_googleapi_to_openapi_converter.py
3.13: repeated the above with 3.13 (separate env)
Result: All unit tests passed

PiperOrigin-RevId: 794669437
2025-08-13 11:43:24 -07:00
Kacper Jawoszek a30c63c593 fix: aclose all async generators to fix OTel tracing context
See https://github.com/google/adk-python/issues/1670#issuecomment-3115891100

PiperOrigin-RevId: 794659547
2025-08-13 11:18:26 -07:00
Wei Sun (Jack) c5af44cfc0 docs(config): Fixes tool_functions, which is a config-based sample for using tools
PiperOrigin-RevId: 794652291
2025-08-13 11:01:52 -07:00
Google Team Member c52f956433 chore: Update comment to reference "Streamable HTTP Client"
Corrects a typo in the `StreamableHTTPConnectionParams` docstring, changing "SSE" to "Streamable HTTP" to accurately reflect the referenced client.

PiperOrigin-RevId: 794424727
2025-08-12 23:45:23 -07:00
Xuan Yang 585141e0b7 fix: Use PreciseTimestamp for create and update time in database session service to improve precision
PiperOrigin-RevId: 794422113
2025-08-12 23:36:53 -07:00
Google Team Member 114db93d70 ADK changes
PiperOrigin-RevId: 794403729
2025-08-12 22:29:23 -07:00
Hangfei Lin e2518dc371 fix: Ignore AsyncGenerator return types in function declarations
For Vertex model backend, we send response back. This doesn't work for streaming tools that the return type is AsyncGenerator. So the fix here is to ignore the return type when it's AsyncGenerator.

We can't distinguish streaming vs non-streaming tool with AsyncGenerator though as LiveRequestQueue is optional in streaming tool.

Adds an `ignore_response` option to `build_function_declaration` to skip including the return type in the function declaration. This is enabled for tools that return `AsyncGenerator`, as the model does not yet support understanding these return types, while streaming tools can still handle them. Also, removes redundant return statements in `_get_mandatory_params`.

PiperOrigin-RevId: 794392846
2025-08-12 21:45:52 -07:00
Xiang (Sean) Zhou 8c65967cdc fix: Make all subclass of BaseToolset to call parent constructor
So that all member field are created / initialized in the base toolset.

PiperOrigin-RevId: 794388671
2025-08-12 21:32:24 -07:00
Xiang (Sean) Zhou ebd726f1f5 feat: Support adding prefix to tool names returned by toolset
This is to address the name conflict issue of tools returned by different toolset. Mainly it's to give each toolset a namespace.

We have a flag `add_tool_name_prefix` to decide whether to apply this behavior
We have a `tool_name_prefix` to let client specify a custom prefix, if not set , toolset name will be used as prefix.

PiperOrigin-RevId: 794306796
2025-08-12 16:17:53 -07:00
Goldy 54680edf3c fix: path parameter extraction for complex Google API endpoints
Merge https://github.com/google/adk-python/pull/1815

fix: path parameter extraction for complex Google API endpoints

- Fix GoogleApiToOpenApiConverter to handle path parameters in complex endpoints like /v1/documents/{documentId}:batchUpdate
- Use Google Discovery Document 'location' field
- Add comprehensive test suite for Google Docs batchUpdate functionality
- Verify parameter location handling for complex endpoint patterns
- Test schema validation for BatchUpdateDocumentRequest/Response

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/1815 from goldylocks87:fix-issue-1814-path-parameter-extraction af5508ec6975b1ccbc34931a0041e422ee259c16
PiperOrigin-RevId: 794301898
2025-08-12 16:02:45 -07:00
Shangjie Chen bb3735c9ca chore: Remove logging that contains full event data from DatabaseSessionService
Resolves https://github.com/google/adk-python/issues/2153

PiperOrigin-RevId: 794288546
2025-08-12 15:19:52 -07:00
Xuan Yang a09a5e67aa chore: add the missing env variables in discussion_answering.yml
PiperOrigin-RevId: 794285985
2025-08-12 15:12:03 -07:00
Google Team Member 7e0880869b feat: Expose print_detailed_results param to AgentEvaluator.evaluate
Currently `print_detailed_results` is available only in `AgentEvaluator.evaluate_eval_set` while the adk-samples data science agent uses `AgentEvaluator.evaluate` https://github.com/google/adk-samples/blob/c230c3ddc16a3f9fc7edff409b567bdd65ebd9da/python/agents/data-science/eval/test_eval.py#L32.

PiperOrigin-RevId: 794262781
2025-08-12 14:07:17 -07:00
Google Team Member 1fc8d20ae8 feat: add Spanner first-party toolset (breaking change to BigQueryTool, consolidating into generic GoogleTool)
Spanner toolset support basic operations to interact with Spanner table metadata and query results.

Consolidate BigQueryTool into generic GoogleTool, so that BigQueryToolset and SpannerToolset can share.

PiperOrigin-RevId: 794259782
2025-08-12 13:59:37 -07:00
Google Team Member 10e3dfab1a feat: remove load_dotenv() in feature_decorator.py
PiperOrigin-RevId: 794249376
2025-08-12 13:35:49 -07:00
Xuan Yang 5fba1963c3 chore: add Gemini API docs as a new datastore for the ADK Answering Agent
PiperOrigin-RevId: 794247007
2025-08-12 13:30:00 -07:00
Xuan Yang 7d2cb654f0 chore: add the missing license header for some sample agents' files
PiperOrigin-RevId: 794165986
2025-08-12 10:24:36 -07:00
Xiang (Sean) Zhou 88f759a941 fix: docstring concatenation in 3.13
The issue was caused by a breaking change in Python 3.13's inspect.cleandoc() function that made it more conservative about whitespace handling:

Root Cause:

- Python 3.12-: inspect.cleandoc() used line.lstrip() - strips all whitespace (spaces, tabs, etc.)
- Python 3.13+: inspect.cleandoc() uses line.lstrip(' ') - strips only space characters

PiperOrigin-RevId: 793921360
2025-08-11 21:26:25 -07:00
Wei Sun (Jack) e295feb4c6 docs: Add workflow_triage sample for multi-agent request orchestration
Demonstrates intelligent triage system with root planning agent and parallel
execution agents.

Use session state to store the execution plan and coordinate with other specialized agents.

Check out README.md for more details.

PiperOrigin-RevId: 793884758
2025-08-11 19:05:53 -07:00
Liang Wu d87feb8ddb docs(config): add examples for config agents
PiperOrigin-RevId: 793871778
2025-08-11 18:09:55 -07:00
Shangjie Chen 88114d7c73 chore: Add docstring to clarify the behavior of preload memory tool
PiperOrigin-RevId: 793840979
2025-08-11 16:33:49 -07:00
Xiang (Sean) Zhou d0b3b5d857 chore: add experimental messages for a2a related API
PiperOrigin-RevId: 793812544
2025-08-11 15:09:08 -07:00
Wei Sun (Jack) d674178a05 chore: Fixes generate_image sample
PiperOrigin-RevId: 793725452
2025-08-11 11:15:06 -07:00
Wei Sun (Jack) dc26aad663 docs: Adds pypi badge to README.md
PiperOrigin-RevId: 793713600
2025-08-11 10:47:57 -07:00
Shangjie Chen 7f12387eb1 chore: Make all FastAPI endpoints async
PiperOrigin-RevId: 792886431
2025-08-08 21:58:34 -07:00
Eugen-Bleck 8f937b5175 docs: update StreamableHTTPConnectionParams docstring to remove SSE references (#1456)
Co-authored-by: Terrence Ryan <tpryan@google.com>
Fixes: google/adk-docs#475
2025-08-08 20:42:43 -07:00
Shangjie Chen c323de5c69 chore: Group FastAPI endpoints with tags
PiperOrigin-RevId: 792816574
2025-08-08 17:20:46 -07:00
Liang Wu b4f1ebea31 chore(config): replace @working_in_progress with @experimental for config agent feature
PiperOrigin-RevId: 792803076
2025-08-08 16:32:50 -07:00
Google Team Member 944e39ec2a chore: allow implementations to skip defining a close method on Toolset
PiperOrigin-RevId: 792760747
2025-08-08 14:22:17 -07:00
Xiang (Sean) Zhou 9478a31bf2 fix: Lazy load retrieval tools and prompt users to install extensions if import failed
PiperOrigin-RevId: 792701550
2025-08-08 11:37:47 -07:00
Xiang (Sean) Zhou f2005a2026 chore: Add sample agent to test support of output_schema and tools at the same time for gemini model
PiperOrigin-RevId: 792694074
2025-08-08 11:16:31 -07:00
Xiang (Sean) Zhou af635674b5 feat: Support both output_schema and tools at the same time in LlmAgent
1. Allow developers to specify output schema and tools together.
2. If both are specified, do the following:
  2.1 Do not set output schema on the model config
  2.2 Add a special tool called set_model_response(result)
  2.3 `result` has the same schema as the requested output_schema
  2.4 Instruct the model to use set_model_response() to output its final result, rather than output text directly.
  2.5 When the set_model_response() is called, ADK will extract its content and put it in a text part, so the client would treat it as the model response.

PiperOrigin-RevId: 792686011
2025-08-08 10:55:22 -07:00
Xiang (Sean) Zhou b4ce3b12d1 fix: incorrect logic in LlmRequest.append_tools and make BaseTool to call it
PiperOrigin-RevId: 792642882
2025-08-08 08:53:57 -07:00
Google Team Member 98a5730115 fix: incorrect logic in LlmRequest.append_tools and make BaseTool to call it
PiperOrigin-RevId: 792518526
2025-08-08 01:29:47 -07:00
Xiang (Sean) Zhou 4b2a8e3186 fix: incorrect logic in LlmRequest.append_tools and make BaseTool to call it
PiperOrigin-RevId: 792474565
2025-08-07 22:53:54 -07:00
Sam Hatfield e4d54b66b3 fix: Creates an InMemoryMemoryService within the EvaluationGenerator
Merge https://github.com/google/adk-python/pull/2263

Addresses #2084

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2263 from sjhatfield:main 8d6fca48437f151c34b2766ea4813a777bafcabd
PiperOrigin-RevId: 792336301
2025-08-07 15:40:42 -07:00
Xuan Yang 5900273455 chore: add Github workflow config for uploading ADK docs to knowledge store
PiperOrigin-RevId: 792272706
2025-08-07 12:52:28 -07:00
Xuan Yang b5a8bad170 chore: update ADK Answering agent to reference doc site instead of adk-docs repo
PiperOrigin-RevId: 792259386
2025-08-07 12:17:09 -07:00
Shangjie Chen 20c30d5819 chore: Bump version number to 1.10.0
PiperOrigin-RevId: 792206610
2025-08-07 10:05:01 -07:00
Yeesian Ng 83e5df7862 fix: Set the agent_framework when initializing module-based agent engine
PiperOrigin-RevId: 792170095
2025-08-07 08:27:15 -07:00
Google Team Member 25b2806301 fix: accommodate for open api schema that do not have any 'properties'
PiperOrigin-RevId: 792028582
2025-08-07 00:30:50 -07:00
Xuan Yang f6a022cda3 chore: only run ADK Answering Agent automatically when Q&A discussion is created
PiperOrigin-RevId: 792025646
2025-08-07 00:19:30 -07:00
Liang Wu e0a8355219 chore(config): add the public URL of JSON schema file to template
PiperOrigin-RevId: 791983175
2025-08-06 21:50:20 -07:00
Liang Wu d9ce2e691c feat(config): implement config and from_config for MCPToolset
The connection_params argument in the constructor is split into four arguments in the config class because some of them have identical fields. In order to identify which is which, a separate name is more convenient.

PiperOrigin-RevId: 791965995
2025-08-06 20:45:58 -07:00
Liang Wu dc193f7969 fix(config): fix adk create --type=config
Previously click didn't convert the input into the enum type.

PiperOrigin-RevId: 791922529
2025-08-06 18:10:21 -07:00
Xuan Yang 6277dae749 chore: add a disclaimer for the response from the answering agent
PiperOrigin-RevId: 791915465
2025-08-06 17:49:08 -07:00
Liang Wu ef837015f3 refactor(config): move BaseToolConfig to a separate file
PiperOrigin-RevId: 791841562
2025-08-06 14:18:20 -07:00
Google Team Member 54cc849de7 feat: Add metadata field to ADK BaseTool
PiperOrigin-RevId: 791790030
2025-08-06 12:11:42 -07:00
Liang Wu e73d71d324 feat(config): implement config and from_config for ExampleTool
Only list[Example] is supported in config. BaseExampleProvider will need to be used in code.

PiperOrigin-RevId: 791763913
2025-08-06 11:05:54 -07:00
Xiang (Sean) Zhou e528749a1c fix: lazy import VertexAiRagRetrieval
original codes try to eagerly import VertexAiRagRetrieval while it doesn't want to raise error if client try to import other names in this package and dependencies of VertexAiRagRetrieval is missing. so it swallow the import error which doesn't make sense, given vertex sdk is a must have for VertexAiRagRetrieval, we should fail fast.

this fix achieve the same purpose but fail fast if client try to import  VertexAiRagRetrieval from this package and miss certain dependencies (e.g. vertex sdk)

PiperOrigin-RevId: 791759776
2025-08-06 10:54:57 -07:00
Liang Wu 1686cc57c2 feat(config): implement configs and from_config() for CrewaiTool and LangchainTool
PiperOrigin-RevId: 791742964
2025-08-06 10:19:12 -07:00
Wei Sun (Jack) 53803522b6 refactor(config): Makes BaseAgent.from_config a final method and let sub-class to optionally override _parse_config to update kwargs if needed
This ensures that the pydantic hooks (e.g. model_validators) are triggered correctly.

PiperOrigin-RevId: 791545704
2025-08-05 23:53:25 -07:00
Liang Wu e3c2bf3062 chore: remove unused Example-related classes
PiperOrigin-RevId: 791538058
2025-08-05 23:26:06 -07:00
Liang Wu 2fff882fb0 feat(config): implement from_config() for BaseTool
PiperOrigin-RevId: 791520708
2025-08-05 22:26:23 -07:00
Xuan Yang a3b31ca950 chore: add the missing name for the ADK Answering Agent workflow
PiperOrigin-RevId: 791413949
2025-08-05 16:24:24 -07:00
Xuan Yang 8dc0c949af chore: add Github workflow config for the ADK Answering agent
PiperOrigin-RevId: 791407331
2025-08-05 16:07:09 -07:00
Hangfei Lin 71fbc9275b feat: Implement Live Session Resumption
Previous implementation doesn't pass the actual handle to server. Now we cache the handle and pass it over when reconnection happens.

To enable:
    run_config = RunConfig(
        session_resumption=types.SessionResumptionConfig(transparent=True)
    )

PiperOrigin-RevId: 791308462
2025-08-05 11:50:54 -07:00
Xiang (Sean) Zhou 423542a43f fix: shared default plugin manager and cost manager instances among multiple invocations
PiperOrigin-RevId: 791303349
2025-08-05 11:38:52 -07:00
Xiang (Sean) Zhou 37dae9b631 chore: Import AGENT_CARD_WELL_KNOWN_PATH from adk instead of from a2a directly
thus let adk handle import problem for a2a, e.g. python version need to be > 3.10 etc.

PiperOrigin-RevId: 791273137
2025-08-05 10:28:37 -07:00
Liang Wu 0e28d64712 feat(tools): create enterprise_web_search_tool as a tool instance
There is no argument for the tool, so just like google_search, we should make it an easy-to-use tool instance.

PiperOrigin-RevId: 791266806
2025-08-05 10:11:37 -07:00
Xiang (Sean) Zhou 6da6c2a44c fix: using async lock for accessing shared object in parallel executions and update tests for testing various type of functions
1. given we are running parallel functions in one event loop (one thread) , we should use async lock instead of thread lock
2. test three kind of functions:
  a. sync function
  b. async function that doesn't yield
  c. async function that yield

PiperOrigin-RevId: 791255012
2025-08-05 09:45:04 -07:00
Wei Sun (Jack) 8ef2177658 test: Fixes adk cli options and method parameters mismatching and adds a unit test for future proof checking
The test will fail if `@option` list and method parameter don't match.

Future proof test for #2328

PiperOrigin-RevId: 791022512
2025-08-04 21:08:57 -07:00
Google Team Member 97318bcd19 fix: correct type annotation
Overridden `supported_models` should be a `classmethod` rather than a `staticmethod`.

PiperOrigin-RevId: 790989895
2025-08-04 19:25:52 -07:00
Xuan Yang 283303032a chore: update the prompt to make the ADK Answering Agent more objective
PiperOrigin-RevId: 790882938
2025-08-04 13:59:59 -07:00
nikkie e369c283b3 fix: typo againt (in adk run --replay help)
Merge https://github.com/google/adk-python/pull/2327

`adk run --help` (adk 1.9.0)

```
  --replay FILE      The json file that contains the initial state of the
                     session and user queries. A new session will be created
                     using this state. And user queries are run againt the
                     newly created session. Users cannot continue to interact
                     with the agent.
```

```
$ git grep againt
src/google/adk/cli/cli_tools_click.py:        " queries are run againt the newly created session. Users cannot"
```

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2327 from ftnext:fix-typo-run-replay-help 77cae65a235d9119810fe3d209910562672713c8
PiperOrigin-RevId: 790872246
2025-08-04 13:32:41 -07:00
Xuan Yang 74589a1db7 chore: make LlmRequest.LiveConnectConfig field default to a factory to avoid sharing a mutable instance
PiperOrigin-RevId: 790854215
2025-08-04 12:43:34 -07:00
Wei Sun (Jack) e41dbccf7f fix(cli): Fixes adk deploy cloud_run cli
Fixes #2328

PiperOrigin-RevId: 790775592
2025-08-04 09:16:26 -07:00
Carol Zheng d620bcb384 fix: Remove thoughts from contents in llm requests
Merge https://github.com/google/adk-python/pull/2320

Fix #843

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2320 from CAROLZXYZXY:cazheng/fix-843 5b4a4b256928cb766a44a3e18d4300b7ee5f779f
PiperOrigin-RevId: 790592793
2025-08-03 22:48:25 -07:00
Xiang (Sean) Zhou 90b9193a20 chore: Add sample agent for testing parallel functions execution
PiperOrigin-RevId: 790208057
2025-08-02 14:53:03 -07:00
Xiang (Sean) Zhou 57cd41f424 feat: Support parallel execution of parallel function calls
PiperOrigin-RevId: 790182046
2025-08-02 12:28:19 -07:00
Divyansh Shukla 7556ebc76a feat: Allow max tokens to be customizable in Claude
PiperOrigin-RevId: 789901925
2025-08-01 14:43:57 -07:00
Wei Sun (Jack) 2bb20411f4 feat(config): Adds BaseAgent.config_type field to indicate the config for the current agent and removes if-else branches against LlmAgent/LoopAgent/... in config_agent_utils::from_config
This makes the logic work with any user-defined agent with user-defined XxxAgentConfig.

PiperOrigin-RevId: 789845354
2025-08-01 12:02:07 -07:00
Xiang (Sean) Zhou 86a44873e9 fix: Annotate response type as None for transfer_to_agent tool and set empty Schema as response schema when tool has no response annotation
1. if a function has no return type annotation, we should treat it as returning any type
2. we use empty schema (with `type` as None) to indicate no type constraints and this is already supported by model server

PiperOrigin-RevId: 789808104
2025-08-01 10:22:28 -07:00
Xiang (Sean) Zhou faadef167e fix: incompatible a2a sdk changes
a. camel case to snake case
b. A2ACardResolver moved to different module

PiperOrigin-RevId: 789807686
2025-08-01 10:20:37 -07:00
Google Team Member bead607364 chore: Hide the ask_data_insights tool until the API is publicly available
PiperOrigin-RevId: 789806535
2025-08-01 10:17:13 -07:00
Xuan Yang 041f04e89c chore: change LlmRequest.config's default value to be types.GenerateContentConfig() instead of None
PiperOrigin-RevId: 789792582
2025-08-01 09:36:20 -07:00
Google Team Member 16a15c8709 docs: fix typos
PiperOrigin-RevId: 789660536
2025-08-01 01:31:41 -07:00
Liang Wu 9656ccc407 feat(config): add GenerateContentConfig to LlmAgentConfig
PiperOrigin-RevId: 789631181
2025-07-31 23:33:36 -07:00
Liang Wu db975dfe2a chore: prevent triggering of _load_from_yaml_config in AgentLoader
PiperOrigin-RevId: 789502695
2025-07-31 15:59:41 -07:00
Wei Sun (Jack) 0ccbf6f2f8 chore: Bump version and update CHANGELOG for v1.9.0
PiperOrigin-RevId: 789494584
2025-07-31 15:34:18 -07:00
Ankur Sharma a54c7024cf fix: Re-adding eval related changes
Due to reasons that are being investigated, some of the recent changes got unintentionally reverted. We are adding those back in this PR.

PiperOrigin-RevId: 789384063
2025-07-31 10:18:39 -07:00
Shangjie Chen 1cfe6e9ffe chore: Remove unnecessary flags
PiperOrigin-RevId: 789379877
2025-07-31 10:07:39 -07:00
Shangjie Chen 314d6a4f95 fix: Return session state in list_session API endpoint
Resolves https://github.com/google/adk-python/issues/2193
Resolves https://github.com/google/adk-python/issues/781

PiperOrigin-RevId: 789143973
2025-07-30 19:53:46 -07:00
Alejandro Cruzado-Ruiz 247fd2066c chore: replace module import for BaseAgent in local_eval_service
PiperOrigin-RevId: 789136339
2025-07-30 19:19:17 -07:00
Shangjie Chen 7d06fb735e chore: Move create_session log to where the session is actually created
PiperOrigin-RevId: 789094066
2025-07-30 16:46:25 -07:00
Liang Wu d5dcef2cf0 fix(config): forbid extra fields in AgentToolConfig
PiperOrigin-RevId: 789038376
2025-07-30 14:13:48 -07:00
Xuan Yang 6191412b07 fix: keep existing header values while merging tracking headers for llm_request.config.http_options in Gemini.generate_content_async
PiperOrigin-RevId: 789013693
2025-07-30 13:09:56 -07:00
Xuan Yang 3be1bb37d9 fix: use pull_request_target event as the trigger of PR triaging agent
GitHub workflows triggered by `pull_request` events from forked repositories do not have access to secrets by default due to security considerations.

PiperOrigin-RevId: 789011890
2025-07-30 13:05:15 -07:00
Google Team Member 7c9b0a2567 feat: add chat first-party tool
This tool answers questions about structured data in BigQuery using natural language.

PiperOrigin-RevId: 789000987
2025-07-30 12:35:20 -07:00
Liang Wu 0c6086cb15 chore: remove redundant definition for adk deploy gke command
PiperOrigin-RevId: 788758843
2025-07-29 22:47:56 -07:00
hsuyuming 9db5d9a3e8 fix: Unable to acquire impersonated credentials
Merge https://github.com/google/adk-python/pull/2003

add scope "https://www.googleapis.com/auth/cloud-platform" within google.auth.default

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2003 from hsuyuming:fix/issue_2001_support_impersonated_credential 8874a367273aca98460f7f250bfc4690f883ebbe
PiperOrigin-RevId: 788656025
2025-07-29 16:42:25 -07:00
Xiang (Sean) Zhou de6ebddcd2 chore: Replace selcukg with genquan
PiperOrigin-RevId: 788590913
2025-07-29 13:48:54 -07:00
Liang Wu bcac9ba44c feat(config): add --type flag to adk create to allow starting with config
Updated the `adk create` default model version to gemini-2.5-flash.

PiperOrigin-RevId: 788589859
2025-07-29 13:45:11 -07:00
Xiang (Sean) Zhou 2f73cfde18 chore: Fix the long running test cases
The test test_token_exchange_not_supported was slow because of an incorrect monkeypatch target. The test was patching google.adk.auth.auth_handler.AUTHLIB_AVAILABLE, but the actual OAuth2 exchange logic uses a different AUTHLIB_AVAILABLE variable in google.adk.auth.exchanger.oauth2_credential_exchanger.
What was happening:
Test set auth_handler.AUTHLIB_AVAILABLE = False
AuthHandler.exchange_auth_token() called OAuth2CredentialExchanger.exchange()
But oauth2_credential_exchanger.AUTHLIB_AVAILABLE was still True
The exchanger attempted real OAuth2 token exchange with client.fetch_token()
This made actual network calls to OAuth2 endpoints, causing timeouts and delays

PiperOrigin-RevId: 788576949
2025-07-29 13:14:28 -07:00
Xuan Yang ec8dd5721a fix: merge tracking headers even when llm_request.config.http_options is not set in Gemini.generate_content_async
PiperOrigin-RevId: 788568620
2025-07-29 12:52:32 -07:00
Xuan Yang 646eb42533 chore: add Github workflow config for the ADK PR triaging agent
PiperOrigin-RevId: 788519884
2025-07-29 10:49:35 -07:00
Google Team Member bf72426af2 fix: runner was expecting Event object instead of Content object when using early exist feature
PiperOrigin-RevId: 788516645
2025-07-29 10:41:19 -07:00
Holt Skinner 9c0721beaa fix: Update agent_card_builder to follow grammar rules
Merge https://github.com/google/adk-python/pull/2226

Fixes #2223

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2226 from holtskinner:a2a-fixes ff556224e4071a8287a9ced19f645f0edd9916ef
PiperOrigin-RevId: 788512608
2025-07-29 10:32:32 -07:00
Xuan Yang 5eff66a132 chore: create an initial prototype agent to triage pull requests
This agent will post a comment if the PR is not following our contribution guides or add a label and reviewer for the PR if it passes the guide check.

PiperOrigin-RevId: 788511767
2025-07-29 10:29:35 -07:00
Google Team Member 282d67f253 fix: import cli's artifact dependencies directly
PiperOrigin-RevId: 788488501
2025-07-29 09:34:19 -07:00
Xiang (Sean) Zhou 3432b22172 fix: Copy the original function call args before passing it to callback or tools to avoid being modified
PiperOrigin-RevId: 788462897
2025-07-29 08:20:48 -07:00
Yifan Wang af35e2673f chore: WIP endpoint
PiperOrigin-RevId: 788232652
2025-07-28 18:06:03 -07:00
Xuan Yang f68d4d5cd0 chore: add the missing license header for a2a/__init__.py
PiperOrigin-RevId: 788227196
2025-07-28 17:50:26 -07:00
Google Team Member 16e8419e32 fix: restore bigquery sample agent to runnable form
A previous change of import paths had rendered the agent not-runnable out of the box. This change fixes that.

PiperOrigin-RevId: 788221276
2025-07-28 17:31:50 -07:00
Xiang (Sean) Zhou 0c855877c5 docs: Update documents about the information of viber coding
PiperOrigin-RevId: 788217734
2025-07-28 17:18:53 -07:00
Yeesian Ng f29ab5db05 feat: Respect the .ae_ignore file when deploying to agent engine
PiperOrigin-RevId: 788052720
2025-07-28 10:01:54 -07:00
Liang Wu f1889ae440 feat(config): support ADK built-in and custom tools in config
PiperOrigin-RevId: 787735915
2025-07-27 11:14:04 -07:00
Ankur Sharma c69dcf8779 feat: Added an Fast API new endpoint to serve eval metric info
This endpoint could be used by ADK Web to dynamically know:
- What are the available eval metrics in an App
- A description of those metrics
- A value range supported by those metrics

We also update the metric registry to make it mandatory to supply these details. The goal is to improve usability and interpretability of the eval metrics.

PiperOrigin-RevId: 787277695
2025-07-25 16:25:20 -07:00
Wei Sun (Jack) ec7d9b0ff6 chore(config): Moves agent configs to separate python files
PiperOrigin-RevId: 787245794
2025-07-25 14:40:49 -07:00
Yeesian Ng 6419a2aa9b fix: Switch from agent_engine_name to agent_engine_id for updating instances
PiperOrigin-RevId: 787179405
2025-07-25 11:24:10 -07:00
Yifan Wang b83b0a6eec chore: experiment endpoint
PiperOrigin-RevId: 787164869
2025-07-25 10:44:09 -07:00
Wei Sun (Jack) a3ff21eb0b feat(config): Adds CustomAgentConfig to support user-defined agents in config
PiperOrigin-RevId: 787148485
2025-07-25 09:56:10 -07:00
qieqieplus 1778490e64 fix: Fix unsafe_local_code_executor for import scope
Merge https://github.com/google/adk-python/pull/869

How to reproduce the error:

```
from google.adk.code_executors import UnsafeLocalCodeExecutor
from google.adk.code_executors.code_execution_utils import CodeExecutionInput

result = UnsafeLocalCodeExecutor().execute_code(
    invocation_context=None,
    code_execution_input=CodeExecutionInput(
        code='''
import math

def pi():
    return math.pi

print(pi())
'''
    )
)

print(result)
```

output:
```
CodeExecutionResult(stdout='', stderr="name 'math' is not defined", output_files=[])
```
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/869 from qieqieplus:main 63f557bbd3b7aa5c2801f5cc9e022d3364177308
PiperOrigin-RevId: 787145189
2025-07-25 09:45:34 -07:00
Vicente Ferrara a858d79b3a feat: cli funcionality to deploy an Agent to a running GKE cluster
Merge https://github.com/google/adk-python/pull/1607

- Added CLI functionality so that we can deploy and Agent onto a GKE cluster
- Related documentation https://github.com/google/adk-docs/pull/445

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/1607 from vicentefb:GkeDeployAgent 42f35d93b0a5df5f6dbeb9ee7f869cde51e2f6eb
PiperOrigin-RevId: 786857789
2025-07-24 15:32:23 -07:00
Lam Nguyen c8f8b4a20a fix: Fix incorrect token count mapping in telemetry
Merge https://github.com/google/adk-python/pull/2109

Fixes #2105

## Problem
  When integrating Google ADK with Langfuse using the @observe
  decorator, the usage details displayed in Langfuse web UI were
  incorrect.

  The root cause was in the telemetry implementation where
  total_token_count was being mapped to gen_ai.usage.output_tokens
  instead of candidates_token_count.

  - Expected mapping:
    - candidates_token_count → completion_tokens (output tokens)
    - prompt_token_count → prompt_tokens (input tokens)

  - Previous incorrect mapping:
    - total_token_count → completion_tokens (wrong!)
    - prompt_token_count → prompt_tokens (correct)

  ## Solution
  Updated trace_call_llm function in telemetry.py to use
  candidates_token_count for output token tracking instead of
  total_token_count, ensuring proper token count reporting to
  observability tools like Langfuse.

  ## Testing plan
  - Updated test expectations in test_telemetry.py
  - Verified telemetry tests pass
  - Manual verification with Langfuse integration

  ## Screenshots
  **Before**

<img width="1187" height="329" alt="Screenshot from 2025-07-22 20-20-33" src="https://github.com/user-attachments/assets/ad5fc957-64a2-4524-bd31-0cebb15a5270" />

  **After**

<img width="1187" height="329" alt="Screenshot from 2025-07-22 20-21-40" src="https://github.com/user-attachments/assets/3920df2a-be75-47e0-9bd0-f961bb72c838" />

 _Notes_: From the screenshot, there's another problem: thoughts_token_count field is not mapped, but this should be another issue imo

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2109 from tl-nguyen:fix-telemetry-token-count-mapping 3d043f558b5f8bcb2c6e0370e2cc4c0ff25d1f4a
PiperOrigin-RevId: 786827802
2025-07-24 14:01:03 -07:00
Shangjie Chen 11037fc133 chore: Filter event with only functions, thought_signatures when adding to memory
PiperOrigin-RevId: 786825628
2025-07-24 13:54:37 -07:00
Yeesian Ng 206a13271e feat: Add a CLI option to update an agent engine instance
PiperOrigin-RevId: 786816663
2025-07-24 13:27:49 -07:00
Xuan Yang 3be0882c63 feat: add -v, --verbose flag to enable DEBUG logging as a shortcut for --log_level DEBUG
PiperOrigin-RevId: 786797394
2025-07-24 12:30:30 -07:00
Alejandro Cruzado-Ruiz e176f03e8f feat: modularize fast_api.py to allow simpler construction of API Server
PiperOrigin-RevId: 786763344
2025-07-24 10:53:13 -07:00
Kavin Kumar B 7206e0a0eb fix: eval module not found exception string
Merge https://github.com/google/adk-python/pull/2148

This PR fixes #2071 exception string from `pip install google-adk[eval]` to `pip install "google-adk[eval]"` which makes it compatible for all the bash, zsh and other terminals

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2148 from kavinkumar807:fix-module-not-found-exception-string-in-eval 914281006a0e162665c0933d0c0ee0c37eb397cf
PiperOrigin-RevId: 786752261
2025-07-24 10:23:03 -07:00
Yeesian Ng fbe6a7b8d3 fix: Add absolutize_imports option when deploying to agent engine
PiperOrigin-RevId: 786749263
2025-07-24 10:15:35 -07:00
Google Team Member bfc203a92f feat: modularize fast_api.py to allow simpler construction of API Server
PiperOrigin-RevId: 786646546
2025-07-24 04:03:19 -07:00
Hangfei Lin 5e8aa15a50 feat: add support for session resumption(only transparent mode) config to run_config
This commit adds support for the session resumption configuration in the run_config.
The SessionResumptionConfig is added to RunConfig to allow the user to set up a configuration for session resumption(only transparent mode for now).

There are two modes of session resumption: manual and transparent. In manual mode, you have to manually bookkeeping the session information and restarts the session which is tricky to do right now. In transparent mode, the server does the bookkeeping for you and no hassle on ADK side. For now, the transparent mode should be enough.

Also, added the relevant unit tests to check that every possible configuration is set properly and the run_config is correctly populated.
This is needed for supporting the new session resumption feature.

PiperOrigin-RevId: 786549455
2025-07-23 21:37:00 -07:00
Che Liu 16392984c5 feat: Expose Gemini RetryOptions to client
google.genai SDK has introduced a new retry_options. This change exposes this configuration
to ADK users

Usage:

```python
root_agent = Agent(
    model=Gemini(
        model='gemini-2.0-flash',
        retry_options=types.HttpRetryOptions(
	    initial_delay=1,
	    attempts=2
	    # ... Retry options from google.genai
	),
	# ...
    ),
```
PiperOrigin-RevId: 786472564
2025-07-23 16:50:09 -07:00
Che Liu 20537e8bfa feat: Add sample plugin for logging
This plugin helps printing all critical events in the console. It is not a replacement
of existing logging in ADK. It rather helps terminal based debugging by showing all logs in the console, and serves as a
simple demo so everyone could develop their own plugins.

PiperOrigin-RevId: 786470637
2025-07-23 16:43:32 -07:00
Che Liu 00afaaf2fc feat: add new callbacks to handle tool and model errors
This CL add new callbacks in plugin system:
- `on_tool_error_callback`
- `on_model_error_callback`

This allow the user to create plugins that can handle errors.

PiperOrigin-RevId: 786469646
2025-07-23 16:40:09 -07:00
Alejandro Cruzado-Ruiz dfc25c17a9 feat: modularize fast_api.py to allow simpler construction of API Server
PiperOrigin-RevId: 786467758
2025-07-23 16:33:54 -07:00
Ariz Chang 32ae882a49 feat: Add camel case converter for agents
PiperOrigin-RevId: 786465205
2025-07-23 16:27:03 -07:00
Ankur Sharma 884c201958 chore: Release 1.8.0
PiperOrigin-RevId: 786462899
2025-07-23 16:19:49 -07:00
Andrew Larimer 70c461686e fix: add space to allow adk deploy cloud_run --a2a
Merge https://github.com/google/adk-python/pull/2138

This missing space leads to an error when deploying to cloud_run that says "No option --a2a/apps/agents"

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2138 from andrewlarimer:fix--add-space-to-allow-adk-deploy-cloud_run---a2a 47831f10e1f7f6c27b5f6b8c102b2f7db4619778
PiperOrigin-RevId: 786459787
2025-07-23 16:09:49 -07:00
Ankur Sharma 1355bd643b feat: Refactored AgentEvaluator and updated it to use LocalEvalService
With this change we ensure that all three eval entry points, web, cli and pytest use the common LocalEvalService.

Updates to web and cli happened in a previous change.

PiperOrigin-RevId: 786445632
2025-07-23 15:27:26 -07:00
Xiang (Sean) Zhou 927c75f0ee chore: Replace imports by importing from actual module instead of from package (__init__.py)
PiperOrigin-RevId: 786342250
2025-07-23 10:49:43 -07:00
Xiang (Sean) Zhou 430b82024f chore: Fixed flaky test_update_credential_with_tokens unittest
PiperOrigin-RevId: 786340983
2025-07-23 10:45:01 -07:00
Xiang (Sean) Zhou 70266abfc2 chore: fix UT failures of test_google_llm.py
Mainly it's due to GenAI sdk changed their header of genai SDK versions, we have UT to verify that ADK or ADK users won't override their headers. Updated the header accordingly in the UT.

PiperOrigin-RevId: 786334741
2025-07-23 10:31:16 -07:00
Holt Skinner a911469616 chore: Update a2a-sdk to 0.2.16
Convert a2a types to use snake_case fields

https://github.com/a2aproject/a2a-python/releases/tag/v0.2.16

PiperOrigin-RevId: 786279179
2025-07-23 07:54:03 -07:00
Michael Timblin ce7253f63f fix: Use correct type for actions parameter in ApplicationIntegrationToolset
Merge https://github.com/google/adk-python/pull/2102

Addresses https://github.com/google/adk-python/issues/2101

I've ran `pytest ./tests/unittests`, and all tests passed

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2102 from manifoldtimblin:fix-type-hint 6d4ab724ff07688158d3d121a78b2c00493a26a7
PiperOrigin-RevId: 786046567
2025-07-22 16:49:45 -07:00
Alejandro Cruzado-Ruiz bda3df2480 feat: Refactor AgentLoader into base class and add InMemory impl alongside existing filesystem impl
PiperOrigin-RevId: 786008518
2025-07-22 14:58:32 -07:00
Ankur Sharma 4ae4c69c32 fix: ModuleNotFound error should be caught when dependencies of LocalEvalService are not installed
Once caught we publish the clarifying message to install the extra.

PiperOrigin-RevId: 785999033
2025-07-22 14:32:02 -07:00
Xiang (Sean) Zhou 32df937ebc chore: Update docstring for is_final_response method
PiperOrigin-RevId: 785983329
2025-07-22 13:50:30 -07:00
Yifan Wang 702e9bf556 chore: update adk web
PiperOrigin-RevId: 785972516
2025-07-22 13:22:34 -07:00
Ankur Sharma ff31f57dc9 fix: Move some API request and responses to DEBUG logging level
Please set --log_level to DEBUG, if you are interested in having those API request and responses in logs.

NOTE: Generally it is not recommended to have DEBUG log level for services that run in a production setting. It is our recommendation to only use DEBUG log level in a debug or development setting.
PiperOrigin-RevId: 785972338
2025-07-22 13:22:18 -07:00
Max Thormé d4f01afc15 fix(comment): fix comment to malicious user cannot obtain another user’s session
Merge https://github.com/google/adk-python/pull/1959

### What

Fix misleading comment.

```diff
- # Make sure a malicious user can obtain a session and events not belonging to them
+ # Make sure a malicious user **cannot** obtain a session or events not belonging to them
```

### Why

The previous wording contradicted the assertion `assert len(session_mismatch.events) == 0`, which verifies that a malicious user **cannot** access another user’s session or events.

### Testing plan

Docs-only change.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/1959 from mthorme:fix-comment-session-mismatch b1f139af340bd240d40ed58f5dea3274c3a3bd83
PiperOrigin-RevId: 785908548
2025-07-22 10:33:57 -07:00
Shangjie Chen f46396fa98 chore: Allow httpoptions override in VertexAiSessionService
PiperOrigin-RevId: 785886180
2025-07-22 09:36:17 -07:00
Google Team Member 13ff009d34 fix: Handle non-json-serializable values in the execute_sql tool
This change takes cares of SQL results containing values that are not json serializable (e.g. datetime, bignumeric) by converting them to their string representation.

PiperOrigin-RevId: 785719997
2025-07-21 23:17:06 -07:00
Jacky Wu 6cc3d9ddd1 chore: follow-up #946 to allow session db kwargs in fast api entrance
Merge https://github.com/google/adk-python/pull/1042

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/1042 from Colstuwjx:chore/expose-database-args-in-fastapi 83a20cf400a8a712c57cb3574fdd654ab5d8d4d6
PiperOrigin-RevId: 785714547
2025-07-21 22:52:20 -07:00
Xiang (Sean) Zhou 083dcb4465 feat: Add ComputerUseToolset
PiperOrigin-RevId: 785646071
2025-07-21 18:08:35 -07:00
Xiang (Sean) Zhou b2c2f1bd33 chore: Add an a2a sample agent to demo running the a2a server via unvicorn command and run remote agent as root_agent
PiperOrigin-RevId: 785629271
2025-07-21 17:08:35 -07:00
Xiang (Sean) Zhou a77d68964a feat: Add an to_a2a util to convert adk agent to A2A ASGI application
Users can do :
```
a2a_app = to_a2a(root_agent)
```
then use below command to start a2a server:
```
uvicorn user_module:a2a_app --host localhost --port 8000
```

PiperOrigin-RevId: 785625048
2025-07-21 16:54:53 -07:00
Ankur Sharma d1f182e8e6 feat: Use LocalEvalService to run all evals in cli and web
We update both adk web run eval endpoint and adk eval cli to use the LocalService. The old method is marked as deprecated and will be removed in later PRs.

PiperOrigin-RevId: 785612708
2025-07-21 16:15:11 -07:00
Ariz Chang 0e173d7363 feat: Add camel case converter for agents
PiperOrigin-RevId: 785602954
2025-07-21 15:45:24 -07:00
Xiang (Sean) Zhou 18f5bea411 feat: Add agent card builder
PiperOrigin-RevId: 785565665
2025-07-21 13:59:02 -07:00
Jianfeng Zeng f2caf2eeca fix: Add buffer to the write file option
PiperOrigin-RevId: 785546915
2025-07-21 13:08:29 -07:00
Liang Wu dfee06ac06 feat(config): support input/output schema by fully-qualified code reference
PiperOrigin-RevId: 785541326
2025-07-21 12:53:13 -07:00
Wei Sun (Jack) 2aab1cf98e fix: allows current sub-agent to finish execution before exiting the loop agent due to a sub-agent's escalation. This commit also disables the summarization for exit_loop tool
Fixes #423

Related to #1670

- This avoids the `GeneratorExit` error thrown, which would crash OTel metric collection and cause `Failed to detach context` error.
- This also allows all function  calls are processed when exit_loop is called together with other tools in the same LLmResponse.

A sample agent for testing:

```
from google.adk import Agent
from google.adk.agents.loop_agent import LoopAgent
from google.adk.tools.exit_loop_tool import exit_loop

worker_1 = Agent(
    name='worker_1',
    description='Worker 1',
    instruction="""\
Just say job #1 is done.

If job #1 is said to be done. Call exit_loop tool.""",
    tools=[exit_loop],
)

worker_2 = Agent(
    name='worker_2',
    description='Worker 2',
    instruction="""\
Just say job #2 is done.

If job #2 is said to be done. Call exit_loop tool.""",
    tools=[exit_loop],
)

work_agent = LoopAgent(
    name='work_agent',
    description='Do all work.',
    sub_agents=[worker_1, worker_2],
    max_iterations=5,
)

root_agent = Agent(
    model='gemini-2.0-flash',
    name='hello_world_agent',
    description='hello world agent that can roll a  check prime',
    instruction="""Hand off works to sub agents.""",
    sub_agents=[work_agent],
)
```
PiperOrigin-RevId: 785538101
2025-07-21 12:43:19 -07:00
Xuan Yang 96a0d4b02c chore: undo the workaround which bypassed the setup-uv bug
Bug https://github.com/astral-sh/setup-uv/issues/489 has been fixed.

PiperOrigin-RevId: 785529944
2025-07-21 12:20:02 -07:00
Ankur Sharma 65cb6d6bf3 fix: Check that mean_score is a valid float value
In some cases, Vertex AI evaluation returns nan values for the metrics. That was not handled correctly.

PiperOrigin-RevId: 785514456
2025-07-21 11:36:55 -07:00
Ankur Sharma fc85348f91 fix: add utf-8 encoding to file based reads and writes of eval data
This will help manage encoding consistency between reads and writes.

PiperOrigin-RevId: 785503746
2025-07-21 11:09:45 -07:00
Xiang (Sean) Zhou 9467720919 chore: Remove unused import from hello world sample agent
PiperOrigin-RevId: 785501232
2025-07-21 11:03:03 -07:00
Xiang (Sean) Zhou ee3918e34e chore: Update the error message when A2A is not supported for the installed python version
PiperOrigin-RevId: 785490858
2025-07-21 10:37:33 -07:00
Vasilii Novikov 81e0d4083f feat: make GCS artifact service async under the hood
Merge https://github.com/google/adk-python/pull/1347

Fixes issue https://github.com/google/adk-python/issues/1346

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/1347 from condorcet:async_gcs_artifact_storage 3efee5a923b08af606aa5525e31816e0bc7b865d
PiperOrigin-RevId: 785488472
2025-07-21 10:31:41 -07:00
Dana K. Williams 2486349268 docs: Fix missing toolbox-core dependency and improve installation guide
Merge https://github.com/google/adk-python/pull/1195

## Summary
Updated the Toolbox Agent documentation to address a critical missing dependency that prevents the agent from running successfully.

## Changes Made
- **Added missing dependency**: Documented that `toolbox-core` must be installed via `pip install toolbox-core`
- **Improved documentation structure**: Added clear section numbering and better organization
- **Enhanced readability**: Fixed grammar, capitalization, and formatting throughout
- **Added Prerequisites section**: Set clear expectations before installation begins
- **Clarified optional steps**: Made it clearer when database creation can be skipped

## Problem Solved
The original documentation was missing a crucial step - installing the `toolbox-core` package. Without this dependency, users encounter an `ImportError: No module named 'toolbox-core'` when trying to use the `ToolboxToolset` class in ADK. This fix ensures users can successfully set up and run the agent without encountering import errors.

## Testing
- Verified the installation steps work correctly with the added dependency
- Confirmed the agent runs successfully after following the updated documentation

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/1195 from designcomputer:patch-1 b90c71fe95aa09a3dca069e91f14791f557ab2e3
PiperOrigin-RevId: 785487495
2025-07-21 10:29:33 -07:00
Xiang (Sean) Zhou 3643b4ae19 feat: Allow toolset to process llm_request before tools returned by it
PiperOrigin-RevId: 785480813
2025-07-21 10:11:40 -07:00
Xiang (Sean) Zhou cec400ada3 chore: Autoformat history_management agent codes
PiperOrigin-RevId: 785003632
2025-07-19 17:51:54 -07:00
Google Team Member d2461ecccb refactor: only import some module when needed and add follow_symlink=True when serve static files
PiperOrigin-RevId: 784956132
2025-07-19 12:54:05 -07:00
Calvin Giles ffe2bdbe4c feat: Add support for vertex gemini model optimizer
Merge https://github.com/google/adk-python/pull/1130

This enables the use of the `model-optimizer-*` family of models in vertex, as per the [documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/vertex-ai-model-optimizer#using-vertex-ai-model-optimizer).

To use this, ensure your location is set to `global` and pass a model optimizer model to an agent:

```python
root_agent = Agent(
    model="model-optimizer-exp-04-09",
    name="fast_and_slow_agent",
    instruction="Answer any question the user gives you - easy or hard.",
    generate_content_config=types.GenerateContentConfig(
        temperature=0.01,
        model_selection_config=ModelSelectionConfig(
            feature_selection_preference=FeatureSelectionPreference.BALANCED
            # Options: PRIORITIZE_QUALITY, BALANCED, PRIORITIZE_COST
        )
    ),
)
```
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/1130 from calvingiles:feat-model-optimizer 1a76bfa22420edb07d83415dcea6dd0114084e8e
PiperOrigin-RevId: 784921913
2025-07-19 09:05:17 -07:00
Calvin Giles 67284fc466 feat: History Management Sample
Merge https://github.com/google/adk-python/pull/891

This creates a sample relating to discussion #826 - how to manage context windows.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/891 from calvingiles:history-management-sample 2827817bea8d96ea0eee7e3ba84c14bd1fe4286d
PiperOrigin-RevId: 784920438
2025-07-19 08:57:11 -07:00
Hangfei Lin 0ec69d05a4 feat: Enhance LangchainTool to accept more forms of functions
Now the LangchainTool can wrap:

* Langchain StructuredTool (sync and async).
* Langchain @Tool (sync and async).

This enhance the flexibility for user and enables async functionalities.

PiperOrigin-RevId: 784728061
2025-07-18 15:56:17 -07:00
Hangfei Lin f1e0bc0b18 chore: remove pr-commit-check
With this mode, the PR commit can be squashed before copybara. So we can delete the pr-commit-check.yml.

PiperOrigin-RevId: 784665025
2025-07-18 12:26:46 -07:00
Liang Wu 5edc493da9 chore: allow "from google.adk.tools import AgentTool"
PiperOrigin-RevId: 784606041
2025-07-18 09:30:40 -07:00
Copybara-Service 3568c9291d Merge pull request #547 from jeffreyrubi:fix/missing-path-level-parameters
PiperOrigin-RevId: 784415343
2025-07-17 20:27:46 -07:00
Copybara-Service d0a330cd15 Merge pull request #2020 from thiagosalvatore:main
PiperOrigin-RevId: 784393522
2025-07-17 18:50:46 -07:00
seanzhou1023 637fa410d8 Merge branch 'main' into main 2025-07-17 18:23:32 -07:00
Sean Zhou 6f016609e8 fix: support path level parameters for open_api_spec_parser
autoformat the changes
2025-07-17 18:09:40 -07:00
Hangfei Lin bb1b1c695f Merge branch 'main' into fix/missing-path-level-parameters 2025-07-17 17:46:27 -07:00
Wei Sun (Jack) bb4ff2cc3d chore: fixes formatting in adk_project_overview_and_architecture.md
PiperOrigin-RevId: 784371131
2025-07-17 17:21:14 -07:00
Wei Sun (Jack) b1f4aebb25 chore: lint fixings in vertex_ai_memory_bank.py
* Adds type hints;
* Switches to lazy evaluation in logs.

PiperOrigin-RevId: 784353566
2025-07-17 16:21:49 -07:00
Shangjie Chen 2e778049d0 feat: Support passing fully qualified agent engine resource name when constructing session service and memory service
Resolves https://github.com/google/adk-python/issues/1760

PiperOrigin-RevId: 784353411
2025-07-17 16:19:55 -07:00
Ankur Sharma 36e45cdab3 feat: Enable FinalResponseMatchV2 metric as an experiment
PiperOrigin-RevId: 784346859
2025-07-17 15:59:47 -07:00
Xuan Yang 35de210d4e chore: add a script to upload ADK docs for the ADK Answering Agent
PiperOrigin-RevId: 784343501
2025-07-17 15:49:44 -07:00
Xuan Yang bbe1c9dc66 fix: specify version into the uv installation action to bypass the setup-uv bug
https://github.com/astral-sh/setup-uv/issues/489

PiperOrigin-RevId: 784339143
2025-07-17 15:35:15 -07:00
Thiago Salvatore 9ad4350c88 Merge branch 'main' of github.com:thiagosalvatore/adk-python 2025-07-17 18:21:59 -03:00
Thiago Salvatore 2f8bb91e6b add docstring 2025-07-17 18:21:40 -03:00
Thiago Salvatore 3f01c8c999 Merge branch 'main' into main 2025-07-17 18:20:37 -03:00
Thiago Salvatore b5850e0757 reformat file structure 2025-07-17 18:17:09 -03:00
Thiago Salvatore 53df35ee58 fix(schema to dict): fix serialization of tools with nested schema 2025-07-17 18:16:17 -03:00
Xuan Yang 6e68c2d7f3 chore: update ADK Triage Agent to set issue type
It will change bug report to "Bug" type and feature request to "Feature" type.

PiperOrigin-RevId: 784280674
2025-07-17 12:51:41 -07:00
Xuan Yang 8ada46a18e chore: remove the redundant service.bucket setting in mock_gcs_artifact_service
PiperOrigin-RevId: 784253138
2025-07-17 11:29:32 -07:00
Xuan Yang 1c4c887bec fix: use the same word extractor for query and event contents in InMemoryMemoryService
PiperOrigin-RevId: 784236637
2025-07-17 10:43:01 -07:00
Xuan Yang 78697aa6af chore: add to_session method in StorageSession for readability
PiperOrigin-RevId: 784232578
2025-07-17 10:32:18 -07:00
Ankur Sharma b17d8b6e36 fix: Raise NotFoundError in list_eval_sets function when app_name doesn't exist
PiperOrigin-RevId: 784216832
2025-07-17 09:53:26 -07:00
Xiang (Sean) Zhou 377b5a9b78 fix: Add response schema for agent tool function declaration even when it's return None
PiperOrigin-RevId: 784216811
2025-07-17 09:51:34 -07:00
Xiang (Sean) Zhou 33ac8380ad fix: Set response schema for function that returns None
PiperOrigin-RevId: 784053725
2025-07-16 23:59:45 -07:00
Jianfeng Zeng 31fa5d91bd feat: Update builder/save endpoint to accept files as input. Write the agent yaml file to the agent folder
PiperOrigin-RevId: 783963934
2025-07-16 17:55:55 -07:00
Xuan Yang b705b35977 fix: update documentation owner's Github username for the ADK Triage Agent
PiperOrigin-RevId: 783951115
2025-07-16 17:10:25 -07:00
Shangjie Chen eccb484985 chore: Update label name for bot triaged issues
Also assign agent engine related issue to yeesian as poc

PiperOrigin-RevId: 783941809
2025-07-16 16:39:25 -07:00
Yifan Wang 2f6ab08580 chore: Release 1.7.0
PiperOrigin-RevId: 783918022
2025-07-16 15:29:19 -07:00
Hangfei Lin 7415f2c094 feat: Add tool callback chaining support for live streaming
**Highlights:**

-   **Callback Chaining:** Now supports a list of before and after callbacks, as in the non-live version. Callbacks are executed in order, stopping when one returns a response.
-   **Unit Tests:** Added new unit tests for before and after callbacks, async and sync versions, callback chains and mixed callbacks.
-   **Sample Agent:** Introduced a new example agent with multiple callbacks showing various behaviors: audit, security, validation, and enhancement. This provides practical usage examples.

PiperOrigin-RevId: 783884562
2025-07-16 13:56:06 -07:00
Hangfei Lin 6071b34650 feat: Implement Activity Start and End signals in LiveRequestQueue and BaseLLMConnection
This change adds activity start and end signals to the LiveRequestQueue,
allowing clients to manually control the start and end of user input in
streaming sessions when automatic voice activity detection is disabled.

The LiveRequestQueue allows users to send messages to the model with the following semantics:
- `content`: sends turn-by-turn content.
- `blob`: sends a media blob for realtime streaming (e.g., audio).
- `activity_start`: indicates the beginning of an activity.
- `activity_end`: indicates the end of an activity.
- `close`: closes the connection.

GeminiLLMConnection has been updated to send the new activity signals to the backend.

This change is a necessary to support clients (e.g. voice assistants) that do not want to use automatic voice activity detection. In this case, the client will be responsible to send the `activity_start` signal when the user starts talking, and `activity_end` when the user finishes talking.

To test the change:
    run_config = RunConfig(
        realtime_input_config=types.RealtimeInputConfig(
            automatic_activity_detection=types.AutomaticActivityDetection(
                disabled=True,
            ),
        )
    )

    import threading  # Add this import

    def thread_target():
      # Define the async operations to run in the background.
      async def background_task():
        live_request_queue.send_activity_start()

        # live_request_queue.send_content(
        #     content=types.Content(
        #         role='user',
        #         parts=[types.Part.from_text(text="hi, what's the time?")],
        #     )
        # )

        await asyncio.sleep(3)
        live_request_queue.send_activity_end()

PiperOrigin-RevId: 783882447
2025-07-16 13:51:04 -07:00
Google Team Member b89aac9eb3 ADK changes
PiperOrigin-RevId: 783804355
2025-07-16 10:17:19 -07:00
Google Team Member 3f9f773d9b feat: Add ability to send state change with message
PiperOrigin-RevId: 783589708
2025-07-15 21:17:04 -07:00
Yifan Wang 7e8762896e chore: update adk-web
PiperOrigin-RevId: 783527209
2025-07-15 17:14:19 -07:00
Ariz Chang a4cbbf3e81 feat: Add ability to send state change with message
PiperOrigin-RevId: 783516738
2025-07-15 16:37:26 -07:00
Xiang (Sean) Zhou b977d12ea8 refactor: Add save_credential and load_credential in callback context for developer to access credential service
developer may want to save/load credentials themselves to/from credential service. see (https://github.com/google/adk-python/issues/1816)

PiperOrigin-RevId: 783487628
2025-07-15 15:09:19 -07:00
Xiang (Sean) Zhou b1fa383e73 docs: Update agent transfer related doc string and comments
This is to address https://github.com/google/adk-python/issues/1907

PiperOrigin-RevId: 783481177
2025-07-15 14:50:33 -07:00
Xiang (Sean) Zhou 1a75848391 refactor: Use CallbackContext in credential service for saving/loading credential
1. credential service may be accessed by callbacks
2. plan to add load_credential and save_credential method in CallbackContext (see cl/782158513) given customer has requirement to access credential service themselves. (see https://github.com/google/adk-python/issues/1816)

It's backward compatible given CallbackContext is parent class of ToolContext

PiperOrigin-RevId: 783480378
2025-07-15 14:48:38 -07:00
Xiang (Sean) Zhou bf7745f428 fix: Create correct object for image and video content in litellm
PiperOrigin-RevId: 783478779
2025-07-15 14:44:14 -07:00
Hangfei Lin c2058f3779 chore: adk Add more documentations for ADK live feature in ADK.md
Also added commit message guidelines.

PiperOrigin-RevId: 783450329
2025-07-15 13:27:38 -07:00
Alejandro Cruzado-Ruiz 94dc03761e fix: return empty list in place of raising FileNotFoundError when there are no eval sets
PiperOrigin-RevId: 783439932
2025-07-15 12:56:38 -07:00
Liang Wu 41f1888116 feat(config): support callbacks in BaseAgent and LlmAgent
PiperOrigin-RevId: 783422160
2025-07-15 12:05:10 -07:00
Xiang (Sean) Zhou 3c6e18fd1c fix: Don't set error_code and error_message when model stop response in normal case
PiperOrigin-RevId: 783415488
2025-07-15 11:47:53 -07:00
Liang Wu ce037ec888 feat(config): support built-in tools and referencing tools in code
PiperOrigin-RevId: 783415273
2025-07-15 11:46:04 -07:00
Copybara-Service 391cf3f320 Merge pull request #1669 from zshehov:use-starred-tuple-unpacking-on-gcs-artifact-blob-names-versions
PiperOrigin-RevId: 783413576
2025-07-15 11:43:14 -07:00
Xiang (Sean) Zhou a5d6f1e52e fix: Support project-based gemini model path for BuiltInCodeExecutor and all built-in tools
This is to support model path like :
projects/265104255505/locations/us-central1/publishers/google/models/gemini-2.0-flash-001"

PiperOrigin-RevId: 783413351
2025-07-15 11:41:37 -07:00
Xiang (Sean) Zhou 30d7b37069 refactor: Move list_artifacts from tool_context to callback_context
1. users may want to list_artifacts in callbacks
2. save/load artifacts are already in callback_context

PiperOrigin-RevId: 783399941
2025-07-15 11:08:17 -07:00
Copybara-Service 57043d3e7d Merge pull request #1955 from iwknow:func_fix
PiperOrigin-RevId: 783391431
2025-07-15 10:47:16 -07:00
Zdravko Shehov 4a2589a090 fix: Use starred tuple unpacking on GCS artifact blob names for versions function 2025-07-15 11:47:18 +03:00
Ankur Sharma c25911c912 feat: Implement in memory EvalSetsManager
This version of the EvalSetsManager is intended to support two main behaviors

1) The agent developer wants to bring in their own eval set file, which is usually the case with `adk eval` cli. Once their eval sets are uploaded into this version of the eval sets manager, the EvalSetManager could be handed over to the Eval system for running evals.

2) As a part of AgentEvaluator testing, we expect developers to supply Eval cases in json files. The in-memory version of the EvalSetsManager will help us run those test cases using LocalEvalService.

PiperOrigin-RevId: 783198788
2025-07-14 23:34:35 -07:00
Google Team Member a50419961c fix: Process ListEvents response correctly when getSession is called
When get session is being called on a session with more than 1 page of events (100+), the response of the subsequent listevents calls fails due to missing parsing logic. This change fixes the processing of the listevents responses.

PiperOrigin-RevId: 783166959
2025-07-14 21:21:51 -07:00
Xiang (Sean) Zhou 498ce906dd docs: Update doc string for GcsArtifactService
PiperOrigin-RevId: 783157778
2025-07-14 20:41:16 -07:00
Xuan Yang f52df2bdb6 chore: update ADK Answering Agent to label the discussion with "bot_responded" after responding
PiperOrigin-RevId: 783109120
2025-07-14 17:47:29 -07:00
Yifan Wang 5124252c94 feat: add testing endpoint for builder
PiperOrigin-RevId: 783090278
2025-07-14 16:44:50 -07:00
Xiang (Sean) Zhou dea1ee14ab docs: Fix docstring and update module public name list for generating API references
To fix https://github.com/google/adk-docs/issues/131

PiperOrigin-RevId: 783080206
2025-07-14 16:16:57 -07:00
Frank Liu 94b5aaf0a1 fix: Correct EventAction merging logic and add corresponding tests 2025-07-14 14:54:36 -07:00
Xiang (Sean) Zhou 62a611956f fix: Add instruction in long running tool description to avoid being invoked again by model
PiperOrigin-RevId: 783039620
2025-07-14 14:18:49 -07:00
Holt Skinner a6716a5514 fix: Import A2A well known path from A2A sdk
PiperOrigin-RevId: 783036797
2025-07-14 14:11:01 -07:00
Che Liu a4baa35b84 feat: Add a sample for how to use plugins
PiperOrigin-RevId: 782616659
2025-07-13 10:47:11 -07:00
Ankur Sharma bab3be2cf3 feat: Add support for persisting eval run results
If the EvalRunResultsManager is provided to LocalEvalService, then we want to persist the eval run results using it.

PiperOrigin-RevId: 782196848
2025-07-11 19:29:32 -07:00
Ankur Sharma 33eec34577 feat: Adding implementation of evaluate method in LocalEvalService
Also, delete agent_creator.py file. We added this file by mistake.

PiperOrigin-RevId: 782193593
2025-07-11 19:15:40 -07:00
Liang Wu 48971d43d0 feat(config): support output_key and include_contents in LlmAgentConfig
PiperOrigin-RevId: 782170665
2025-07-11 17:47:42 -07:00
Liang Wu b2ef9a069e feat(config): support sub_agents in BaseAgentConfig
Currently only support path to YAML or code reference to agent instance.

PiperOrigin-RevId: 782157110
2025-07-11 16:57:53 -07:00
Xiang (Sean) Zhou 134ec0d71e fix: Fix the long running function response event merge logic
1) raise explicit error if the response event contains responses against multiple function call events
2) merge all function responses for the corresponding function call event

PiperOrigin-RevId: 782154577
2025-07-11 16:48:59 -07:00
Xiang (Sean) Zhou a8fcc1b8ab fix: Return final task result in task artifact instead of status message
According to a2a protocol task artifact is a different concept from adk artifact.
if a task is completed the final result should be in task artifact.

PiperOrigin-RevId: 782154265
2025-07-11 16:47:28 -07:00
Xiang (Sean) Zhou a57d629bb9 chore: Update the README of a2a sample agent
PiperOrigin-RevId: 782153753
2025-07-11 16:44:58 -07:00
Copybara-Service 202558fd52 Merge pull request #1829 from matino:expose_credential_service
PiperOrigin-RevId: 782150305
2025-07-11 16:34:58 -07:00
seanzhou1023 997b6a964d Merge branch 'main' into expose_credential_service 2025-07-11 15:38:27 -07:00
seanzhou1023 c6c6f34429 Update agent_tool.py 2025-07-11 15:34:07 -07:00
seanzhou1023 7de173ed90 Update test_readonly_context.py 2025-07-11 15:32:37 -07:00
seanzhou1023 080edded76 Update readonly_context.py 2025-07-11 15:31:13 -07:00
Copybara-Service 074b7bebdf Merge pull request #1855 from marcellomaugeri:main
PiperOrigin-RevId: 782121756
2025-07-11 15:04:53 -07:00
Sean Zhou 0a187b4a7d auto format the codes 2025-07-11 14:42:12 -07:00
seanzhou1023 b2a5afaa67 Merge branch 'main' into main 2025-07-11 14:40:31 -07:00
Copybara-Service b43a73bb3f Merge pull request #1602 from DavidSchmidt00:fix_graph
PiperOrigin-RevId: 782090252
2025-07-11 13:27:57 -07:00
Sean Zhou 8acfcfeb5d auto format codes 2025-07-11 13:14:33 -07:00
seanzhou1023 274e375e6f Merge branch 'main' into fix_graph 2025-07-11 12:55:24 -07:00
Copybara-Service 0a65b528e3 Merge pull request #1866 from hironow:hironow/type-fix-for-static
PiperOrigin-RevId: 782040553
2025-07-11 11:02:03 -07:00
Copybara-Service 0a9e67dbca Merge pull request #1875 from bih:patch-1
PiperOrigin-RevId: 781815489
2025-07-10 21:32:19 -07:00
Copybara-Service 4ba0f0a8de Merge pull request #120 from soundTricker:feature/80-sa-auth-for-google-tool
PiperOrigin-RevId: 781815460
2025-07-10 21:30:49 -07:00
Sean Zhou 4c5ef1e235 feat: Add configure service account auth for google_api_tool_set 2025-07-10 21:23:59 -07:00
Ankur Sharma 51be7a899c feat: Add implementation of BaseEvalService that runs evals locally
This change:
- Introduces the LocalEvalService Class.
- Implements only the "perform_inference" method. Evaluate method will be implemented in the next CL.
- Adds required test coverage.

PiperOrigin-RevId: 781781954
2025-07-10 19:25:24 -07:00
seanzhou1023 4845b7bacc Merge branch 'main' into patch-1 2025-07-10 17:53:08 -07:00
Che Liu 162228d208 feat: Integrating Plugin with ADK
This change integrates the plugin system with ADK. PluginManager is attached to the invocation context similar to session/artifact/memory.

It includes integrations with following ADK internal callbacks:

* App callbacks: Integrated in the BaseRunner class, in run_async and run_live
* On Message callbacks: Integrated in the BaseRunner class, triggers on run_async.
* Agent callbacks: Integrated in the BaseAgent class. Leveraging the existing *callback functions
* Model callbacks: Integrating in the base_llm_flow.
* Tool callbacks: Integrated in functions.py, wrapped around the code for agent tool_callbacks

Sample code to use plugins:

```python
# Add plugins to Runner

runner = Runner(
      app_name="my-app",
      agent=root_agent,
      artifact_service=artifact_service,
      session_service=session_service,
      memory_service=memory_service,
      plugins=[
        MySamplePlugin(),
        LoggingPlugin(),
      ],
  )

```

PiperOrigin-RevId: 781746586
2025-07-10 17:28:42 -07:00
Che Liu 16ba91cd01 feat: Implement PluginService for registering and executing plugins
PluginService takes the registration of plugins, and provide the wrapper utilities to execute all plugins.

PiperOrigin-RevId: 781745769
2025-07-10 17:26:05 -07:00
Che Liu 4dce9ef519 feat: ADK Plugin Base Class
Plugin is a collection of callbacks (lifecycle hooks), including callbacks for Agent, Tools, Model and App. It helps developers to add customizations and change behaviors of their agent application easily

This is the first change that introduces only the base interfaces based on the doc.

plugins folder is generated with `create_symlink.sh plugins`

PiperOrigin-RevId: 781745044
2025-07-10 17:25:54 -07:00
seanzhou1023 297f9e3ec9 Merge branch 'main' into patch-1 2025-07-10 17:19:59 -07:00
seanzhou1023 894ef31fc1 Update base_toolset.py 2025-07-10 17:19:42 -07:00
Yanfei Chen 5a721d99a7 test: add the unit test for EnterpriseWebSearchTool
PiperOrigin-RevId: 781743222
2025-07-10 17:16:13 -07:00
Google Team Member 2f655f0c67 fix: Add support for code execution result and skip inline data in anthropic llm
```
blaze run assistant/lamda/bard/scrape/vertex/tools:use_vertex_agent --    --prompt_collection_id=cab_v0p7@3     --agent_name=vertex_1p_agent     --kernel_id=vertex_agent:claude-sonnet-4@20250514 --dynamically_inject_tools=True --add_final_answer_tag=True --example_ids=plot-line-004_0.5_new_1
```
TODO: https://evalhub.corp.google.com/runs/Uf5en14gqmK-R/links
PiperOrigin-RevId: 781724544
2025-07-10 16:17:27 -07:00
Liang Wu 68f34135fe feat(config): add ParallelAgent and SequentialAgent to the loader
PiperOrigin-RevId: 781712004
2025-07-10 15:42:51 -07:00
Liang Wu a313c2c1af feat(config): add configs for ParallelAgent and SequentialAgent
PiperOrigin-RevId: 781704814
2025-07-10 15:24:22 -07:00
Liang Wu d83362725d feat(config): add disallow_transfer_to_parent and disallow_transfer_to_peers to LlmAgentConfig
PiperOrigin-RevId: 781690247
2025-07-10 14:45:01 -07:00
Liang Wu aef54f8eb7 feat(config): support loading from YAML config in CLI
The supported CLIs are: `adk web`, `adk run` and `adk api_server`.

PiperOrigin-RevId: 781666724
2025-07-10 13:47:58 -07:00
Liang Wu ca396a3ab1 feat(config): add APIs for building config agents
Including basic fields in configs, the from_config() methods and the JSON schema. Other fields will be added in following PRs.

PiperOrigin-RevId: 781660569
2025-07-10 13:32:28 -07:00
Xuan Yang fb2415395f chore: create an initial prototype agent to answer Github discussion questions
This agent will post a comment to answer questions or provide more information according to the knowledge base.

PiperOrigin-RevId: 781651937
2025-07-10 13:09:56 -07:00
Liang Wu 2034fbb8f1 chore: remove unused line for Client()
PiperOrigin-RevId: 781617898
2025-07-10 11:41:27 -07:00
Xuan Yang 149c5fe4ff chore: update triage agent to assign the issue to owner after labeling it
PiperOrigin-RevId: 781604031
2025-07-10 11:06:45 -07:00
Bilawal Hameed 0fe8dcabda docs: s/readony_context/readonly_context/g 2025-07-10 18:42:41 +01:00
Google Team Member 10197db0d7 feat: Make InMemoryMemoryService thread-safe
Even though InMemoryMemoryService is intended only for testing and local development, we eliminate a potential source of bugs during prototyping by providing a thread-safe InMemoryMemoryService.

PiperOrigin-RevId: 781554006
2025-07-10 08:55:18 -07:00
Xiang (Sean) Zhou 584c8c6d91 fix: improve partial event handling and streaming aggregation
- Allow run_async to break on partial events instead of raising ValueError
- Generate aggregated streaming content regardless of finish_reason
- Add error_code and error_message to final streaming responses if model response is interrupted.

PiperOrigin-RevId: 781377328
2025-07-09 23:03:33 -07:00
Xuan Yang 444eba58a3 chore: rename session_factory to sql_session for readability
PiperOrigin-RevId: 781359783
2025-07-09 21:59:58 -07:00
Hangfei Lin d792018c09 test: Adds test for streaming + function calls
This commit includes a number of new tests for live streaming with function calls. These tests cover various scenarios:
- Single function calls
- Multiple function calls
- Parallel function calls
- Function calls with errors
- Synchronous function calls
- Simple streaming tools
- Video streaming tools
- Stopping a streaming tool
- Multiple streaming tools simultaneously

The tests use mock models and custom runners to simulate the interaction between the agent, model, and tools. They verify that function calls are correctly generated, executed, and that the expected data is returned.

PiperOrigin-RevId: 781318483
2025-07-09 19:41:27 -07:00
Xiang (Sean) Zhou da34692231 chore: Release 1.6.0
PiperOrigin-RevId: 781272837
2025-07-09 17:16:08 -07:00
Liang Wu d263afd91b feat: add agent.clone() method
This would allow users to easily make a copy of the agents they built without having to add too much boilerplates. This promotes code reuse, modularity and testability of agents.

PiperOrigin-RevId: 781214379
2025-07-09 14:34:58 -07:00
Ariz Chang c85330eae8 fix: Fix view eval case
PiperOrigin-RevId: 781196782
2025-07-09 13:52:54 -07:00
hironow 843b791bb0 chore(fix typo): correct typo AUTHLIB_AVIALABLE → AUTHLIB_AVAILABLE 2025-07-10 03:08:31 +09:00
Genquan Duan adef7b297a feat: Create PR agent for ADK github repo
Automatically generate reasonable PR descriptions.

PiperOrigin-RevId: 781078962
2025-07-09 09:06:28 -07:00
Marcello Maugeri 2ac8c44668 feat(lite_llm): add PDF support
Adds the ability to ingest and process PDF documents in the lite_llm pipeline.
2025-07-09 10:17:29 +02:00
Yifan Wang 18cd3844db chore: update adk web
PiperOrigin-RevId: 780740004
2025-07-08 15:35:59 -07:00
Ariz Chang e545e5a570 feat: Allow user to edit agent files/directories and apply changes without reloading anything
PiperOrigin-RevId: 780710003
2025-07-08 14:14:31 -07:00
Yanfei Chen e33161b4f8 fix: Support project-based gemini model path to use enterprise_web_search_tool
PiperOrigin-RevId: 780692178
2025-07-08 13:29:20 -07:00
Xiang (Sean) Zhou b5d9f8f3e3 chore: Update gemini model to 2.0 for a2a samples
PiperOrigin-RevId: 780657476
2025-07-08 11:56:28 -07:00
Joseph Pagadora 75699fbeca feat: Implement auto rater-based evaluator for responses
PiperOrigin-RevId: 780654576
2025-07-08 11:49:26 -07:00
Xiang (Sean) Zhou 45d60a1906 refactor: extract mcp client creation logic to a separate method
PiperOrigin-RevId: 780609120
2025-07-08 10:04:15 -07:00
Mateusz Czubak d3b500bd68 feat: expose credential service in readonly context 2025-07-08 11:32:50 +02:00
David Schmidt c592a10e94 Merge branch 'main' into fix_graph 2025-07-07 21:58:54 +02:00
Hangfei Lin bf39c00610 test: Add tests for live streaming configs
This PR extends the existing Streaming tests to consider new configurations that have been added, including:

- `output_audio_transcription`
- `input_audio_transcription`
- `realtime_input_config`
- `enable_affective_dialog`
- `proactivity`

These configurations are tested individually and also combined, to cover all the possibilities, increasing the testing coverage and ensuring everything is working as expected.

In addition, the new configuration values are also validated to be sure they are properly initialized.

PiperOrigin-RevId: 780178334
2025-07-07 11:01:46 -07:00
Hangfei Lin 28d0ea876f feat: Add adk project overview and architecture
This explains the high-level architecture and philosophy of the ADK project.
It can also be feed into LLMs for vibe-coding.

PiperOrigin-RevId: 780178125
2025-07-07 11:00:15 -07:00
Hangfei Lin 4ca77bc056 fix: Use inspect.signature() instead of typing.get_type_hints
fix: Use `inspect.signature()` instead of `typing.get_type_hints()` to find the LiveRequestQueue.
Motivation: `typing.get_type_hints()` may raise errors in complex scenarios where type annotation is not available.

Add live_bidi_streaming_tools_agent example to show how to use the live streaming feature.

PiperOrigin-RevId: 780160921
2025-07-07 10:16:13 -07:00
Shangjie Chen dc414cb507 chore: Add docstring to clarify that inmemory service are not suitable for production
environment

Resolves https://github.com/google/adk-python/issues/1569

PiperOrigin-RevId: 780013850
2025-07-07 02:13:56 -07:00
Shangjie Chen a021222077 feat: Add custom_metadata to VertexAiSessionService event handling
PiperOrigin-RevId: 779255526
2025-07-04 12:38:15 -07:00
Copybara-Service 4442167dd5 Merge pull request #1778 from rahulsamant37:fix/event-id-uuid4-collision-v1
PiperOrigin-RevId: 779177848
2025-07-04 07:06:19 -07:00
David Schmidt 438a008cb2 Merge branch 'main' into fix_graph 2025-07-04 14:02:33 +02:00
Rahul Samant e437c7aac6 fix: Replace Event ID generation with UUID4 to prevent SQLite integrity constraint failures
Fixes #719 where duplicate Event IDs caused database constraint violations
during streaming responses. Replaces 8-character random string generation
with UUID4 to ensure globally unique identifiers.

Changes:
- Replace Event.new_id() random string approach with uuid.uuid4()
- Remove unused random and string imports
- Add uuid import

Eliminates SQLite UNIQUE constraint failures in streaming scenarios.
2025-07-03 15:51:01 +00:00
Shangjie Chen 3fa2ea7cb9 fix: Remove duplicate options from adk deploy
Resolves https://github.com/google/adk-python/issues/1739

PiperOrigin-RevId: 778692588
2025-07-02 17:27:45 -07:00
Hangfei Lin 6a39c854e0 chore: update agents.md to include versioning strategy
Adds a description for docstring and comments in the AGENTS.md and adds a section for Versioning that describes how ADK follows Semantic Versioning 2.0.0

PiperOrigin-RevId: 778667398
2025-07-02 15:51:55 -07:00
Copybara-Service b04a5cebb8 Merge pull request #1644 from sindrigunnars:fix-issue-1641-database-session-service
PiperOrigin-RevId: 778630365
2025-07-02 13:51:34 -07:00
Sindri Snær Gunnarsson 362fb3f2b7 fix: scenario where a user can access another users events given the same session id
test: refine test_session_state in test_session_state to catch event leakage

fix: revert app name to my_app for test_session_state test

style: fix pyink style warnings

fix: add app_name to filter as per suggestion from rpedela-recurly
2025-07-02 18:56:08 +00:00
Ankur Sharma 0bd05df471 feat: Add Safety evaluator metric
We add a new metric for evaluating safety of Agent's response to ADK Eval. We delegate the actual implementation to Vertex Gen AI Eval SDK, so using this metric will require GCP project.

As a part of this change, we created (refactored) a simple Facade for vertex gen ai eval sdk.

PiperOrigin-RevId: 778580406
2025-07-02 11:30:31 -07:00
Ankur Sharma 62c4a85917 chore: Update ResponseEvaluator to use newer version of Eval SDK
Also,
- removed functionality that was marked deprecated from the ResponseEvaluator class.
- Added unit test cases

PiperOrigin-RevId: 778568884
2025-07-02 11:00:27 -07:00
Copybara-Service 08869ccc07 Merge pull request #1744 from google:hangfei-patch-3
PiperOrigin-RevId: 778561518
2025-07-02 10:40:03 -07:00
Shangjie Chen df141db60c chore: Add tenacity into project.toml
PiperOrigin-RevId: 778535340
2025-07-02 09:31:19 -07:00
Copybara-Service 9bd539eca9 Merge pull request #1656 from google:fix-transfer-to-agent-parameters-issue
PiperOrigin-RevId: 778334126
2025-07-01 22:03:23 -07:00
Shangjie Chen 3d2f13cecd chore: Update the retry logic of create session polling
This should slightly increase the timeout also reduce the polling frequency.

PiperOrigin-RevId: 778323416
2025-07-01 21:21:57 -07:00
Hangfei Lin d0fdfb8c8e doc: Update README.md 2025-07-01 21:05:43 -07:00
google-labs-jules[bot] 0959b06dbd Fix: Handle unexpected 'parameters' argument in FunctionTool.run_async
The LLM occasionally includes an unexpected 'parameters' argument when calling tools, specifically observed with 'transfer_to_agent'. This change makes FunctionTool.run_async more robust by filtering arguments against the function signature before invocation.

This resolves issue #1637.

Update test_function_tool.py

fix typing

fix: add `from __future__ import annotations`
2025-07-02 00:22:09 +00:00
Liang Wu 9af2394e0a fix: continue the action when grep -L returns exit status 1
`grep -L` returns status 1 when there are modified files that don't have the `from __future__ import annotations` pattern. Previously if this happens, the entire GitHub action by default will stop and exit with status 1. Adding `|| true` will prevent this from happening and continue the workflow.

PiperOrigin-RevId: 778246018
2025-07-01 16:57:56 -07:00
Copybara-Service 873beca088 Merge pull request #1709 from google:my-feature-branch-llmstxt
PiperOrigin-RevId: 778239103
2025-07-01 16:38:48 -07:00
hangfei a903c54bac chore: Add util to build our llms.txt and llms-full.txt files 2025-07-01 16:21:12 -07:00
Ankur Sharma b0d88bf172 feat: BaseEvalService declaration and surrounding data models
Also, adds a metric registry.

PiperOrigin-RevId: 778186012
2025-07-01 14:13:48 -07:00
Shangjie Chen 17d6042995 fix: Make sure each partial event has different timestamp
PiperOrigin-RevId: 778148175
2025-07-01 12:36:33 -07:00
Jianfeng Zeng 43083baddc chore: update adk web
Update minified files for adk-web

PiperOrigin-RevId: 777618082
2025-06-30 10:09:18 -07:00
Hangfei Lin 9b75e24d8c fix: Avoid pydantic.ValidationError when the model stream returns empty final chunk
Bug: When a model emits a stream of tokens, it sometimes emits a final chunk of whitespace or no content. The agent was trying to parse that content into JSON, causing a validation error.

Fix: If a model is expected to return JSON and the last streamed token is empty/whitespace, the agent will no longer try to parse it, and exit gracefully.

New unit tests confirm the scenario and the fix.

PiperOrigin-RevId: 777609415
2025-06-30 09:50:04 -07:00
Hangfei Lin a58cc3d882 chore: Create an example for multi agent live streaming
This example include multi agents:
- Root agent.
- Sub agent for Rolling Dice.
- Sub agent for checking primes.

Added README.md to demonstrate how to use it.

PiperOrigin-RevId: 777599625
2025-06-30 09:21:15 -07:00
Google Team Member 37108be855 docs: Add AGENTS.md to provide relevant project context for the Gemini CLI
Including details on the ADK style guide and how to run specific tools.

PiperOrigin-RevId: 776827602
2025-06-27 21:00:54 -07:00
Xuan Yang b6c7b5b64f chore: refactor the ADK Triaging Agent to make the code easier to read
PiperOrigin-RevId: 776763061
2025-06-27 16:45:38 -07:00
Hangfei Lin ffa9b361db docs: Update CONTRIBUTING.md
Merge https://github.com/google/adk-python/pull/1703

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/1703 from google:hangfei-patch-1 251b530e8346ab03a3bfd84c837f14578be37285
PiperOrigin-RevId: 776670181
2025-06-27 12:06:18 -07:00
Google Team Member dc43d518c9 feat: Support protected write in BigQuery execute_sql tool
This change adds a new enum value which the agent builder can pass in the `BigQueryToolConfig` to allow limited writes to the `execute_sql` tool.

PiperOrigin-RevId: 776661744
2025-06-27 11:44:30 -07:00
Xiang (Sean) Zhou e2748b3ed5 chore: Add an a2a agent to demo oauth flow
PiperOrigin-RevId: 776661038
2025-06-27 11:43:05 -07:00
Xiang (Sean) Zhou 379810dd6a chore: Add a human in the loop a2a agent demo sample
PiperOrigin-RevId: 776660876
2025-06-27 11:41:47 -07:00
Xiang (Sean) Zhou 1cf5cf0d0a chore: Add a basic a2a agent demo sample
PiperOrigin-RevId: 776660703
2025-06-27 11:40:26 -07:00
Xiang (Sean) Zhou f0183a9b98 feat: Enable A2A features as experimental
PiperOrigin-RevId: 776656783
2025-06-27 11:28:28 -07:00
Xuan Yang 3f621ae6f2 fix: treat SQLite database update time as UTC for session's last update time
Fixes https://github.com/google/adk-python/issues/1180

We are using `func.now()` to set the `onupdate` time for db, when SQLAlchemy generates the SQL to build the database, it actually translates `func.now()` into `NOW()` or `CURRENT_TIMESTAMP`. The value it returns depends on the database server settings. For example, if the global/default timezone for a db is set to be UTC, the update time will be set to be a UCT time; if the global time zone for a db is set to be a local time zone (e.g. America/Los_Angeles), the update time will be a local time.

Normally, the best practice is to set database server to use UTC. Applications will convert it into different time zones as needed.

For SQLite, there is no way to config the default timezone, it will just treat it as UTC. But because it is a naive datetime (with no timezone info), python will assume it is a local time and then covert it into a UTC, which is why we see the bug (e.g. we create a session at 2025-06-17 12:49:33 local time, but when we read the session, its last update time is 2025-06-17 19:49:33 local time).

The solution is converting the native datatime to be timezone aware before `.timestamp()`.

The change in this CL only affects SQLite database.

PiperOrigin-RevId: 776654443
2025-06-27 11:22:23 -07:00
Keisuke Oohashi 4e765ae2f3 fix: raise ValueError when sessionId and userId are incorrect combination(#1653)
Merge https://github.com/google/adk-python/pull/1655

Fix #1653

When session_id and user_id are incorrect combination on vertex ai session service, it should not return the session.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/1655 from soundTricker:fix/1653-invalid-session 7a3dee2fc75602a2685ea922799cc5f5ba666e97
PiperOrigin-RevId: 776648361
2025-06-27 11:06:15 -07:00
Xiang (Sean) Zhou c13c9875cf feat: Add remote a2a agent
PiperOrigin-RevId: 776643130
2025-06-27 10:52:01 -07:00
Xiang (Sean) Zhou 045aea9b15 fix: Support API-Key for MCP Tool authentication
PiperOrigin-RevId: 776641474
2025-06-27 10:47:42 -07:00
Xiang (Sean) Zhou 20279d9a50 fix: Save output in state via output_key only when the event is authored by current agent
PiperOrigin-RevId: 776640671
2025-06-27 10:45:34 -07:00
Xiang (Sean) Zhou 09e487df3c chore: Use context_id as session_id and construct temp user_id from context_id
PiperOrigin-RevId: 776639713
2025-06-27 10:42:15 -07:00
Hangfei Lin 51a559eb2a chore: Adding PR commit check github workflow
This will fail a PR check if multiple commits are added, and will give the user instructions on how to fix the issue.

PiperOrigin-RevId: 776638574
2025-06-27 10:38:36 -07:00
Xiang (Sean) Zhou 1fe9c47cc6 chore: Enhance a2a_agent_executor module to raise error with meaningful error message to ask user upgrade python when python version < 3.10
PiperOrigin-RevId: 776631647
2025-06-27 10:21:26 -07:00
Xiang (Sean) Zhou 31e41bdd06 chore: Enhance part_converter module to only import sys when needed and update the import error message
PiperOrigin-RevId: 776631415
2025-06-27 10:19:50 -07:00
Hangfei Lin 9029b8a66e fix: Lock LangGraph version to <= 0.4.10
New version removed graph.graph we rely on.
temporarily fix the version before we fix the issue.

PiperOrigin-RevId: 776619611
2025-06-27 09:48:20 -07:00
Jack Wotherspoon e153d07593 chore: updating CONTRIBUTING.md with missing extra
Merge https://github.com/google/adk-python/pull/1679

Contributing doc says to do the following:

```sh
uv sync --extra test --extra eval
pytest ./tests/unittests
```

If you follow this the tests will fail:

```sh
tests/unittests/a2a/executor/test_task_result_aggregator.py:27: in <module>
    from a2a.types import Message
E   ModuleNotFoundError: No module named 'a2a'
```

This makes sense since the `a2a` package is not part of ADK's core dep, it is an extra:

https://github.com/google/adk-python/blob/e79651cd86ba3f0c998109f2140f1db2cab78708/pyproject.toml#L79-L83

Thus for a2a tests to pass we must include the extra in the sync command:

```sh
uv sync --extra test --extra eval --extra a2a
pytest ./tests/unittests
```

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/1679 from jackwotherspoon:main c1a536780409065db817088a8d5ed5979cca8d8f
PiperOrigin-RevId: 776617515
2025-06-27 09:42:54 -07:00
Xiang (Sean) Zhou e79651cd86 feat: Add A2A endpoints to fast api server when --a2a option is specified (WIP)
PiperOrigin-RevId: 776211580
2025-06-26 11:18:44 -07:00
Yifan Wang 22629a17bd chore: update adk web
Update minified files for adk-web

PiperOrigin-RevId: 776176499
2025-06-26 09:51:02 -07:00
Xiang (Sean) Zhou 5356f20ead chore: Add a2a log utils for formatting a2a reqeust/response logs
PiperOrigin-RevId: 776026554
2025-06-26 01:12:23 -07:00
Xiang (Sean) Zhou ed09cd840f chore: Add enable_a2a option to adk command line
PiperOrigin-RevId: 775991652
2025-06-25 23:05:08 -07:00
Xiang (Sean) Zhou 630f1674cb chore: Add a2a agent executor
PiperOrigin-RevId: 775983689
2025-06-25 22:32:17 -07:00
Xiang (Sean) Zhou 2f55de6ded chore: Add a2a task result aggregator
PiperOrigin-RevId: 775975982
2025-06-25 22:02:28 -07:00
Ray Iramaneerat 77b869f5e3 fix: Update google_search_tool.py to support updated Gemini LIVE model naming
Merge https://github.com/google/adk-python/pull/1518

## Description
Fixes [#1512](https://github.com/google/adk-python/issues/1512) by updating google_search_tool.py to support new Gemini LIVE model naming

## Changes
- Update the model name checking in google_search_tool.py

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/1518 from rayira:rayira-patch-1 4c98f88290af6e0a4690652019ca1d7a08689340
PiperOrigin-RevId: 775941268
2025-06-25 19:56:09 -07:00
Ankur Sharma 04de3e197d fix: Adding detailed information on each metric evaluation
Additionally, few other small changes.
*   Updated a test fixture to support the latest eval data schema. Somehow I missed doing that previously.
*   Updated the `evaluation_generator.py` to use `run_async`, instead of `run`.
*   Also, raise an informed error when dependencies required eval are not installed.
*   Also, changed the behavior of AgentEvaluator.evaluate method to run all the evals, instead of failing at the first eval metric failure.

PiperOrigin-RevId: 775919127
2025-06-25 18:32:02 -07:00
SimonWei 3901fade71 fix: converts litellm generate config err
Merge https://github.com/google/adk-python/pull/1509

Fixs: #1302

Previous PR: https://github.com/google/adk-python/pull/1450

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/1509 from simonwei97:fix/litellm-gen-config-converting-err 3120887f29a21789f1b4a7c54af3ed35eb5055e3
PiperOrigin-RevId: 775903671
2025-06-25 17:40:48 -07:00
Hangfei Lin 63fda1b7bf Merge branch 'main' into fix_graph 2025-06-25 16:38:20 -07:00
Xiang (Sean) Zhou a71dbdf9e2 chore: Enhance a2a event converter
a. fix function call long running id matching logic
b. fix error code conversion logic
c. add input required and auth required status conversion logic
d. add a2a Task/Message to ADK event converter
f. set task id and context id from input argument

PiperOrigin-RevId: 775860563
2025-06-25 15:32:17 -07:00
Xiang (Sean) Zhou 832a633351 chore: Enhance a2a part converters
a. fix binary data conversion
b. support thoughts, code execution result, executable codes conversion

PiperOrigin-RevId: 775827259
2025-06-25 13:58:49 -07:00
Xuan Yang 738d1a8b84 chore: create an agent to check issue format and content for bugs and feature requests
This agent will pose a comment to ask for more information according to the template if necessary.

PiperOrigin-RevId: 775742256
2025-06-25 10:20:45 -07:00
Hangfei Lin 5306ddad4d chore: Release 1.5.0
PiperOrigin-RevId: 775742049
2025-06-25 10:19:20 -07:00
Xiang (Sean) Zhou a623467299 chore: Enhance a2a context id parsing and construction logic
PiperOrigin-RevId: 775718282
2025-06-25 09:19:16 -07:00
Xiang (Sean) Zhou f54b9b6ad1 chore: Add unit tests for contents.py
PiperOrigin-RevId: 775713101
2025-06-25 09:06:01 -07:00
Google Team Member 6729edd08e refactor: Rename the Google API based bigquery sample agent
This change renames the sample agent based on the Google API based tools to reflect the larger purpose and avoid confusion with the built-in BigQuery tools. In addition, it also renames the root agent in the BigQuery sample agent to "bigquery_agent"

PiperOrigin-RevId: 775655226
2025-06-25 06:05:32 -07:00
Xiang (Sean) Zhou 917a8a19f7 chore: Adapt oauth calendar agent to use authenticated tool
PiperOrigin-RevId: 775433950
2025-06-24 16:46:20 -07:00
Aditya Mulik ef3c745d65 fix: typo fix in sample agent instruction
Merge https://github.com/google/adk-python/pull/1623

fix: minor typo fix in the agent instruction
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/1623 from adityamulik:minor_typo_fix 12ea09ae397b5c5e2a9ada48017cd1ca14add72e
PiperOrigin-RevId: 775433411
2025-06-24 16:44:34 -07:00
Shangjie Chen 88a4402d14 chore: Do not send api request when session does not have events
PiperOrigin-RevId: 775423356
2025-06-24 16:15:23 -07:00
Dave Bunten 09f1269bf7 ci(tests): leverage official uv action for install
Merge https://github.com/google/adk-python/pull/1547

This PR replaces the `curl`-based installation of `uv` to instead use the [official GitHub Action from Astral](https://github.com/astral-sh/setup-uv).

Closes #1545

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/1547 from d33bs:use-uv-action 05ab7a138cbb5babee30ea81e83f26064e041529
PiperOrigin-RevId: 775402484
2025-06-24 15:18:18 -07:00
Google Team Member 9e473e0abd fix: Include current turn context when include_contents='none'
The intended behavior for include_contents='none' is to:
- Exclude conversation history from previous turns
- Still include current turn context (user input, tool calls/responses within current turn)

https://google.github.io/adk-docs/agents/llm-agents/#managing-context-include_contents

This resolves https://github.com/google/adk-python/issues/1124

PiperOrigin-RevId: 775400036
2025-06-24 15:11:33 -07:00
Xiang (Sean) Zhou acbdca0d84 fix: Make raw_auth_credential and exchanged_auth_credential optional given their default value is None
PiperOrigin-RevId: 775397286
2025-06-24 15:03:54 -07:00
Google Team Member ed7a21e189 chore: Update google-genai package and related deps to latest
PiperOrigin-RevId: 775394737
2025-06-24 14:57:56 -07:00
Liang Wu a1e1441115 fix: update contributing links
Merge https://github.com/google/adk-python/pull/1528

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/1528 from google:doc ec8325e126aba7257de73ab26d8d3a30064859b4
PiperOrigin-RevId: 775383121
2025-06-24 14:27:25 -07:00
Genquan Duan f33e0903b2 feat: Add ADK examples for litellm with add_function_to_prompt
Add examples for for https://github.com/google/adk-python/issues/1273

PiperOrigin-RevId: 775352677
2025-06-24 13:08:44 -07:00
Shangjie Chen abc89d2c81 feat: Add implementation of VertexAiMemoryBankService and support in FastAPI endpoint
PiperOrigin-RevId: 775327151
2025-06-24 11:57:03 -07:00
Google Team Member 00cc8cd643 feat: Add Vertex Express mode compatibility for VertexAiSessionService
PiperOrigin-RevId: 775317848
2025-06-24 11:33:37 -07:00
Joseph Pagadora 9597a446fd feat: Add rouge_score library to ADK eval dependencies, and implement RougeEvaluator that is computes ROUGE-1 for "response_match_score" metric
PiperOrigin-RevId: 774949712
2025-06-23 15:31:03 -07:00
Joseph Pagadora fa025d7559 feat: Add a new option eval_storage_uri in adk web & adk eval to specify GCS bucket to store eval data
PiperOrigin-RevId: 774947795
2025-06-23 15:24:57 -07:00
Xiang (Sean) Zhou 120cbabeb2 refactor: Rename long util function name in runner.py and move it to functions.py
PiperOrigin-RevId: 774880990
2025-06-23 12:24:10 -07:00
Xiang (Sean) Zhou 29cd183aa1 chore: Add credential service backed by session state
PiperOrigin-RevId: 774878336
2025-06-23 12:16:03 -07:00
David Schmidt a794728a2f fix(agent_graph): Prevent duplicate edges in agent graph 2025-06-23 19:54:36 +02:00
avidelatm bd67e8480f fix: make LiteLLM streaming truly asynchronous
Merge https://github.com/google/adk-python/pull/1451

## Description
Fixes https://github.com/google/adk-python/issues/1306 by using `async for` with `await self.llm_client.acompletion()` instead of synchronous `for` loop.

## Changes
- Updated test mocks to properly handle async streaming by creating an async generator
- Ensured proper parameter handling to avoid duplicate stream parameter

## Testing Plan
- All unit tests now pass with the async streaming implementation
- Verified with `pytest tests/unittests/models/test_litellm.py` that all streaming tests pass
- Manually tested with a sample agent using LiteLLM to confirm streaming works properly

# Test Evidence:
https://youtu.be/hSp3otI79DM

Let me know if you need anything else from me for this PR

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/1451 from avidelatm:fix/litellm-async-streaming d35b9dc90b2fd6fad44c3869de0fda2514e50055
PiperOrigin-RevId: 774835130
2025-06-23 10:30:12 -07:00
Keisuke Oohashi ea69c9093a feat: add usage span attributes to telemetry (#356)
Merge https://github.com/google/adk-python/pull/1079

Fixes part of #356

Add usage attributes to span.
Note: Since the handling of GenAI event bodies in OpenTelemetry has not yet been determined, I have temporarily added only attributes related to usage.
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/1079 from soundTricker:feature/356-support-more-opentelemetry-semantics 99a9d0352b4bca165baa645440e39ce7199f072b
PiperOrigin-RevId: 774834279
2025-06-23 10:28:14 -07:00
Shangjie Chen f033e405c1 chore: Clarify the behavior of Event.invocation_id
PiperOrigin-RevId: 774827874
2025-06-23 10:12:16 -07:00
bck-ob-gh 3b1d9a8a3e fix: Use starred tuple unpacking on GCS artifact blob names
Merges https://github.com/google/adk-python/pull/1471

Fixes google#1436

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/1471 from bck-ob-gh:main 4c4f2b66ab1e6fde8b1a9d2b914dcb24040db144
PiperOrigin-RevId: 774809270
2025-06-23 09:24:31 -07:00
Xiang (Sean) Zhou 7c670f638b chore: Send user message to the agent that returned a corresponding function call if user message is a function response
PiperOrigin-RevId: 773895971
2025-06-20 17:15:29 -07:00
Xiang (Sean) Zhou fb13963ded chore: Add request converter to convert a2a request to ADK request
PiperOrigin-RevId: 773894462
2025-06-20 17:09:05 -07:00
Shangjie Chen 2fd8feb65d chore: Support allow_origins in cloud_run deployment
Also reorganize the fast_api_common_options. This resolves https://github.com/google/adk-python/issues/1444.

PiperOrigin-RevId: 773890111
2025-06-20 16:54:08 -07:00
Shangjie Chen 8677d5c8dc chore: bump version number to 1.4.2
PiperOrigin-RevId: 773867075
2025-06-20 15:41:50 -07:00
Shangjie Chen 4d72d31b13 fix: Add type checking to handle different response type of genai API client
Fixes https://github.com/google/adk-python/issues/1514

PiperOrigin-RevId: 773838035
2025-06-20 14:12:55 -07:00
Xiang (Sean) Zhou 742478fdb7 chore: Add event converters to convert adk event to a2a event (WIP)
PiperOrigin-RevId: 773795427
2025-06-20 12:14:12 -07:00
Xiang (Sean) Zhou ffcba70686 chore: skip mcp and a2a tests for python 3.9
PiperOrigin-RevId: 773785385
2025-06-20 11:46:31 -07:00
Google Team Member 2f716ada7f fix: Allow more credentials types for BigQuery tools
This change accepts the `google.auth.credentials.Credentials` type for `BigQueryCredentialsConfig`, so any subclass of that, including `google.oauth2.credentials.Credentials` would work to integrate with BigQuery service. This opens up a whole range of possibilities, such as using service account credentials to deploy an agent using these tools.

PiperOrigin-RevId: 773190440
2025-06-18 22:02:09 -07:00
Shangjie Chen 17beb32880 chore: Bump version number and update changelog for 1.4.1 release
PiperOrigin-RevId: 773148349
2025-06-18 19:08:43 -07:00
Xiang (Sean) Zhou 7f8dc8927a chore: fix the mcp_sse_agent
PiperOrigin-RevId: 773140021
2025-06-18 18:32:06 -07:00
Hangfei Lin aabfde56e4 Merge branch 'main' into fix/missing-path-level-parameters 2025-05-30 11:33:24 -07:00
Jeffrey Mak f2b9e72f82 Merge branch 'main' into fix/missing-path-level-parameters 2025-05-17 16:57:00 -04:00
Jeffrey Mak 3263a97999 Merge branch 'main' into fix/missing-path-level-parameters 2025-05-14 10:57:06 -04:00
Jeffrey Mak 36866935a3 Merge branch 'main' into fix/missing-path-level-parameters 2025-05-09 19:21:46 -04:00
kmak de238eeab1 fix: unittest for path-level parameters case 2025-05-09 19:20:59 -04:00
Jeffrey Mak 84579cab56 Merge branch 'main' into fix/missing-path-level-parameters 2025-05-04 08:51:14 -04:00
kmak 34b001292a fix: support path level parameters for open_api_spec_parser 2025-05-04 08:50:02 -04:00
1102 changed files with 214354 additions and 9592 deletions
+3
View File
@@ -0,0 +1,3 @@
{
"contextFileName": "AGENTS.md"
}
+7 -2
View File
@@ -14,11 +14,12 @@ assignees: ''
A clear and concise description of what the bug is.
**To Reproduce**
Please share a minimal code and data to reproduce your problem.
Steps to reproduce the behavior:
1. Install '...'
2. Run '....'
3. Open '....'
4. See error
4. Provide error or stacktrace
**Expected behavior**
A clear and concise description of what you expected to happen.
@@ -27,9 +28,13 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- OS: [e.g. macOS, Linux, Windows]
- Python version(python -V):
- ADK version(pip show google-adk):
**Model Information:**
- Are you using LiteLLM: Yes/No
- Which model is being used(e.g. gemini-2.5-pro)
**Additional context**
Add any other context about the problem here.
+52
View File
@@ -0,0 +1,52 @@
**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
**1. Link to an existing issue (if applicable):**
- Closes: #_issue_number_
- Related: #_issue_number_
**2. Or, if no issue exists, describe the change:**
_If applicable, please follow the issue templates to provide as much detail as
possible._
**Problem:**
_A clear and concise description of what the problem is._
**Solution:**
_A clear and concise description of what you want to happen and why you choose
this solution._
### Testing Plan
_Please describe the tests that you ran to verify your changes. This is required
for all PRs that are not small documentation or typo fixes._
**Unit Tests:**
- [ ] I have added or updated unit tests for my change.
- [ ] All unit tests pass locally.
_Please include a summary of passed `pytest` results._
**Manual End-to-End (E2E) Tests:**
_Please provide instructions on how to manually test your changes, including any
necessary setup or configuration. Please provide logs or screenshots to help
reviewers better understand the fix._
### Checklist
- [ ] I have read the [CONTRIBUTING.md](https://github.com/google/adk-python/blob/main/CONTRIBUTING.md) document.
- [ ] 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.
### Additional context
_Add any other context or screenshots about the feature request here._
@@ -0,0 +1,47 @@
name: Analyze New Release for ADK Docs Updates
on:
# Runs on every new release.
release:
types: [published]
# Manual trigger for testing and retrying.
workflow_dispatch:
jobs:
analyze-new-release-for-adk-docs-updates:
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Load adk-bot SSH Private Key
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.ADK_BOT_SSH_PRIVATE_KEY }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests google-adk
- name: Run Analyzing Script
env:
GITHUB_TOKEN: ${{ secrets.ADK_TRIAGE_AGENT }}
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
GOOGLE_GENAI_USE_VERTEXAI: 0
DOC_OWNER: 'google'
CODE_OWNER: 'google'
DOC_REPO: 'adk-docs'
CODE_REPO: 'adk-python'
INTERACTIVE: 0
PYTHONPATH: contributing/samples/adk_documentation
run: python -m adk_release_analyzer.main
+3 -3
View File
@@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
fetch-depth: 2
@@ -70,7 +70,7 @@ jobs:
# Use grep -L to find files that DO NOT contain the pattern.
# This command will output a list of non-compliant files.
FILES_MISSING_IMPORT=$(grep -L 'from __future__ import annotations' $CHANGED_FILES)
FILES_MISSING_IMPORT=$(grep -L 'from __future__ import annotations' $CHANGED_FILES || true)
# Check if the list of non-compliant files is empty
if [ -z "$FILES_MISSING_IMPORT" ]; then
@@ -89,7 +89,7 @@ jobs:
- name: Check for import from cli package in certain changed Python files
run: |
git fetch origin ${{ github.base_ref }}
CHANGED_FILES=$(git diff --diff-filter=ACMR --name-only origin/${{ github.base_ref }}...HEAD | grep -E '\.py$' | grep -v -E 'cli/.*|tests/.*|contributing/samples/' || true)
CHANGED_FILES=$(git diff --diff-filter=ACMR --name-only origin/${{ github.base_ref }}...HEAD | grep -E '\.py$' | grep -v -E 'cli/.*|src/google/adk/tools/apihub_tool/apihub_toolset.py|tests/.*|contributing/samples/' || true)
if [ -n "$CHANGED_FILES" ]; then
echo "Changed Python files to check:"
echo "$CHANGED_FILES"
+134
View File
@@ -0,0 +1,134 @@
name: Copybara PR Handler
on:
push:
branches:
- main
workflow_dispatch:
inputs:
pr_number:
description: 'PR number to close (for testing)'
required: true
type: string
commit_sha:
description: 'Commit SHA reference (optional, for testing)'
required: false
type: string
jobs:
close-imported-pr:
runs-on: ubuntu-latest
permissions:
pull-requests: write
issues: write
contents: read
steps:
- name: Check for Copybara commits and close PRs
uses: actions/github-script@v8
with:
github-token: ${{ secrets.ADK_TRIAGE_AGENT }}
script: |
// Check if this is a manual test run
const isManualRun = context.eventName === 'workflow_dispatch';
let prsToClose = [];
if (isManualRun) {
// Manual testing mode
const prNumber = parseInt(context.payload.inputs.pr_number);
const commitSha = context.payload.inputs.commit_sha || context.sha.substring(0, 7);
console.log('=== MANUAL TEST MODE ===');
console.log(`Testing with PR #${prNumber}, commit ${commitSha}`);
prsToClose.push({ prNumber, commitSha });
} else {
// Normal mode: process commits from push event
const commits = context.payload.commits || [];
console.log(`Found ${commits.length} commit(s) in this push`);
// Process each commit
for (const commit of commits) {
const sha = commit.id;
const committer = commit.committer.name;
const message = commit.message;
console.log(`\n--- Processing commit ${sha.substring(0, 7)} ---`);
console.log(`Committer: ${committer}`);
// Check if this is a Copybara commit
if (committer !== 'Copybara-Service') {
console.log('Not a Copybara commit, skipping');
continue;
}
// Extract PR number from commit message
// Pattern: "Merge https://github.com/google/adk-python/pull/3333"
const prMatch = message.match(/Merge https:\/\/github\.com\/google\/adk-python\/pull\/(\d+)/);
if (!prMatch) {
console.log('No PR number found in Copybara commit message');
continue;
}
const prNumber = parseInt(prMatch[1]);
const commitSha = sha.substring(0, 7);
prsToClose.push({ prNumber, commitSha });
}
}
// Process PRs to close
for (const { prNumber, commitSha } of prsToClose) {
console.log(`\n--- Processing PR #${prNumber} ---`);
// Get PR details to check if it's open
let pr;
try {
pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber
});
} catch (error) {
console.log(`PR #${prNumber} not found or inaccessible:`, error.message);
continue;
}
// Only close if PR is still open
if (pr.data.state !== 'open') {
console.log(`PR #${prNumber} is already ${pr.data.state}, skipping`);
continue;
}
const author = pr.data.user.login;
try {
// Add comment with commit reference
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: `Thank you @${author} for your contribution! 🎉\n\nYour changes have been successfully imported and merged via Copybara in commit ${commitSha}.\n\nClosing this PR as the changes are now in the main branch.`
});
// Close the PR
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber,
state: 'closed'
});
console.log(`Successfully closed PR #${prNumber}`);
} catch (error) {
console.log(`Error closing PR #${prNumber}:`, error.message);
}
}
if (isManualRun) {
console.log('\n=== TEST COMPLETED ===');
} else {
console.log('\n--- Finished processing all commits ---');
}
@@ -0,0 +1,54 @@
name: ADK Answering Agent for Discussions
on:
discussion:
types: [created]
discussion_comment:
types: [created]
jobs:
agent-answer-questions:
if: >-
(github.event_name == 'discussion' && github.event.discussion.category.name == 'Q&A') ||
(github.event_name == 'discussion_comment' && contains(github.event.comment.body, '@adk-bot') && github.event.sender.login != 'adk-bot')
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Authenticate to Google Cloud
id: auth
uses: 'google-github-actions/auth@v3'
with:
credentials_json: '${{ secrets.ADK_GCP_SA_KEY }}'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install google-adk google-cloud-discoveryengine
- name: Run Answering Script
env:
GITHUB_TOKEN: ${{ secrets.ADK_TRIAGE_AGENT }}
ADK_GCP_SA_KEY: ${{ secrets.ADK_GCP_SA_KEY }}
GOOGLE_CLOUD_PROJECT: ${{ secrets.GOOGLE_CLOUD_PROJECT }}
GOOGLE_CLOUD_LOCATION: ${{ secrets.GOOGLE_CLOUD_LOCATION }}
VERTEXAI_DATASTORE_ID: ${{ secrets.VERTEXAI_DATASTORE_ID }}
GEMINI_API_DATASTORE_ID: ${{ secrets.GEMINI_API_DATASTORE_ID }}
GOOGLE_GENAI_USE_VERTEXAI: 1
OWNER: 'google'
REPO: 'adk-python'
INTERACTIVE: 0
PYTHONPATH: contributing/samples
run: |
# Write discussion data to temporary file to avoid secret masking issues
cat > /tmp/discussion.json << 'EOF'
${{ toJson(github.event.discussion) }}
EOF
python -m adk_answering_agent.main --discussion-file /tmp/discussion.json
+2 -2
View File
@@ -26,12 +26,12 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
fetch-depth: 2
- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: '3.x'
+45
View File
@@ -0,0 +1,45 @@
name: ADK Pull Request Triaging Agent
on:
pull_request_target:
types: [opened, reopened, edited]
workflow_dispatch:
inputs:
pr_number:
description: 'The Pull Request number to triage'
required: true
type: 'string'
jobs:
agent-triage-pull-request:
if: github.event_name == 'workflow_dispatch' || !contains(github.event.pull_request.labels.*.name, 'google-contributor')
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests google-adk
- name: Run Triaging Script
env:
GITHUB_TOKEN: ${{ secrets.ADK_TRIAGE_AGENT }}
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
GOOGLE_GENAI_USE_VERTEXAI: 0
OWNER: 'google'
REPO: 'adk-python'
PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number || github.event.inputs.pr_number }}
INTERACTIVE: ${{ vars.PR_TRIAGE_INTERACTIVE }}
PYTHONPATH: contributing/samples
run: python -m adk_pr_triaging_agent.main
+2 -2
View File
@@ -26,12 +26,12 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
fetch-depth: 2
- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: '3.x'
+8 -16
View File
@@ -25,19 +25,19 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v6
- name: Install dependencies
run: |
@@ -48,14 +48,6 @@ jobs:
- name: Run unit tests with pytest
run: |
source .venv/bin/activate
if [[ "${{ matrix.python-version }}" == "3.9" ]]; then
pytest tests/unittests \
--ignore=tests/unittests/a2a \
--ignore=tests/unittests/tools/mcp_tool \
--ignore=tests/unittests/artifacts/test_artifact_service.py \
--ignore=tests/unittests/tools/google_api_tool/test_googleapi_to_openapi_converter.py
else
pytest tests/unittests \
--ignore=tests/unittests/artifacts/test_artifact_service.py \
--ignore=tests/unittests/tools/google_api_tool/test_googleapi_to_openapi_converter.py
fi
pytest tests/unittests \
--ignore=tests/unittests/artifacts/test_artifact_service.py \
--ignore=tests/unittests/tools/google_api_tool/test_googleapi_to_openapi_converter.py
+57
View File
@@ -0,0 +1,57 @@
# 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.
name: ADK Stale Issue Auditor
on:
workflow_dispatch:
schedule:
# This runs at 6:00 AM UTC (10 PM PST)
- cron: '0 6 * * *'
jobs:
audit-stale-issues:
runs-on: ubuntu-latest
timeout-minutes: 60
permissions:
issues: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests google-adk
- name: Run Auditor Agent Script
env:
GITHUB_TOKEN: ${{ secrets.ADK_TRIAGE_AGENT }}
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
OWNER: ${{ github.repository_owner }}
REPO: adk-python
CONCURRENCY_LIMIT: 3
LLM_MODEL_NAME: "gemini-2.5-flash"
PYTHONPATH: contributing/samples
run: python -m adk_stale_agent.main
+17 -7
View File
@@ -2,23 +2,32 @@ name: ADK Issue Triaging Agent
on:
issues:
types: [opened, reopened]
types: [opened, labeled]
schedule:
- cron: '0 */6 * * *' # every 6h
# Run every 6 hours to triage untriaged issues
- cron: '0 */6 * * *'
jobs:
agent-triage-issues:
runs-on: ubuntu-latest
# Run for:
# - Scheduled runs (batch processing)
# - New issues (need component labeling)
# - Issues labeled with "planned" (need owner assignment)
if: >-
github.event_name == 'schedule' ||
github.event.action == 'opened' ||
github.event.label.name == 'planned'
permissions:
issues: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: '3.11'
@@ -32,12 +41,13 @@ jobs:
GITHUB_TOKEN: ${{ secrets.ADK_TRIAGE_AGENT }}
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
GOOGLE_GENAI_USE_VERTEXAI: 0
OWNER: 'google'
REPO: 'adk-python'
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
INTERACTIVE: 0
EVENT_NAME: ${{ github.event_name }} # 'issues', 'schedule', etc.
ISSUE_NUMBER: ${{ github.event.issue.number }}
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_BODY: ${{ github.event.issue.body }}
ISSUE_COUNT_TO_PROCESS: '3' # Process 3 issues at a time on schedule
run: python contributing/samples/adk_triaging_agent/main.py
PYTHONPATH: contributing/samples
run: python -m adk_triaging_agent.main
@@ -0,0 +1,51 @@
name: Upload ADK Docs to Vertex AI Search
on:
# Runs once per day at 16:00 UTC
schedule:
- cron: '00 16 * * *'
# Manual trigger for testing and fixing
workflow_dispatch:
jobs:
upload-adk-docs-to-vertex-ai-search:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Clone adk-docs repository
run: git clone https://github.com/google/adk-docs.git /tmp/adk-docs
- name: Clone adk-python repository
run: git clone https://github.com/google/adk-python.git /tmp/adk-python
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Authenticate to Google Cloud
id: auth
uses: 'google-github-actions/auth@v3'
with:
credentials_json: '${{ secrets.ADK_GCP_SA_KEY }}'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install google-adk markdown google-cloud-storage google-cloud-discoveryengine
- name: Run Answering Script
env:
GITHUB_TOKEN: ${{ secrets.ADK_TRIAGE_AGENT }}
GOOGLE_CLOUD_PROJECT: ${{ secrets.GOOGLE_CLOUD_PROJECT }}
GOOGLE_CLOUD_LOCATION: ${{ secrets.GOOGLE_CLOUD_LOCATION }}
VERTEXAI_DATASTORE_ID: ${{ secrets.VERTEXAI_DATASTORE_ID }}
GOOGLE_GENAI_USE_VERTEXAI: 1
GCS_BUCKET_NAME: ${{ secrets.GCS_BUCKET_NAME }}
ADK_DOCS_ROOT_PATH: /tmp/adk-docs
ADK_PYTHON_ROOT_PATH: /tmp/adk-python
PYTHONPATH: contributing/samples
run: python -m adk_answering_agent.upload_docs_to_vertex_ai_search
+19
View File
@@ -82,6 +82,7 @@ log/
.env.development.local
.env.test.local
.env.production.local
uv.lock
# Google Cloud specific
.gcloudignore
@@ -97,3 +98,21 @@ Thumbs.db
*.bak
*.tmp
*.temp
# AI Coding Tools - Project-specific configs
# Developers should symlink or copy AGENTS.md and add their own overrides locally
.adk/
.claude/
CLAUDE.md
.cursor/
.cursorrules
.cursorignore
.windsurfrules
.aider*
.continue/
.codeium/
.githubnext/
.roo/
.rooignore
.bolt/
.v0/
+597
View File
File diff suppressed because it is too large Load Diff
+1022 -5
View File
File diff suppressed because it is too large Load Diff
+103 -71
View File
@@ -2,25 +2,24 @@
We'd love to accept your patches and contributions to this project.
- [How to contribute](#how-to-contribute)
- [Before you begin](#before-you-begin)
- [Sign our Contributor License Agreement](#sign-our-contributor-license-agreement)
- [Review our community guidelines](#review-our-community-guidelines)
- [Contribution workflow](#contribution-workflow)
- [Finding Issues to Work On](#finding-issues-to-work-on)
- [Requirement for PRs](#requirement-for-prs)
- [Large or Complex Changes](#large-or-complex-changes)
- [Testing Requirements](#testing-requirements)
- [Unit Tests](#unit-tests)
- [Manual End-to-End (E2E) Tests](#manual-end-to-end-e2e-tests)
- [Documentation](#documentation)
- [Development Setup](#development-setup)
- [Code reviews](#code-reviews)
- [How to contribute](#how-to-contribute)
- [Before you begin](#before-you-begin)
- [Sign our Contributor License Agreement](#sign-our-contributor-license-agreement)
- [Review our community guidelines](#review-our-community-guidelines)
- [Contribution workflow](#contribution-workflow)
- [Finding Issues to Work On](#finding-issues-to-work-on)
- [Requirement for PRs](#requirement-for-prs)
- [Large or Complex Changes](#large-or-complex-changes)
- [Testing Requirements](#testing-requirements)
- [Unit Tests](#unit-tests)
- [Manual End-to-End (E2E) Tests](#manual-end-to-end-e2e-tests)
- [Documentation](#documentation)
- [Development Setup](#development-setup)
- [Code reviews](#code-reviews)
## Before you begin
# Before you begin
## Sign our Contributor License Agreement
### Sign our Contributor License Agreement
Contributions to this project must be accompanied by a
[Contributor License Agreement](https://cla.developers.google.com/about) (CLA).
@@ -34,73 +33,104 @@ was for a different project), you probably don't need to do it again.
Visit <https://cla.developers.google.com/> to see your current agreements or to
sign a new one.
## Review our community guidelines
### Review our community guidelines
This project follows
[Google's Open Source Community Guidelines](https://opensource.google/conduct/).
# Contribution workflow
### Code reviews
## Finding Issues to Work On
All submissions, including submissions by project members, require review. We
use GitHub pull requests for this purpose. Consult
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
information on using pull requests.
- Browse issues labeled **`good first issue`** (newcomer-friendly) or **`help wanted`** (general contributions).
- For other issues, please kindly ask before contributing to avoid duplication.
## Contribution workflow
### Finding Issues to Work On
## Requirement for PRs
- Browse issues labeled **`good first issue`** (newcomer-friendly) or **`help
wanted`** (general contributions).
- For other issues, please kindly ask before contributing to avoid
duplication.
- All PRs, other than small documentation or typo fixes, should have a Issue assoicated. If not, please create one.
- Small, focused PRs. Keep changes minimal—one concern per PR.
- For bug fixes or features, please provide logs or screenshot after the fix is applied to help reviewers better understand the fix.
- Please include a `testing plan` section in your PR to talk about how you will test. This will save time for PR review. See `Testing Requirements` section for more details.
### Requirement for PRs
- All PRs, other than small documentation or typo fixes, should have an Issue
associated. If a relevant issue doesn't exist, please create one first or
you may instead describe the bug or feature directly within the PR
description, following the structure of our issue templates.
- Small, focused PRs. Keep changes minimal—one concern per PR.
- For bug fixes or features, please provide logs or screenshot after the fix
is applied to help reviewers better understand the fix.
- Please include a `testing plan` section in your PR to describe how you
will test. This will save time for PR review. See `Testing Requirements`
section for more details.
### Large or Complex Changes
## Large or Complex Changes
For substantial features or architectural revisions:
- Open an Issue First: Outline your proposal, including design considerations and impact.
- Gather Feedback: Discuss with maintainers and the community to ensure alignment and avoid duplicate work
- Open an Issue First: Outline your proposal, including design considerations
and impact.
- Gather Feedback: Discuss with maintainers and the community to ensure
alignment and avoid duplicate work
## Testing Requirements
### Testing Requirements
To maintain code quality and prevent regressions, all code changes must include comprehensive tests and verifiable end-to-end (E2E) evidence.
To maintain code quality and prevent regressions, all code changes must include
comprehensive tests and verifiable end-to-end (E2E) evidence.
#### Unit Tests
### Unit Tests
Please add or update unit tests for your change. Please include a summary of passed `pytest` results.
Please add or update unit tests for your change. Please include a summary of
passed `pytest` results.
Requirements for unit tests:
- **Coverage:** Cover new features, edge cases, error conditions, and typical use cases.
- **Location:** Add or update tests under `tests/unittests/`, following existing naming conventions (e.g., `test_<module>_<feature>.py`).
- **Framework:** Use `pytest`. Tests should be:
- Fast and isolated.
- Written clearly with descriptive names.
- Free of external dependencies (use mocks or fixtures as needed).
- **Quality:** Aim for high readability and maintainability; include docstrings or comments for complex scenarios.
- **Coverage:** Cover new features, edge cases, error conditions, and typical
use cases.
- **Location:** Add or update tests under `tests/unittests/`, following
existing naming conventions (e.g., `test_<module>_<feature>.py`).
- **Framework:** Use `pytest`. Tests should be:
- Fast and isolated.
- Written clearly with descriptive names.
- Free of external dependencies (use mocks or fixtures as needed).
- **Quality:** Aim for high readability and maintainability; include
docstrings or comments for complex scenarios.
### Manual End-to-End (E2E) Tests
#### Manual End-to-End (E2E) Tests
Manual E2E tests ensure integrated flows work as intended. Your tests should cover all scenarios. Sometimes, it's also good to ensure relevant functionality is not impacted.
Manual E2E tests ensure integrated flows work as intended. Your tests should
cover all scenarios. Sometimes, it's also good to ensure relevant functionality
is not impacted.
Depending on your change:
- **ADK Web:**
- Use the `adk web` to verify functionality.
- Capture and attach relevant screenshots demonstrating the UI/UX changes or outputs.
- Label screenshots clearly in your PR description.
- **ADK Web:**
- **Runner:**
- Provide the testing setup. For example, the agent definition, and the runner setup.
- Execute the `runner` tool to reproduce workflows.
- Include the command used and console output showing test results.
- Highlight sections of the log that directly relate to your change.
- Use the `adk web` to verify functionality.
- Capture and attach relevant screenshots demonstrating the UI/UX changes
or outputs.
- Label screenshots clearly in your PR description.
## Documentation
- **Runner:**
For any changes that impact user-facing documentation (guides, API reference, tutorials), please open a PR in the [adk-docs](https://github.com/google/adk-docs) repository to update relevant part before or alongside your code PR.
- Provide the testing setup. For example, the agent definition, and the
runner setup.
- Execute the `runner` tool to reproduce workflows.
- Include the command used and console output showing test results.
- Highlight sections of the log that directly relate to your change.
### Documentation
For any changes that impact user-facing documentation (guides, API reference,
tutorials), please open a PR in the
[adk-docs](https://github.com/google/adk-docs) repository to update the relevant
part before or alongside your code PR.
## Development Setup
1. **Clone the repository:**
```shell
@@ -110,11 +140,13 @@ For any changes that impact user-facing documentation (guides, API reference, tu
2. **Install uv:**
Check out [uv installation guide](https://docs.astral.sh/uv/getting-started/installation/).
Check out
[uv installation guide](https://docs.astral.sh/uv/getting-started/installation/).
3. **Create and activate a virtual environment:**
**NOTE**: ADK supports Python 3.9+. Python 3.11 and above is strongly recommended.
**NOTE**: ADK supports Python 3.10+. Python 3.11 and above is strongly
recommended.
Create a workspace venv using uv.
@@ -128,7 +160,8 @@ For any changes that impact user-facing documentation (guides, API reference, tu
source .venv/bin/activate
```
**windows**
**Windows**
```shell
source .\.venv\Scripts\activate
```
@@ -147,11 +180,11 @@ For any changes that impact user-facing documentation (guides, API reference, tu
pytest ./tests/unittests
```
NOTE: for accurately repro test failure, only include `test` and `eval` as
extra dependencies.
NOTE: for accurate repro of test failure, only include `test`, `eval` and
`a2a` as extra dependencies.
```shell
uv sync --extra test --extra eval
uv sync --extra test --extra eval --extra a2a
pytest ./tests/unittests
```
@@ -164,14 +197,14 @@ For any changes that impact user-facing documentation (guides, API reference, tu
./autoformat.sh
```
7. **Build the wheel file:**
7. **Build the wheel file:**
```shell
uv build
```
8. **Test the locally built wheel file:**
Have a simple testing folder setup as mentioned in the
8. **Test the locally built wheel file:** Have a simple testing folder setup as
mentioned in the
[quickstart](https://google.github.io/adk-docs/get-started/quickstart/).
Then following below steps to test your changes:
@@ -200,12 +233,11 @@ For any changes that impact user-facing documentation (guides, API reference, tu
## Contributing Resources
[Contributing folder](https://github.com/google/adk-python/tree/main/contributing/samples) has resources that is helpful for contributors.
[Contributing folder](https://github.com/google/adk-python/tree/main/contributing)
has resources that are helpful for contributors.
## Vibe Coding
## Code reviews
All submissions, including submissions by project members, require review. We
use GitHub pull requests for this purpose. Consult
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
information on using pull requests.
If you want to contribute by leveraging vibe coding, the AGENTS.md
(https://github.com/google/adk-python/tree/main/AGENTS.md) could be used as
context to your LLM.
+52 -20
View File
@@ -1,53 +1,64 @@
# Agent Development Kit (ADK)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
[![PyPI](https://img.shields.io/pypi/v/google-adk)](https://pypi.org/project/google-adk/)
[![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)
<a href="https://codewiki.google/github.com/google/adk-python"><img src="https://www.gstatic.com/_/boq-sdlc-agents-ui/_/r/Mvosg4klCA4.svg" alt="Ask Code Wiki" height="20"></a>
<html>
<h2 align="center">
<img src="https://raw.githubusercontent.com/google/adk-python/main/assets/agent-development-kit.png" width="256"/>
</h2>
<h3 align="center">
An open-source, code-first Python toolkit for building, evaluating, and deploying sophisticated AI agents with flexibility and control.
An open-source, code-first Python framework for building, evaluating, and deploying sophisticated AI agents with flexibility and control.
</h3>
<h3 align="center">
Important Links:
<a href="https://google.github.io/adk-docs/">Docs</a>,
<a href="https://google.github.io/adk-docs/">Docs</a>,
<a href="https://github.com/google/adk-samples">Samples</a>,
<a href="https://github.com/google/adk-java">Java ADK</a> &
<a href="https://github.com/google/adk-java">Java ADK</a>,
<a href="https://github.com/google/adk-go">Go ADK</a> &
<a href="https://github.com/google/adk-web">ADK Web</a>.
</h3>
</html>
Agent Development Kit (ADK) is a flexible and modular framework for developing and deploying AI agents. While optimized for Gemini and the Google ecosystem, ADK is model-agnostic, deployment-agnostic, and is built for compatibility with other frameworks. ADK was designed to make agent development feel more like software development, to make it easier for developers to create, deploy, and orchestrate agentic architectures that range from simple tasks to complex workflows.
Agent Development Kit (ADK) is a flexible and modular framework that applies
software development principles to AI agent creation. It is designed to
simplify building, deploying, and orchestrating agent workflows, from simple
tasks to complex systems. While optimized for Gemini, ADK is model-agnostic,
deployment-agnostic, and compatible with other frameworks.
---
## 🔥 What's new
- **Custom Service Registration**: Add a service registry to provide a generic way to register custom service implementations to be used in FastAPI server. See [short instruction](https://github.com/google/adk-python/discussions/3175#discussioncomment-14745120). ([391628f](https://github.com/google/adk-python/commit/391628fcdc7b950c6835f64ae3ccab197163c990))
- **Rewind**: Add the ability to rewind a session to before a previous invocation ([9dce06f](https://github.com/google/adk-python/commit/9dce06f9b00259ec42241df4f6638955e783a9d1)).
- **New CodeExecutor**: Introduces a new AgentEngineSandboxCodeExecutor class that supports executing agent-generated code using the Vertex AI Code Execution Sandbox API ([ee39a89](https://github.com/google/adk-python/commit/ee39a891106316b790621795b5cc529e89815a98))
## ✨ Key Features
- **Rich Tool Ecosystem**: Utilize pre-built tools, custom functions,
OpenAPI specs, or integrate existing tools to give agents diverse
OpenAPI specs, MCP tools or integrate existing tools to give agents diverse
capabilities, all for tight integration with the Google ecosystem.
- **Code-First Development**: Define agent logic, tools, and orchestration
directly in Python for ultimate flexibility, testability, and versioning.
- **Agent Config**: Build agents without code. Check out the
[Agent Config](https://google.github.io/adk-docs/agents/config/) feature.
- **Tool Confirmation**: A [tool confirmation flow(HITL)](https://google.github.io/adk-docs/tools/confirmation/) that can guard tool execution with explicit confirmation and custom input.
- **Modular Multi-Agent Systems**: Design scalable applications by composing
multiple specialized agents into flexible hierarchies.
- **Deploy Anywhere**: Easily containerize and deploy agents on Cloud Run or
scale seamlessly with Vertex AI Agent Engine.
## 🤖 Agent2Agent (A2A) Protocol and ADK Integration
For remote agent-to-agent communication, ADK integrates with the
[A2A protocol](https://github.com/google-a2a/A2A/).
See this [example](https://github.com/google-a2a/a2a-samples/tree/main/samples/python/agents/google_adk)
for how they can work together.
## 🚀 Installation
### Stable Release (Recommended)
@@ -58,7 +69,7 @@ You can install the latest stable version of ADK using `pip`:
pip install google-adk
```
The release cadence is weekly.
The release cadence is roughly bi-weekly.
This version is recommended for most users as it represents the most recent official release.
@@ -71,6 +82,13 @@ pip install git+https://github.com/google/adk-python.git@main
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.
## 🤖 Agent2Agent (A2A) Protocol and ADK Integration
For remote agent-to-agent communication, ADK integrates with the
[A2A protocol](https://github.com/google-a2a/A2A/).
See this [example](https://github.com/a2aproject/a2a-samples/tree/main/samples/python/agents)
for how they can work together.
## 📚 Documentation
Explore the full documentation for detailed guides on building, evaluating, and
@@ -88,7 +106,7 @@ from google.adk.tools import google_search
root_agent = Agent(
name="search_assistant",
model="gemini-2.0-flash", # Or your preferred Gemini model
model="gemini-2.5-flash", # Or your preferred Gemini model
instruction="You are a helpful assistant. Answer user questions using Google Search when needed.",
description="An assistant that can search the web.",
tools=[google_search]
@@ -103,13 +121,13 @@ Define a multi-agent system with coordinator agent, greeter agent, and task exec
from google.adk.agents import LlmAgent, BaseAgent
# Define individual agents
greeter = LlmAgent(name="greeter", model="gemini-2.0-flash", ...)
task_executor = LlmAgent(name="task_executor", model="gemini-2.0-flash", ...)
greeter = LlmAgent(name="greeter", model="gemini-2.5-flash", ...)
task_executor = LlmAgent(name="task_executor", model="gemini-2.5-flash", ...)
# Create parent agent and assign children via sub_agents
coordinator = LlmAgent(
name="Coordinator",
model="gemini-2.0-flash",
model="gemini-2.5-flash",
description="I coordinate greetings and tasks.",
sub_agents=[ # Assign sub_agents here
greeter,
@@ -135,9 +153,23 @@ adk eval \
## 🤝 Contributing
We welcome contributions from the community! Whether it's bug reports, feature requests, documentation improvements, or code contributions, please see our
- [General contribution guideline and flow](https://google.github.io/adk-docs/contributing-guide/#questions).
- [General contribution guideline and flow](https://google.github.io/adk-docs/contributing-guide/).
- Then if you want to contribute code, please read [Code Contributing Guidelines](./CONTRIBUTING.md) to get started.
## Community Repo
We have [adk-python-community repo](https://github.com/google/adk-python-community) that is home to a growing ecosystem of community-contributed tools, third-party
service integrations, and deployment scripts that extend the core capabilities
of the ADK.
## Vibe Coding
If you want to develop agent via vibe coding the [llms.txt](./llms.txt) and the [llms-full.txt](./llms-full.txt) can be used as context to LLM. While the former one is a summarized one and the later one has the full information in case your LLM has big enough context window.
## Community Events
- [Completed] ADK's 1st community meeting on Wednesday, October 15, 2025. Remember to [join our group](https://groups.google.com/g/adk-community) to get access to the [recording](https://drive.google.com/file/d/1rpXDq5NSH8-MyMeYI6_5pZ3Lhn0X9BQf/view), and [deck](https://docs.google.com/presentation/d/1_b8LG4xaiadbUUDzyNiapSFyxanc9ZgFdw7JQ6zmZ9Q/edit?slide=id.g384e60cdaca_0_658&resourcekey=0-tjFFv0VBQhpXBPCkZr0NOg#slide=id.g384e60cdaca_0_658).
## 📄 License
This project is licensed under the Apache 2.0 License - see the [LICENSE](LICENSE) file for details.
+3 -3
View File
@@ -52,16 +52,16 @@ echo '---------------------------------------'
echo '| Auto-formatting src/...'
echo '---------------------------------------'
find -L src/ -type f -name "*.py" -exec pyink --config pyproject.toml {} +
find -L src/ -not -path "*/.*" -type f -name "*.py" -exec pyink --config pyproject.toml {} +
echo '---------------------------------------'
echo '| Auto-formatting tests/...'
echo '---------------------------------------'
find -L tests/ -type f -name "*.py" -exec pyink --config pyproject.toml {} +
find -L tests/ -not -path "*/.*" -type f -name "*.py" -exec pyink --config pyproject.toml {} +
echo '---------------------------------------'
echo '| Auto-formatting contributing/...'
echo '---------------------------------------'
find -L contributing/ -type f -name "*.py" -exec pyink --config pyproject.toml {} +
find -L contributing/ -not -path "*/.*" -type f -name "*.py" -exec pyink --config pyproject.toml {} +

Some files were not shown because too many files have changed in this diff Show More