Commit Graph

241 Commits

Author SHA1 Message Date
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
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 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
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
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
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
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
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
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
seanzhou1023 997b6a964d Merge branch 'main' into expose_credential_service 2025-07-11 15:38:27 -07:00
seanzhou1023 7de173ed90 Update test_readonly_context.py 2025-07-11 15:32:37 -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
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
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