Repository navigation
Closed
Labels
services[Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc[Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc
Description
Describe the issue
When using App(..., events_compaction_config=...) with ADK v1.21.0+, the session crashes after compaction is triggered (e.g., on the 4th message if compaction_interval=3).
The error is caused by event.actions.compaction being inserted as a raw dict, while downstream ADK code expects a structured object with attributes like .start_timestamp.
This leads to:
AttributeError: 'dict' object has no attribute 'start_timestamp'
To Reproduce
- Install
google-adk==1.21.0or later - Run the following code:
from google.adk.agents import LlmAgent
from google.adk.models.google_llm import Gemini
from google.adk.app import App
from google.adk.runners import Runner
from google.adk.sessions import DatabaseSessionService
from google.adk.config import EventsCompactionConfig
chatbot_agent = LlmAgent(
model=Gemini(model="gemini-2.5-flash-lite"),
name="text_chat_bot",
description="Agent with memory and compaction",
)
research_app_compacting = App(
name="research_app_compacting",
root_agent=chatbot_agent,
events_compaction_config=EventsCompactionConfig(
compaction_interval=3,
overlap_size=1,
),
)
db_url = "sqlite+aiosqlite:///my_agent_data.db"
session_service = DatabaseSessionService(db_url=db_url)
research_runner_compacting = Runner(
app=research_app_compacting,
session_service=session_service,
)
# Run 4 turns (turn 3 triggers compaction)
async def run_session():
await research_runner_compacting.run_async(
user_id="u1", session_id="compaction_demo", new_message="Turn 1"
)
await research_runner_compacting.run_async(
user_id="u1", session_id="compaction_demo", new_message="Turn 2"
)
await research_runner_compacting.run_async(
user_id="u1", session_id="compaction_demo", new_message="Turn 3"
) # compaction triggers here
await research_runner_compacting.run_async(
user_id="u1", session_id="compaction_demo", new_message="Turn 4"
) # 💥 crashes here- See the error:
File ".../contents.py", line 306, in _process_compaction_events
if compaction.start_timestamp is not None:
AttributeError: 'dict' object has no attribute 'start_timestamp'
Expected behavior
ADK should store event.actions.compaction as a structured object (e.g., CompactionAction) or automatically convert dicts to object format before accessing attributes.
Desktop (please complete the following information):
- OS: Ubuntu (Kaggle Notebook)
- Python version (
python -V): 3.12.12 - ADK version (
pip show google-adk): 1.21.0
Model Information:
- Are you using LiteLLM: No
- Which model is being used: gemini-2.5-flash-lite
Screenshots
Metadata
Metadata
Assignees
Labels
services[Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc[Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc
Activity
[-]Compaction Metadata Causes AttributeError in v1.19+[/-][+]Compaction Metadata Causes AttributeError in v1.21+[/+]wuliang229 commentedon Jan 7, 2026
@nicwang119 this should be fixed by 838530e, but the fix will not be needed by the new schema. The current schema used by DatabaseSessionService is going to be deprecated soon, and in the next release, new databases created will use the new schema with JSON serialization. See https://github.com/google/adk-python/discussions/3605 for more details.