Session
Import path: obtained via air.session(session_id). Session itself is exported at top level as from air import Session for type hints, but is not constructed directly by application code in the documented usage pattern.
Constructor
Session(air, session_id: str, store: ContextStore)Not intended to be called directly; use air.session(session_id) instead, which supplies air and the correct store for you.
Attributes
session_id: str
Methods
async chat(message: str | ChatRequest, provider: str | None = None) -> ChatResponse
message: a plain string (becomes one user message) or aChatRequest.provider: if given, overridesChatRequest.providerfor this call only. Behaves like explicit provider selection: no fallback,ProviderNotFoundErrorif the name is not registered.
Loads this session's prior messages, combines them with message, calls air.chat(...) with the combined request, stores the new user message(s) and the assistant's reply, and returns the ChatResponse.
async history() -> list[dict]
Returns every stored message for this session as a list of dicts with keys role, content, provider, model, created_at. provider/model are only set on assistant entries.
async clear() -> None
Removes this session's stored messages. The session id remains known (still returned by air.list_sessions() when using the SQLite backend).
async delete() -> None
Removes this session entirely, including its id from air.list_sessions().
Example
session = air.session("user-123")
await session.chat("My name is Alex")
response = await session.chat("What is my name?")
print(response.content)
history = await session.history()
for entry in history:
print(entry["role"], entry["content"])See ../core/sessions.md for full behavior, including what is and is not persisted.