Decision tree
Pattern 1 — Session tools
Use when: the handler returns data to the agent and does not need a feature panel, history, or overlay UI. Registration: passtools to useScenaroSession (or session.start({ tools }) headless).
Handler signature:
- Registers RPC methods on connect
- Wraps your return value as
{ requestId, code: 'OK', data } - Aborts
context.signalafter 10 seconds (RPC_TIMEOUTS.FRONTEND_TOOL_MS) - Returns
{ code: 'TIMEOUT' }to the agent on timeout
Pattern 2 — FeatureProvider tools
Use when: the tool drives a UI feature panel — search results, product detail, comparison, shopping list — with history, visibility, and component rendering. Registration:FeatureProvider with a Map<string, ToolRegistryEntry> keyed by feature type
(e.g. collection-items-search).
Handler signature (different from session tools):
FeatureProvider internally mounts useFeatureToolRpc, which:
- Listens for
configon the event bus - Registers RPC methods for tools listed in the wire config
- Emits
tool:execute→ runsexecuteTool→ responds to the agent
Local FeatureManager vs SDK FeatureProvider
Both patterns exist in the Scenaro monorepo:
Experience apps typically keep a thin adapter at
src/lib/scenaro-sdk/hooks/useScenarioSession.js
that maps connect → start(), isConnected → status === 'connected', etc. The local
FeatureManager + AgentListener handle tool RPC independently of SDK FeatureProvider.
You do not need to migrate to SDK FeatureProvider unless you want to drop the vendored
feature runtime.
Config: curated vs raw
After the config handshake you get two views:events.on('config', …) receives the raw ConfigPayload. On the session,
session.on('config', …) receives the curated SessionConfig.
RPC flow (both patterns)
Topics not exposed as SDK helpers
Some protocol topics exist but have no high-level SDK API yet. Use the engine handle (room)
- manual data listeners if needed:
See Protocol topics.
Next steps
- Feature registry — registry shape and
useFeatures()API - Events and listeners — event bus catalog
- Product search recipe — full feature example
- SDK reference: react —
ToolHandlertypes