-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Fix explore_adk_runtime.py to align with ADK 1.21.0 database schema
Problem
The scripts/explore_adk_runtime.py script uses outdated column names and query patterns that don't match the ADK 1.21.0 database schema. This causes multiple errors when trying to explore the ADK runtime database.
Current Schema (ADK 1.21.0)
Events table columns:
id,app_name,user_id,session_id,invocation_idauthor(VARCHAR(256)) - direct column, not in JSONactions(BLOB)long_running_tool_ids_json(TEXT)branch(VARCHAR(256))timestamp(DATETIME)content(TEXT) - JSON content, replaces oldevent_datagrounding_metadata,custom_metadata,usage_metadata,citation_metadata(TEXT)partial,turn_complete(BOOLEAN)error_code,error_message(VARCHAR)interrupted(BOOLEAN)input_transcription,output_transcription(TEXT) - new in 1.21.0
Key Changes:
- ❌
event_datacolumn does not exist (replaced bycontent) - ✅
authoris a direct column, not in JSON - ✅
contentcontains JSON data (replacesevent_data) - ✅
timestampis DATETIME (notcreated_at)
Errors Found
1. Using non-existent event_data column
Location: Multiple functions
get_session_summary()- line 740get_full_session_export()- line 1127find_and_summarize_last_agent_run()- line 663search_sessions_by_agent()- line 1809- SQL examples in help text - multiple locations
Error: sqlite3.OperationalError: no such column: e.event_data
Fix: Replace event_data with content
2. Using json_extract() on direct columns
Location: Multiple search/summarize functions
find_and_summarize_last_agent_run()- line 663:json_extract(e.event_data, '$.author')search_sessions_by_agent()- line 1809:json_extract(e.event_data, '$.author')- SQL help examples - multiple locations
Error: Should use direct column e.author instead of JSON extraction
Fix: Replace json_extract(e.event_data, '$.author') with e.author
3. parse_event_data() function expects wrong column
Location: parse_event_data() - line 448
- Function name suggests it parses
event_data, but should work withcontent - Called with
event_datavariable name in multiple places
Fix: Update function to work with content column, update variable names
4. SQL help examples use outdated schema
Location: show_sql_help() - lines 324-1490
- All examples use
event_datacolumn - Examples use
json_extract(event_data, '$.author')instead of directauthorcolumn - Examples reference
created_atinstead oftimestamp
Fix: Update all SQL examples to use current schema
Affected Functions
- ✅
search_sessions_by_text()- Already fixed (usese.content) - ❌
get_session_summary()- Usesevent_datacolumn - ❌
get_full_session_export()- Usesevent_datacolumn - ❌
find_and_summarize_last_agent_run()- Usesjson_extract(e.event_data, '$.author') - ❌
search_sessions_by_agent()- Usesjson_extract(e.event_data, '$.author') - ❌
search_by_invocation_id()- May use outdated patterns - ❌
show_sql_help()- All examples use old schema - ❌
parse_event_data()- Function name/variables need updating
Required Changes
1. Replace event_data with content
# Before:
SELECT id, invocation_id, timestamp, event_data
FROM events
WHERE session_id = ?
# After:
SELECT id, invocation_id, timestamp, content
FROM events
WHERE session_id = ?2. Use direct author column
# Before:
WHERE json_extract(e.event_data, '$.author') = ?
# After:
WHERE e.author = ?3. Update parse_event_data() function
# Before:
def parse_event_data(event_data: Optional[str]) -> Dict[str, Any]:
if not event_data:
return {}
try:
return json.loads(event_data)
except json.JSONDecodeError:
return {}
# After:
def parse_event_content(content: Optional[str]) -> Dict[str, Any]:
"""Parse event content JSON (replaces parse_event_data)."""
if not content:
return {}
try:
return json.loads(content)
except json.JSONDecodeError:
return {}4. Update variable names throughout
event_data→contentparse_event_data()→parse_event_content()- Update all function calls and variable assignments
5. Update SQL help examples
- Replace all
event_datareferences withcontent - Replace
json_extract(event_data, '$.author')withauthor - Replace
created_atwithtimestamp - Update examples to reflect current schema structure
Testing
After fixes, verify:
- ✅
--list-recent Nworks (already works) - ❌
--summarize SESSION_ID- currently fails - ❌
--summarize-last AGENT_NAME- currently fails withevent_dataerror - ❌
--search-agent AGENT_NAME- may fail withevent_dataerror - ❌
--search-text TERM- already fixed, verify still works - ❌
--export-full SESSION_ID- currently fails - ❌
--schema-only- verify shows correct schema - ❌
--sql-help- update examples
Version
- ADK Version: 1.21.0
- Script Location:
scripts/explore_adk_runtime.py - Date: 2025-12-23
Related
- ADK Schema Changes: Added
input_transcription,output_transcriptioncolumns - Previous Fix:
search_sessions_by_text()was fixed to usee.contentinstead ofe.event_data - Issue: Script needs comprehensive schema alignment update