The assistant settings of one user (phoenix_kit_agent_user_settings, keyed by
user_uuid). A nil field means "the module default" (PhoenixKitAgent.Config);
enabled: false switches the assistant off for this user even with the agent
permission.
notify_user_uuids are extra people told when this user hits a limit (the
uuid of a deleted user is removed from every row, see
PhoenixKitAgent.UserDeletion). busy_since / busy_turn_ref are the
"one turn in flight per user" lock (PhoenixKitAgent.Turns.Locks, which
leaves updated_at alone) and updated_by_uuid the last admin who changed
the row: both are set by the caller, never cast. Money is in micro-dollars
($1 = 1_000_000).
Two changesets, for the two people who write a row: admin_changeset/2 —
the switch, the model, the admin's prompt, the limits and the notices, for
a caller that has checked agent.manage; personal_changeset/2 — the
user's own personal_instructions, nothing else. Neither casts the lock
columns, updated_by_uuid or the key. Never upsert this row with
on_conflict: :replace_all: that would wipe a live turn lock.
Summary
Functions
What an admin with agent.manage sets for a user: switch, model, the
admin's prompt, limits, notices. The caller checks the permission.
The per-user limit fields; each falls back to the module default when nil.
What the user writes for themself: personal_instructions only.
Types
@type t() :: %PhoenixKitAgent.Schemas.UserSettings{ __meta__: term(), busy_since: term(), busy_turn_ref: term(), daily_cost_limit_micro_usd: term(), daily_turn_limit: term(), enabled: term(), endpoint_uuid: term(), inserted_at: term(), max_attachment_mb: term(), max_attachments_per_message: term(), monthly_cost_limit_micro_usd: term(), notify_on_limit: term(), notify_user_uuids: term(), personal_instructions: term(), system_prompt: term(), updated_at: term(), updated_by_uuid: term(), user_uuid: term() }
Functions
@spec admin_changeset(t(), map()) :: Ecto.Changeset.t()
What an admin with agent.manage sets for a user: switch, model, the
admin's prompt, limits, notices. The caller checks the permission.
@spec limit_fields() :: [atom()]
The per-user limit fields; each falls back to the module default when nil.
@spec personal_changeset(t(), map()) :: Ecto.Changeset.t()
What the user writes for themself: personal_instructions only.