@threadplane/reactFunctionv0.0.0

AgentProvider

Unpublished development API. This package is under development and is not available as a published release.

Owns the agent sessions of its subtree. useAgentSession(), useAgent() and <Chat /> inside it read the current session from it.

Until the first session resolves, the session shows an empty idle conversation. On a threadId change it keeps the current session until the new one resolves, and adopts only the latest change. Commands called meanwhile wait for the new session and run on it; stop goes to the current session at once. When the factory rejects, the provider keeps its current session and the waiting commands reject with the same error. Unmounting disposes every session.

import { AgentProvider } from '@threadplane/react';

Declaration · overload 1

export declare function AgentProvider<TSession extends HostedSession = AgentSession>(props: AgentProviderProps<TSession>): import("react/jsx-runtime").JSX.Element;

Type parameters

TSession
HostedSession Default: AgentSession

Parameters

props · required
AgentProviderProps<TSession>

Returns

import("react/jsx-runtime").JSX.Element

Examples

<AgentProvider
  createSession={(context) =>
    import('@threadplane/langgraph').then(({ createSession }) =>
      createSession({ apiUrl: '/api', assistantId: 'chat', ...context })
    )
  }
>
  <Chat />
</AgentProvider>