Agent tasks
A single invocation of the agent, performing a task.
An agent task is a single invocation of the agent, performing a task defined by the user through combined session params and the params received from the webapp during invocation.
Here are the agent tasks you can start today:
| Task type | Purpose |
|---|---|
STREAMING_CHAT_COMPLETION | Stream a chat completion in the browser |
STRUCTURED_CHAT_COMPLETION | Extract structured data from a chat completion |
MEMORY_CHAT | Chat over SEMANTIC memories |
MEMORY_SEARCH | Semantic search (RAG) over SEMANTIC memories |
EXPLORE_MEMORIES | A task made for data analysis. The agent explores METADATA and SEMANTIC memories together. It runs code and can perform advanced analytics, generate reports, and render charts for the data, giving you a powerful tool for data analytics directly in your webapp. |
EXPLORE_PRODUCT | A task made for building webapp assistants where the agent can call actions and render components defined by the user (in the browser). It can also perform simple semantic searches over memories if you need to connect a knowledge base for the agent. |
How it works
- Server creates a session: Your backend calls
POST /v1/sessionswith acreateAgentTaskbody for thattaskType, plus any guardrails or allowed actions. It returns aclientTokento the webapp. - SDK starts the task:
createAgentTaskin the React SDK uses that token to create the agent task. - Stream delivers progress: A
createStreamsession lets the browser listen for updates. - Server can inspect the task: List or get the task with a secret key via Agent tasks.
const { createAgentTask } = useAgentTasks({})
const response = await createAgentTask(
{
type: 'StreamingChatCompletion',
messages: [{ role: 'USER', content: 'Hello' }],
model: 'anthropic/claude-sonnet-4.6',
},
{
fetchCreateAgentTaskClientToken: async () => {
const res = await fetch('/api/agent-task-session', { method: 'POST' })
if (!res.ok) {
throw new Error('Failed to create agent task session')
}
const data = await res.json()
if (!data.clientToken) {
throw new Error('No clientToken in session response')
}
return { clientToken: data.clientToken }
},
},
)Examples
These examples show how you initialize each task in the React SDK. Combine them with a server-created session that returns a clientToken for that taskType. The SDK cannot start a task without that token.
StreamingChatCompletion
{
type: 'StreamingChatCompletion',
messages: [{ role: 'USER', content: 'Hello' }],
model: 'anthropic/claude-sonnet-4.6',
}StructuredChatCompletion
{
type: 'StructuredChatCompletion',
messages: [{ role: 'USER', content: 'Jane lives in Oslo.' }],
model: 'anthropic/claude-sonnet-4.6',
jsonSchema: '{"type":"object","properties":{"name":{"type":"string"}}}',
}MemoryChat
{
type: 'MemoryChat',
messages: [{ role: 'USER', content: 'What does the Acme MSA cover?' }],
model: 'anthropic/claude-sonnet-4.6',
language: 'en',
}MemorySearch
{
type: 'MemorySearch',
query: 'termination notice period',
model: 'anthropic/claude-sonnet-4.6',
language: 'en',
}ExploreMemories
{
type: 'ExploreMemories',
query: 'Which contracts renew this quarter?',
language: 'en',
}ExploreProduct
{
type: 'ExploreProduct',
query: 'Apply the open tickets filter',
}See Sessions for the matching session body, and the integration examples for streaming chat, structured chat, and explore memories.