Your app can start interactive agent threads for the current member, send follow-up messages into them, and
read their replies through matter.threads.
const { threadId } = await matter.threads.start({
prompt: 'Draft a reply to Sam about the renewal, using the notes on the Acme deal.',
title: 'Reply to Sam',
})
await matter.threads.send(threadId, 'Keep it under 100 words.')
const thread = await matter.threads.get(threadId)
// -> { id, title, status, running, messages: [{ role, text, at, turnId }] }Letting the member write first#
For a “talk to Matter about this” button, open an empty thread beside your page instead.
threads.compose opens it with the composer ready, and nothing runs until the member sends.
context goes with their first message as instructions they don’t see: what the thread is about
and what to do. It resolves to { threadId } once they send, so you can save it on the record,
or to null if they close it without sending. Then no thread is made.
const thread = await matter.threads.compose({
title: `Changes to ${ad.title}`,
context: `The member wants changes to ad ${ad.id} in the Ads table. Read it first, then make the changes they ask for.`,
slot: 'writing',
})
if (thread) await matter.table('ads').update(ad.id, { thread: thread.threadId })
It works from a page in Matter’s desktop window. Elsewhere, including the phone, it fails with
unavailable. Since Matter 0.5.26.
Choosing the model#
A thread runs on the member’s default model unless you name one of your app’s model slots. On a slot, it
runs on the model the member chose for that slot, else the first of the slot’s suggestions this computer can
run, else their default, just as routines on the slot do. Your app’s later messages in the thread follow the
slot too, so if the member changes the slot’s model, the thread’s next turn uses the new one. Since Matter
0.5.6; older versions ignore slot, so raise minMatterVersion if you rely on it.
const { threadId } = await matter.threads.start({
prompt: 'Plan the next step for Ada and draft the message.',
title: 'Ada Lovelace',
slot: 'writing',
})Thread methods#
| Method | Description |
|---|---|
threads.start({ prompt, title?, slot? }) |
Starts a new thread of the app’s on this computer, on the member’s default model, or with
slot on one of your model slots. Resolves to
{ threadId }.
|
threads.compose({ title?, context?, slot?, width? }) |
Opens a new, empty thread beside this page for the member to write in. Their first message starts it,
with context as unseen instructions, as the app’s thread, on slot’s model or
their default (they can pick another). Resolves to { threadId } when they send, or
null if they close it unsent.
|
threads.send(threadId, text, { steer? }) |
Sends a follow-up message in a thread this app started, or one of its routine runs (queues if a turn
is currently running), on the thread’s slot or else the model its last turn used. With
steer: true, it joins the turn that’s running instead, when that turn’s model takes
messages mid-turn, and otherwise runs next. Use it for news the work under way should know, like a
customer writing again. Steering needs Matter 0.5.16; older versions queue it. Resolves to
{ threadId, turnId }.
|
threads.get(threadId, { limit? }) |
Returns the thread’s status, whether a turn is running, and its latest user messages and
final agent replies (default 20, max 100).
|
-
Scoped to your app: An app reads and messages only the threads it started and its routine
runs’ threads. Any other returns
not_found. -
Tools: Like a routine run, a thread your app starts gets your app’s
toolsMCP server, and works in a folder of its own.
To show a thread beside your page, open it in a panel with
matter.panels.open({ thread: threadId }). To write a doc yourself, without an agent, use
matter.docs.