Sessions
Decide what one agent may find and run for one user.
A session is the agent's view of Dexby for one user. It sets which apps and tools are in reach and what the agent may do. The model gets a few meta tools to search those tools and run them, so a catalog of thousands of tools costs a handful of definitions.
import { Dexby } from '@dexby.ai/sdk'
const dexby = new Dexby()
const created = await dexby.createSession({
userId: 'user_123',
connectors: ['slack', 'github'],
pinned: ['slack_post_message'],
policy: { readOnly: false, maxDataClass: 'pii' }
})
if (created.isErr()) throw new Error(created.error.message)
const session = created.valueGive session.tools() to your framework (Frameworks), or connect an MCP client
to session.mcpUrl (MCP).
Options
| Option | Default | Meaning |
|---|---|---|
userId | client's userId | Your id for the user. Calls use this user's connected accounts. |
connectors | every app | Connector ids in reach, such as slack. |
actions | every tool | Tool ids, or prefixes ending in *, such as github_list_*. |
pinned | none | Up to 20 tool ids the model gets as full definitions, so common calls skip the search. |
accounts | none | Which account each app uses by default: { slack: 'work' } by account id, name or label. |
allowGlobalAccounts | false | Let the agent see and use the project's global accounts. See below. |
policy.readOnly | false | Only tools that read. |
policy.maxDataClass | phi | Highest data class a tool may touch: standard, pii or phi. |
policy.allowDisconnect | false | Let the agent remove one of the user's accounts. |
policy.allowProxy | false | Let the agent send raw requests to an app's API. |
ttlMinutes | 1440 (24 h) | 5 minutes to 30 days. After that, calls answer SESSION_NOT_FOUND. |
session.state shows each app in scope with the user's connection status.
The scope covers catalog tools and the project's custom tools: MCP server
tools (connector mcp:<id>) and imported REST operations (connector openapi:<prefix>). The same
options apply to all of them. MCP server tools count as write and pii, so policy.readOnly or
maxDataClass: 'standard' leaves them out. Tools classified phi are in scope only when the project
handles health data.
Meta tools
| Tool | What the model does with it |
|---|---|
dexby_search_actions | Finds tools in scope. Can return the best matches' schemas. |
dexby_get_action_schemas | Reads the input schemas of up to 20 tools. |
dexby_execute | Runs one tool with the user's connected account. |
dexby_read_result | Pages through a result that was too long to return at once. |
dexby_list_connections | Lists the user's accounts for the apps in scope. |
dexby_connect_account | Gets a connect link to hand to the user. |
dexby_set_default_account | Changes the user's default account for an app. |
dexby_disconnect_account | Removes an account. Only with policy.allowDisconnect. |
dexby_proxy | Sends a raw request to an app's API. Only with policy.allowProxy. |
Pinned tools come after the meta tools under their own ids.
Refusals
When a call cannot run, the tool returns { ok: false, error } to the model, for example
connection_required when the app is not connected. The request can succeed at the HTTP level
while the tool returns a refusal; this does not mean the action succeeded. The error message tells
the model what to do next. Every code is listed in Errors.
Accounts
When a user has several accounts for one app, a call uses the first of:
- The account the call names.
- The session's
accountsentry for the app. - The user's default account.
- The only active account.
Several accounts and no default: the model gets account_selection_required with the choices, and
asks the user. An app that needs no sign-in reports not_required and runs with nothing connected.
Global accounts
The project's global accounts are opt-in per session:
const created = await dexby.createSession({ userId: 'user_123', allowGlobalAccounts: true })allowGlobalAccounts: false(the default): global accounts do not exist for the session. The session state,dexby_list_connections, account choices anddexby_executeleave them out, anddexby_connect_accountnever suggests one. A user without an account of their own getsconnection_required, even when the call names a global account.allowGlobalAccounts: true: global accounts are listed beside the user's own, markedglobal: true, and chosen by the usual rule. A name that matches both one of the user's accounts and a global account is never guessed.
Either way, a global account runs only the actions an admin allowed it. Anything else is refused
with not_permitted, and nothing is sent to the app.
Your own loop
Without a framework, get the definitions and run each call the model makes:
const definitions = await session.definitions('openai-strict') // or 'json-schema'
const outcome = await session.call('dexby_search_actions', { queries: ['post a slack message'] })See Frameworks for Anthropic, OpenAI, Gemini and Bedrock loops.