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