One message, end to end
Number the hops. The message is saved before the model runs, the request goes to a server with room in the plan’s pool, and the reply streams back through the chat service, which saves each piece.
- The app sends the message with its session token and a
client_message_id. - The gateway checks the session and the plan, and passes the user id on.
- The chat service saves the message, loads the branch and this turn’s memories, and builds the request.
- The message is checked, and the router picks a server in the plan’s pool.
- Tokens stream back, are saved as numbered pieces and reach the app.
- At the end, usage is settled and a title and memory updates are queued.
Diagram as text
Components: App (Client); Gateway (API gateway); Chat service (Service); Conversation store (NoSQL DB); Safety check (Service); Model router (Load balancer); Model server (LLM); Usage counter (Cache); Job queue (Queue). Connections: App → Gateway (message); Gateway → Chat service (user id); Chat service → Conversation store (save, load); Chat service → Safety check (check); Chat service → Model router (request); Model router → Model server; Chat service → Usage counter (settle), asynchronous; Chat service → Job queue (title, memory), asynchronous.
Read:Learn: High-level architectureLearn: Latency budgeting
Check yourself
Why save the message before calling the model?
Show answerHide answer
It exists under its id even if the model call fails, a retry finds it, and a second device shows it at once.