Skip to content

Shared conversation

Ana, Ben and Chloe share one Familiar in one named room. Each has their own session and client, so every message and every tool call belongs to the person who sent it.

Everything runs in this page: the real core, in-memory storage, the HTTP API and its event stream, and one client store per person. The three sessions are simulated in the frame, so other tabs and visitors don’t join. Only the model is scripted. Choose who to Send as below the suggestions, send something, then choose someone else and try:

  • Note for the group: I can bring dessert
  • What did Ana say?
  • Who am I?
  • Count me in

What did Ana say? quotes Ana’s latest earlier message from the input Familiar sent the model. That shows the Familiar’s working context reaching the model, not long-term memory. The script understands only these exact phrases. Anything else, including Don't count me in, gets a reply listing them. Reloading or pressing Reset starts over.

The host opens a workspace with one Familiar and one named room, the group’s. It maps each session to an Author, and createHttpApi takes the author from the request’s session, never its body. It allows only posting, history, Stop and the events of that one room, so every participant is refused memory, schedules, other rooms and admin operations:

const familiar = await workspace.familiars.create({ name: 'Familiar' })
const room = await workspace.rooms.create({
name: 'Group',
familiars: [familiar.id],
})
const CHAT = new Set<Operation>([
'rooms.post',
'rooms.history',
'rooms.stop',
'events.room',
])
// The host's sign-ins: session token to the person it belongs to.
const sessions = new Map<string, Author>()
const api = createHttpApi(workspace, {
// Each request's session decides its author, never its body.
authenticate: (request) => {
const token = request.headers.get('authorization')?.replace(/^Bearer /, '')
return token ? sessions.get(token) : undefined
},
allow: (_, operation, resource) =>
CHAT.has(operation) &&
!!resource &&
'room' in resource &&
resource.room === room,
})

Everyone signed in shares the room: each person reads its whole history, and the Familiar answers with all of it in mind, including anything it remembers. Give people who mustn’t share information separate workspaces.

Each person gets their own room store, which sends their session with every request and opens its own event stream. Every store mirrors the same room:

const store = createRoomStore('https://demo.invalid', room, {
fetch: async (input, init) => {
const request = new Request(input, init)
request.headers.set('authorization', `Bearer ${token}`)
return api.fetch(request)
},
})

In a real app each person’s browser signs in to your host and sends its own cookie or token, and you pass your API’s URL. Serve the API covers authentication and Connect a frontend covers the client.

A tool never takes the person as an argument. It reads familiar(context).author(), which Familiar resolves from the message that started the turn. When Ben sends while Ana’s turn is going, Ben’s waits its turn, Ana’s tool still runs as Ana, and Ben’s as Ben:

defineTool({
name: 'count_me_in',
description: 'Adds the person asking to the guest list.',
parameters: schema.obj({}),
execute: async (_args, _api, context) => {
const author = await familiar(context).author()
if (!author) {
return result('Nobody asked, so there is no one to add.', true)
}
going.set(author.id, author)
const names = [...going.values()].map(({ name }) => name)
return result(`Counted ${author.name} in. Going: ${names.join(', ')}.`)
},
})

Each message keeps the name its author had when they sent it. A later rename on the host changes new messages, not old ones, and the id stays the same.

  • Real sign-in, or people on other devices. The sessions are simulated in one page.
  • Long-term memory. Familiar’s background memory work runs, but the script gives it a placeholder answer, and nothing outlasts the page.
  • Per-person permissions. Everyone in the room shares its Familiar’s tools; Familiar records who asked, and your tools or the app APIs behind them decide what each person may do. See Identity is not permission.

To use a real model, run the same Familiar on a server you control with a provider from Models and sign-in. Model credentials stay on that server.