Skip to content

Messaging

Messages are the medium for user-AI interaction. Users send messages and the AI streams responses, with support for Markdown rendering, code highlighting, thinking process display, and tool call cards — the entire process is visible in real time.

TypeDescriptionRendering
💬 User MessageContent entered by the userPlain text
📝 AI ReplyText generated by AIMarkdown + code highlighting
🧠 Thinking ProcessAI’s reasoning processCollapsible, Markdown rendered
⚙️ Tool CallTool requested by AI for executionInput/output cards
📄 SummaryCompressed summary after context compaction (summary)Markdown rendered
📃 Plain TextUnformatted text content (text)Plain text
🔧 Tool MessageIndependent tool role message (tool role)Input/output cards
ℹ️ System MessageSystem notificationsPlain text

MessageRole has 4 types: user, assistant, system, tool ContentType has 6 types: text, markdown, summary, thinking, toolcall_input, toolcall_output

Messages use a local-first strategy: stored locally first for immediate display, then synced asynchronously in the background. After sending a message, the user sees it appear in the UI with zero wait.

Sync StateUser-Visible Behavior
pendingMessage shows sending animation
syncedMessage displays normally
failedMessage shows failure marker + 🔄 retry button

💡 Retries use the same client_id, and the server idempotently deduplicates, so no duplicate messages are produced.

Each AI processing cycle constitutes a Turn, which has a well-defined lifecycle:

StateMeaningUser-Visible Behavior
PendingWaiting to executeMessage shows “Processing”
RunningCurrently executingAI streams output, tool cards flash
InterruptedWaiting for tool executionTool card shows “Executing”
CompletedNormal completionAI reply fully displayed
FailedExecution failedError message shown
CancelledUser cancelledStopped marker shown
MergedMerged into another turnNot displayed separately

AI replies arrive token by token in a stream, so users don’t have to wait for the complete response:

Streaming messages are transmitted via dual channels:

ChannelPurposeCharacteristics
Topic ChannelFirst chunk + final complete messagePersistent, supports offline recovery
Live ChannelIntermediate chunksNon-persistent, low latency, tolerant to loss

💡 The final complete message is pushed via the Topic channel, so even if intermediate chunks are lost, the complete content is eventually received.

Users can stop a running turn at any time:

The AI’s reasoning process is collapsed by default; users can expand it to view:

FeatureDescription
Collapsed by defaultSaves UI space
Click to expandView full reasoning process
Streaming animationPulse animation effect during generation
Markdown renderingSupports formatted display

Each RTC tool call is displayed as a card with input and output sections:

FeatureDescription
Sectioned DisplayInput parameters and output results shown independently
JSON FormattingParameters and results auto-pretty-printed
Status IndicatorRunning (🟠 orange pulse) / Completed (🟢 green)
Copy ButtonOne-click copy of input/output content

Tool Call Card UI

FeatureDescription
📊 SortingAscending by send time (oldest first)
📑 PaginationCursor-based pagination, loads history from server
📜 Auto-scrollAutomatically scrolls to bottom when new messages arrive
🔔 New Message AlertShows ”↓ New messages” button when user scrolls away from bottom
ScenarioHandling
Send failureMarked as failed, retry button displayed
IdempotencyUses client_id for deduplication; retries produce no duplicates
RTC failureExponential backoff retry (1s → 2s → 4s → … → 30s cap)