InMemoryChatStorage
InMemoryChatStorage holds a single conversation for the lifetime of the instance. It is the right choice when you do not need persistence across app restarts, or when you want to inject a prior conversation into a session at construction time.
public actor InMemoryChatStorage: ChatStorage { public init(_ messages: [ConversationMessage] = [])}| Parameter | Default | Notes |
|---|---|---|
messages | [] | Starting conversation. Preserved in full — fetch trims only the returned view, so a loaded conversation is never clipped at construction time. |
Fresh session:
let store = InMemoryChatStorage()let orchestrator = Orchestrator(agents: [agent], store: store)Seeding a prior conversation — hand the Orchestrator an existing exchange so the agent has context from the start:
let prior: [ConversationMessage] = loadPriorConversation() // your retrieval logiclet store = InMemoryChatStorage(prior)let orchestrator = Orchestrator(agents: [agent], store: store)The seeded messages are stored in full; fetch trims only the returned view via trimToEvenPairs, so the loaded conversation is never clipped at construction time.
Behavior
Section titled “Behavior”- Scope-agnostic.
userId,sessionId, andagentIdare ignored — every read and write targets the same history. This is what allows seeding without knowing the consumer’sagentId. - No
[agentId]attribution.fetchAllChatsreturns the whole conversation unattributed. - No persistence. History is lost when the instance is deallocated.
See also: Storage overview · FileChatStorage · DeviceChatStorage · Custom store