Fency.ai

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 typePurpose
STREAMING_CHAT_COMPLETIONStream a chat completion in the browser
STRUCTURED_CHAT_COMPLETIONExtract structured data from a chat completion
MEMORY_CHATChat over SEMANTIC memories
MEMORY_SEARCHSemantic search (RAG) over SEMANTIC memories
EXPLORE_MEMORIESA 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_PRODUCTA 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

  1. Server creates a session: Your backend calls POST /v1/sessions with a createAgentTask body for that taskType, plus any guardrails or allowed actions. It returns a clientToken to the webapp.
  2. SDK starts the task: createAgentTask in the React SDK uses that token to create the agent task.
  3. Stream delivers progress: A createStream session lets the browser listen for updates.
  4. 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.

On this page