Sign in

Agentic users

Liveblocks enables you to add AI agents to your app as first-class collaborators. Agents can edit the same multiplayer Sync documents as your users, appear in presence alongside humans, show live status, chat in realtime, reply to comments, and run from any language or workflow tool.

Agentic users

Agentic users in the AI Spreadsheet example

Features

  • Agentic editing: Let AI generate and apply document changes simultaneously with other users.
  • Edit from any language: Modify documents from Node.js, Python, or any stack with JSON Patch.
  • AI presence: Show agents working live, with avatars and focus indicators as they make changes.
  • AI status: Stream live status updates to your app with persistent feeds.
  • AI chat: Build custom multiplayer chats for agents and humans.
  • AI comments: Let agents review content and join thread discussions.

Get started

Choose the features you need. Each guide uses Next.js and can be combined with the others.

Implementation

This is an overview of how each feature can be implemented. Agents edit shared documents through Sync, appear in Presence like human users, publish working status and chat through Feeds, and reply to comments.

Agentic editing

Agents can read and modify your realtime Sync documents concurrently with your users. Generate changes with AI, then apply them with Liveblocks.mutateStorage—edits appear instantly for connected users.

import { LiveObject } from "@liveblocks/client";import { Liveblocks } from "@liveblocks/node";import { generateText, Output } from "ai";import { z } from "zod";
const liveblocks = new Liveblocks({ secret: "",});
await liveblocks.mutateStorage("my-room-id", async ({ root }) => { const document = root.toJSON();
const { output: task } = await generateText({ model: "openai/gpt-5.6-sol", output: Output.object({ schema: z.object({ title: z.string(), status: z.enum(["todo", "in-progress", "done"]), }), }), prompt: `Create a task for the launch plan. Here are current tasks: ${document}`, });
root.get("tasks").set("task-1", new LiveObject(task));});

Learn more under Agentic editing.

Editing from any language

Agentic pipelines are often built in Python or other non-JavaScript stacks. The JSON Patch endpoint lets any system edit Storage over HTTP using RFC 6902 operations, a standard LLMs already understand, allowing models to generate patches directly from natural language instructions.

import requests
operations = [ {"op": "replace", "path": "/tasks/task-1/status", "value": "done"}, {"op": "add", "path": "/tasks/task-1/reviewedBy", "value": "ai-agent"},]
response = requests.patch( "https://api.liveblocks.io/v2/rooms/my-room-id/storage/json-patch", json=operations, headers={"Authorization": "Bearer sk_prod_..."},)

Learn more in our JSON Patch guide.

AI presence

Show what agents are working on inside your app by giving them live Presence updates, such as selections, typing indicators, and online avatars. Liveblocks.setPresence allows you to set your agent’s presence.

await liveblocks.setPresence("my-room-id", {  userId: "ai-agent",  userInfo: { name: "AI agent", color: "#7c3aed" },  data: { status: "editing", focusedId: "task-1" },  ttl: 60,});

After setting presence, you can read it in your app with useOthers like any human, so existing avatar stacks, cursors, and focus indicators show AI activity with no extra UI.

import { useOthers } from "@liveblocks/react/suspense";
function AgentPresence() { const others = useOthers(); const agent = others.find((other) => other.id === "ai-agent");
return <div>{agent?.presence.data.status}</div>;}

Learn more under the Presence use case.

AI status

Presence shows that an agent is in the room right now, but it disappears when the process ends. Use Feeds to publish the agent’s working state—thinking, searching, writing, complete—and save it permanently in a history. Create a status message with Liveblocks.createFeedMessage when work starts, then update it with Liveblocks.updateFeedMessage as the agent moves through each stage.

await liveblocks.createFeedMessage({  roomId: "my-room-id",  feedId: "agent-status",  id: "current",  data: { status: "searching", label: "Searching documents…" },});
await liveblocks.updateFeedMessage({ roomId: "my-room-id", feedId: "agent-status", messageId: "current", data: { status: "writing", label: "Updating the launch plan…" }, updatedAt: Date.now(),});

In React, read the latest status with useFeedMessages and render it in your UI.

import { useFeedMessages } from "@liveblocks/react/suspense";
function AgentStatus() { const { messages } = useFeedMessages("agent-status"); const status = messages[messages.length - 1];
if (!status) { return null; }
return <p>{status.data.label}</p>;}

Keep status in its own feed, separate from chat. Learn more under Feeds.

AI chat

Use Feeds for anything the agent says that should persist: chat replies and streamed output. Append messages with Liveblocks.createFeedMessage, and stream a reply token by token by updating one message repeatedly with Liveblocks.updateFeedMessage.

await liveblocks.createFeedMessage({  roomId: "my-room-id",  feedId: "assistant",  data: { role: "assistant", content: "I’ve updated the launch plan." },});

Users who reconnect can read the full output later, unlike presence, which disappears with the connection. Use AI status for the agent’s current working state. For the complete messaging patterns, read the chat use case.

AI comments

Agents can review content and leave contextual feedback with Comments. Generate the feedback with AI, convert it with markdownToCommentBody, and post it with Liveblocks.createThread under the agent’s own user ID.

import { Liveblocks, markdownToCommentBody } from "@liveblocks/node";import { generateText } from "ai";
const liveblocks = new Liveblocks({ secret: "",});
const { text } = await generateText({ model: "openai/gpt-5.6-sol", prompt: `Review this paragraph and suggest one improvement: ${paragraph}`,});
await liveblocks.createThread({ roomId: "my-room-id", data: { comment: { userId: "ai-agent", body: markdownToCommentBody(text), }, metadata: { paragraphId: "paragraph-4" }, },});

You can also automatically trigger an agent when a user mentions it in a thread using the commentCreated webhook. Learn more under the comments use case.

Examples

Explore complete examples that combine the features described above.