Skip to main content

useChat DX cleanup

@baleybots/react useChat dropped its old server-mode options and useGroupChat — removed, not deprecated behind flags. Today useChat is an adapter over AI SDK's useChat: it returns AI SDK UIMessages as messages, runs the bot in the browser by default, and talks to a createChatRoute server when given api and sessionId. See React Hooks.

What was removed​

RemovedReplacement
useGroupChatuseChat for one bot; hosted crew UI uses /api/chat + useCrewSessions
apiUrl, chatId, multiAgent, agentsuseChat with model + optional storage, or api + sessionId for a createChatRoute server; hosted crew chat via product /api/chat
loadHistory, isResumingHistory via storage on client; server persistence in your route handler
pendingApproval, approveToolCall, rejectToolCallpendingApprovals + respondToToolApprovals (batch)
SendStreamingOptionsPlain send(text)
segments, sendStreamingmessages (AI SDK UIMessage[]) + ChatTurns / ChatTurn, and send

Migration​

From useGroupChat / server-mode useChat​

// Before — removed
import { useGroupChat } from '@baleybots/react';

const { messages, sendMessage } = useGroupChat({
apiUrl: 'https://your-api.com/chat',
chatId: 'conversation-123',
});

// After — client-side chat in the browser
import { useChat, ChatTurns, ChatTurn } from '@baleybots/react';
import { openai } from '@baleybots/core';

const { messages, send } = useChat({
model: openai('gpt-5.6-luna'),
systemPrompt: 'You are a helpful assistant',
});

// Render
<ChatTurns messages={messages}>
{(message) => <ChatTurn key={message.id} message={message} />}
</ChatTurns>

For multi-agent crew chat in the Baleybots product UI, connect to the host /api/chat endpoint and consume SSE with useCrewSessions — do not point useChat at a backend URL.

For your own server with tools, use createChatRoute from @baleybots/proxy-server (session HistoryStorage, streamed as an AI SDK UI message stream) and point useChat({ api, sessionId }) at it, or createBotRoute for a single-shot Processable. See Chat with Tools.

From hand-rolled message lists to ChatTurns​

// Before
{messages.map((msg) => (
<div key={msg.id}>
<b>{msg.role}:</b> {msg.content}
</div>
))}

// After
import { useChat, ChatTurns, ChatTurn } from '@baleybots/react';

const { messages } = useChat({ model: 'openai|gpt-5.6-luna' });

<ChatTurns messages={messages}>
{(message) => <ChatTurn key={message.id} message={message} />}
</ChatTurns>

From scalar approvals to batch approvals​

// Before — removed
const { pendingApproval, approveToolCall, rejectToolCall } = useChat({ tools });

// After
const { pendingApprovals, respondToToolApprovals } = useChat({ tools });

if (pendingApprovals.length > 0) {
respondToToolApprovals(
pendingApprovals.map((p) => ({ approvalId: p.approvalId, approved: true })),
);
}

Submit exactly one decision per entry in pendingApprovals before the turn resumes.

Legacy UIChatMessage[] consumers​

If another hook or analytics layer still needs OpenAI-shaped rows:

import { deriveUIMessages } from '@baleybots/core';

const messages = deriveUIMessages(history.getSegments()); // a core `History`

Key differences (summary)​

Old patternNew pattern
useGroupChat + apiUrlClient useChat or host /api/chat
messages.map(...) over { role, content }ChatTurns + ChatTurn over UIMessages
sendMessagesend
pendingApproval / approveToolCall()pendingApprovals / respondToToolApprovals([...])
multiAgent + agentsCrew UI / orchestration layer (out of scope for useChat)