Skip to content

activity_session

Session ORM Model

A session resource tracks a scoped interaction between among participants, typically:

  • a user and an agent
  • A user and multiple agents
  • Multiple agents interacting with each other

Attributes

Classes

ActivitySession

Bases: Base

A session resource tracks a scoped interaction between one or more participants, typically a user and an agent.

Attributes

__table_args__ class-attribute instance-attribute
__table_args__ = (
    Index(
        "idx__activity_session__namespace_pkid__name",
        "namespace_pkid",
        "name",
    ),
    UniqueConstraint(
        "namespace_pkid",
        "name",
        name="uc__activity_session__namespace_pkid__name",
    ),
    {"comment": __doc__},
)
__tablename__ class-attribute instance-attribute
__tablename__ = 'activity_session'
auto_created class-attribute instance-attribute
auto_created: Mapped[bool] = mapped_column(
    default=False,
    comment="Flag indicating whether the session was auto-created by the chat completions API",
)
create_ts class-attribute instance-attribute
create_ts: Mapped[datetime] = mapped_column(
    server_default=now(), comment="Record create timestamp"
)
data class-attribute instance-attribute
data: Mapped[str] = mapped_column(
    with_variant(LONGTEXT(charset="utf8mb3"), "mysql"),
    nullable=True,
    comment="Session data",
)
deleted class-attribute instance-attribute
deleted: Mapped[bool] = mapped_column(
    default=False, comment="Session soft delete flag"
)
description class-attribute instance-attribute
description: Mapped[Optional[str]] = mapped_column(
    Text,
    nullable=True,
    comment="Free-form description of the participant",
)
enabled class-attribute instance-attribute
enabled: Mapped[bool] = mapped_column(
    default=True,
    comment="Flag indicating whether the session is enabled or not",
)
managed class-attribute instance-attribute
managed: Mapped[bool] = mapped_column(
    default=False,
    comment="When true, indicates that this resource is managed by the system and should not be modified by users.",
)
memories class-attribute instance-attribute
memories: Mapped[List[Memory]] = relationship(
    back_populates="activity_session", lazy="dynamic"
)
name class-attribute instance-attribute
name: Mapped[str] = mapped_column(
    String(RESOURCE_NAME_LEN),
    unique=False,
    comment="Session resource name",
)
namespace class-attribute instance-attribute
namespace: Mapped[Namespace] = relationship(
    back_populates="activity_sessions"
)
namespace_pkid class-attribute instance-attribute
namespace_pkid: Mapped[str] = mapped_column(
    ForeignKey("namespace.pkid"),
    comment="Reference to the owning namespace",
)
participants class-attribute instance-attribute
participants: Mapped[List[Participant]] = relationship(
    secondary="activity_session_participant",
    back_populates="activity_sessions",
)
pkid class-attribute instance-attribute
pkid: Mapped[str] = mapped_column(
    String(PKID_LEN),
    primary_key=True,
    default=prefixed_uuid(__tablename__),
    comment="Unique activity session identifier",
)
settings class-attribute instance-attribute
settings: Mapped[SessionResourceSettings] = mapped_column(
    PydanticType(SessionResourceSettings),
    default={},
    nullable=False,
    comment="JSON-encoded resource settings",
)
update_ts class-attribute instance-attribute
update_ts: Mapped[datetime] = mapped_column(
    server_default=now(),
    onupdate=current_timestamp(),
    comment="Record update timestamp",
)

Functions