Represents a series of interactions between a user and agents.
| 26 | |
| 27 | |
| 28 | class Session(BaseModel): |
| 29 | """Represents a series of interactions between a user and agents.""" |
| 30 | |
| 31 | model_config = ConfigDict( |
| 32 | extra="forbid", |
| 33 | arbitrary_types_allowed=True, |
| 34 | alias_generator=alias_generators.to_camel, |
| 35 | populate_by_name=True, |
| 36 | ) |
| 37 | """The pydantic model config.""" |
| 38 | |
| 39 | id: str = Field( |
| 40 | description="Unique identifier of the session.", |
| 41 | examples=["session-abc123"], |
| 42 | ) |
| 43 | app_name: str = Field( |
| 44 | description="Application name that owns the session.", |
| 45 | examples=["hello_world"], |
| 46 | ) |
| 47 | user_id: str = Field( |
| 48 | description="User ID that owns the session.", |
| 49 | examples=["user-123"], |
| 50 | ) |
| 51 | state: dict[str, Any] = Field( |
| 52 | default_factory=dict, |
| 53 | description="Current persisted session state.", |
| 54 | examples=[{"locale": "en-US"}], |
| 55 | ) |
| 56 | events: list[Event] = Field( |
| 57 | default_factory=list, |
| 58 | description=( |
| 59 | "Ordered event history for the session, including user, model, and" |
| 60 | " tool events (e.g. user input, model response, function" |
| 61 | " call/response)." |
| 62 | ), |
| 63 | ) |
| 64 | last_update_time: float = Field( |
| 65 | default=0.0, |
| 66 | description=( |
| 67 | "Unix timestamp in seconds for the most recent session update." |
| 68 | ), |
| 69 | examples=[1_742_000_000.0], |
| 70 | ) |
| 71 | |
| 72 | _storage_update_marker: str | None = PrivateAttr(default=None) |
| 73 | """Internal storage revision marker used for stale-session detection.""" |
no outgoing calls