Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/google/adk/events/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@

from google.adk.platform import time as platform_time
from google.adk.platform import uuid as platform_uuid
from google.genai import types
from pydantic import alias_generators
from pydantic import BaseModel
from pydantic import ConfigDict
from pydantic import Field
from pydantic import model_validator
from pydantic import PrivateAttr

from ..models.llm_response import LlmResponse
from .event_actions import EventActions
Expand Down Expand Up @@ -148,6 +146,8 @@ class Event(LlmResponse):
may change without notice. External code should not read, write, or
rely on its semantics.
"""
custom_metadata: dict[str, Any] | None = None
"""Application metadata that should stay attached to this event."""

# The following are computed fields.
# Do not assign the ID. It will be assigned by the session.
Expand Down
12 changes: 7 additions & 5 deletions tests/unittests/sessions/test_session_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,12 +726,14 @@ async def test_append_event_complete(session_service):
)
await session_service.append_event(session=session, event=event)

assert (
await session_service.get_session(
app_name=app_name, user_id=user_id, session_id=session.id
)
== session
restored_session = await session_service.get_session(
app_name=app_name, user_id=user_id, session_id=session.id
)
assert restored_session is not None
assert restored_session == session
assert restored_session.events[0].custom_metadata == {
'custom_key': 'custom_value'
}


@pytest.mark.asyncio
Expand Down