Subcore AI Docs
Agents API

Agent config

The read a running deployment makes on every call. Its payload, its refusals, the three settings that connect a deployment to it, what it reports for each session's direction and outcome, how it offers each agent relay or realtime voice, how many quiet minutes end each agent's text conversations, and where a text escalation goes when no person can join.

GET /agent-config/{routingKey}

Your deployment makes this read on every call an agent takes, between the webhook arriving and the agent answering. It fetches the agent's settings and its stored prompt files, uncached, so an edit made through the agents API is live on the next call.

From kit 0.31.0 every conversation on a deployment is an agent's, so every one waits on this read. A request that arrives without a routing key is refused before anything is read: a text door answers 404 with code: "routing_key_required" and names the {tenantPath}/… path to use, and a voice webhook fails, so the number's own fallback takes the call. Before 0.31.0 such a request was answered with the deployment's own files and no read.

You do not call it yourself. It is documented here so that the path your prompts take to a call is visible, and so a deployment's logs can be read without guesswork.

Authentication

The deployment sends its own key, the deployment key, as a bearer token. The routing key in the URL identifies the agent; the API key authenticates the caller and confines the answer to its organization and to the cores its permissions.cores reaches. The manage-agents permission is not needed here, and the deployment key does not have it.

A key issued in the console reaches every agent in its organization, so one deployment key serves all of them and a new agent needs nothing added to it. Whether a key may read agents is a single setting rather than a list, so a key that has it turned off is refused for every agent, not for some. That is the 403 below, and it is a key that changed rather than an agent that is missing something.

The payload

{
  "version": 1,
  "agent": {
    "slug": "clinic-one",
    "name": "Clinic One",
    "instructionSource": "database",
    "timezone": "America/New_York",
    "phoneNumber": "+15035550142",
    "transferNumber": "+15035550188",
    "variables": { "clinicName": "Clinic One" },
    "model": "gemini-3.8-flash",
    "channelOverrides": { "sms": { "model": "grok-4.3", "disabledTools": [], "enabledTools": ["lookup_customer"] } },
    "toolsOptIn": true,
    "recordCalls": false,
    "sessionIdleMinutes": { "default": 20, "sms": 15 }
  },
  "instructions": {
    "main": [
      {
        "path": "instructions.md",
        "content": "…",
        "versionId": "sha256-860e7daee313",
        "updatedAt": "2026-09-16T18:00:21.418Z"
      }
    ]
  }
}
FieldDescription
versionThe dialect of this payload, currently 1. A consumer that does not recognise the version must refuse rather than guess
agentThe agent's settings: the Agent object without routingKey, tenantPath, deployment and kind. The caller already holds the routing key it asked on, and the other three answer questions about managing an agent rather than serving a call. variables is here, since prompts are compiled from it
instructionsA map from directory to the stored File objects, content included. Empty for a repo agent
twilioOnly for a key whose permissions.twilioCredentials is exactly true. The agent's Twilio credentials, { "accountSid", "apiKeySid", "apiKeySecret", "authToken" }, with authToken null when none is stored. null when the agent has no Twilio account connected. Any other key reads the payload without this field

agent.variables is that agent's own prompt variables, which the deployment exposes to its prompts as tenant. followed by each name. It is always an object and {} for an agent with none, so a deployment never has to tell "no variables" from "this payload does not carry them". Reading it needs kit 0.21.1 or later, and an older deployment simply never looks at the field.

agent.model, agent.channelOverrides and agent.toolsOptIn are the agent's model and tools, always served: null and {} for an agent that changed nothing, and every channel entry with model, disabledTools and enabledTools. The voice entry also holds voice when one is stored. Kit 0.32.0 applies the model and disabledTools to every call, kit 0.33.0 applies toolsOptIn and enabledTools too, and kit 0.36.0 reads voice and a realtime model on voice, and kit 0.43.0 reads voice on relay and on the default engine too. An older deployment ignores what it does not know.

agent.recordCalls says whether the deployment records the agent's calls. It is always served, and false until someone turns it on. A deployment on a kit before 0.49.0 ignores it, and a structural one never records, whatever it says.

agent.sessionIdleMinutes is how many minutes of silence end the agent's text conversations: a map from channel to whole minutes from 1 to 10080 (seven days), where default covers every channel the map does not name. It is always served, and {} for an agent that set nothing. It has the channels the agent set and no others: no defaults are filled in, because the number that applies on a channel with neither its own minutes nor a default is the deployment's own. Each value is served cut to the longest window the deployment reading can honour, which kit 0.40.0 sends in a Subcore-Session-Idle-Max-Minutes request header, and to 1440 for a read without it. Kit 0.38.0 reads the field, and an older deployment ignores it. See when a text conversation ends.

The deployment's own code reads the same map. That is how a setting such as an agent's voice reaches a call, from kit 0.28.2. Since this read happens on every call, a value you change applies from the agent's next call.

twilio is how the deployment calls and texts through the agent's own Twilio account. It comes last, after instructions:

"twilio": {
  "accountSid": "AC91db41b217eb50ad8d1efe2e98e89b5d",
  "apiKeySid": "SKdcbc75091596bec79d4a36cc5342d953",
  "apiKeySecret": "R8nv9DNPpzdJUjykdMWtZKg8MHV97NMD",
  "authToken": "f10f5865a07223801b74f027a69d1c5e"
}

It is the one answer on api.subcore.ai that carries a Twilio secret, which is why it goes only to a key allowed to read it. A kit before 0.22.0 ignores the field, and a later one treats a missing field and null alike: the deployment's own Twilio credentials.

versionId is byte-identical to the id the deployment computes for the same file on disk, so a stored file and a repo file can share one provenance record. updatedAt is ISO 8601 UTC with milliseconds and a Z, the same form the File object carries on the instruction routes.

What it answers

CaseAnswer
An agent on repo200 with "instructions": {}, from one indexed lookup. The deployment's own files answer the call
An agent on database with files stored200 with every stored file, read in one statement, so an answer cannot straddle an edit
An agent on database with no file stored409 NO_INSTRUCTIONS, never an empty 200
A routing key that does not exist, is malformed, or belongs to another organizationA bare 404 NOT_FOUND. An agent created before 16 October 2026 also answers on the 32-character key it had before
A key whose permissions.cores does not reach the agent403 FORBIDDEN
A failed query500 DATABASE_ERROR
A key with twilioCredentials, when the agent's stored Twilio credentials cannot be read500 DATABASE_ERROR, never the payload without twilio

Every refusal is deliberately unambiguous. An agent that reads its prompts from the database and cannot get them has to fail the call, so that the number's own failover takes over. Nothing here answers with a shape a deployment could read as "carry on with defaults". A missing agent is a bare 404, a database agent with nothing stored is a 409, and a failed read is a 500. The 500 is kept apart from the 404 because a missing agent is permanent and a failed read is not. For the same reason, a key allowed to read Twilio credentials never gets the payload without twilio: a deployment would read that as "use your own credentials" and send from the wrong account.

No rate limit, no writes

The read is not rate limited, for the same reason telemetry ingestion is not: it sits on a deployment's call path, and a 429 here would fail a live call. It writes nothing, not even the key's last-used timestamp, because it runs inside a voice-latency budget. Every answer is Cache-Control: no-store.

The alias under /api

The same route also answers on

GET /api/agent-config/{routingKey}

That is the path a deployment on kit 0.18.0 builds from its SUBCORE_CONSOLE_URL setting, so a deployment moves its config read to api.subcore.ai by changing that one setting, without a kit release. The alias stays until a kit release reads this service directly.

Connecting your deployment

Three settings in the deployment's environment tie it to this API. The rest of the deployment's configuration is documented with the deployment itself.

SettingValueWhat it does
SUBCORE_API_KEYThe deployment keyAuthenticates the config read and the telemetry the deployment ships. From kit 0.31.0 it is required: without it no agent can be read, so no conversation is answered, and a deployment running with NODE_ENV=production refuses to start
SUBCORE_CONSOLE_URLhttps://api.subcore.aiWhere the config read goes
TELEMETRY_PROFILEstructuralEvents leave the deployment without conversation content
SUBCORE_API_KEY=sk_live_...
SUBCORE_CONSOLE_URL=https://api.subcore.ai
TELEMETRY_PROFILE=structural

A deployment that calls and texts through its agents' own Twilio accounts needs SUBCORE_CONSOLE_URL=https://api.subcore.ai: only this service serves the twilio field, on /agent-config and on the /api/agent-config alias.

The deployment key is not the key that manages agents. It is issued from the deployment's own page in the Subcore console, not from an agent's. It reads configuration and sends telemetry. It cannot manage agents, and it never has the manage-agents permission.

To give a deployment its agents' Twilio credentials, tick Read Twilio credentials on its key in the Subcore console. The permission is denied unless it is exactly true, and the manage-agents permission does not imply it.

What structural covers

From kit 0.25.0, structural also keeps conversation text and phone numbers out of the lines the kit writes to the deployment's own logs. Logs follow TELEMETRY_PROFILE unless LOG_PROFILE is set to full or structural.

The voice library under the kit, @subcore-ai/echo, writes lines of its own, and they carry every caller's number and every sentence they say. From kit 0.26.1, structural covers those too, once the deployment's app.ts passes the kit's logger to its server:

import { echoLogger } from '@subcore-ai/kit/log-content'

const server = new EchoServer({
  port: Number(process.env.PORT ?? 3000),
  hostname: process.env.HOSTNAME ?? 'localhost',
  logger: echoLogger(),
})

A project created with bunx @subcore-ai/kit create on kit 0.26.1 or later passes it already. structural does not reach what your own code logs, or two kinds of lines echo writes straight to the console: a relay message it cannot parse, and the message of an error a call handler throws.

From kit 0.34.0, structural also stops the Subcore console from reading or taking over a conversation. Before that release the console could read a conversation's messages from the deployment and take over a text conversation, which sent the operator's reply through Subcore. On a structural deployment the console's conversation routes now refuse, on the bare path and under {tenantPath}. The channel doors, such as {tenantPath}/chat/message, keep answering customers. The routes that refuse are:

GET  /api/conversations/{sessionId}
GET  /api/conversations/{sessionId}/messages
POST /api/conversations/{sessionId}/claim
POST /api/conversations/{sessionId}/messages
POST /api/conversations/{sessionId}/handback

Each one answers 404 with this body:

{
  "error": "Conversations stay in this deployment",
  "code": "conversations_withheld",
  "detail": "This deployment keeps conversation content out of Subcore (its TELEMETRY_PROFILE resolves to structural), so no conversation can be read or taken over here."
}

The console's credential is still checked first, so a request without a valid one gets 401, and a deployment with no console credential configured answers 503. The refusal comes before any conversation or agent is looked up, so it says nothing about whether either exists. The deployment's manifest, /.well-known/subcore-agent.json, declares capabilities.conversations and capabilities.takeover as false whatever Twilio the deployment has, and still lists their endpoints.

A deployment counts as structural here when its TELEMETRY_PROFILE is anything but full or unset. A value the kit does not recognise counts too, so a typo cannot open the console's routes again. The kit's eval runs always count as full, since nobody real takes part in them. Those are the runs a project starts with the kit's own eval harness. An eval the console runs is answered by the deployment itself and takes its profile, so a structural deployment runs no tool live there, whatever evals.liveToolIds lists. The intent tools still run their own code, as on any deployment: the voice lifecycle tools on voice, the kit's escalate_to_human on text, and core0's handoff_to_agent in handoff mode. A deployment that needs takeover has to run full, and its conversation content then reaches Subcore.

A structural deployment also never records a call, whatever an agent's recordCalls says, since a recording is what the caller said. Its describe document reports deployment.callRecording as false. See call recordings.

That leaves the project behind a structural deployment two things to handle:

  • A transcript leaves the deployment only through the project's conversationRecords.onClosed hook (kit 0.24.0), which hands your code each conversation as it closes, to send wherever you keep records.
  • Nobody can claim a text escalation, so from kit 0.41.0 none of them parks. escalate_to_human sends the agent to your own handoff tool, such as one that takes a message for your team, when lifecycle.textHandoffToolId names it. Otherwise it tells the agent that no one can join. Before 0.41.0 a project that named no handoff tool parked every text escalation here, and the customer then got your awaitingHumanReply to every message after that. Have your text prompts say where a person will see the problem instead of promising one. See where a text escalation goes.

The Playground in the Subcore console, the evals it runs, and the conversation tools on the MCP server still work on a structural deployment. Each carries what you type or a case says, and the agent's reply, through Subcore, so use them with test data only.

Who holds which agreement

Subcore receives no content from a structural deployment's conversations with its customers. It does receive each conversation's session id, and an SMS conversation's id embeds the customer's phone number.

You contract every service the deployment itself uses: its hosting, its memory store, the model and voice vendors it sends each turn to, and Twilio. Any agreement one of those services needs, such as a HIPAA business associate agreement, is between you and that vendor. An agent that calls and texts through its own Twilio account is the exception: that account belongs to your client, so any agreement it needs is between your client and Twilio.

Session direction and outcomes

From kit 0.35.0, the console shows every session's direction, inbound or outbound, and one outcome, named from the agent's own outcomes. The deployment reports facts and never an outcome. The console decides the outcome when it reads the session.

What the deployment reports

Three telemetry events, beside the tool.completed that every tool call which returns already sends:

EventDataSent
conversation.started{ "direction": "inbound" | "outbound" }Once per session, with its first turn
session.ended{ "endedBy": "person" | "agent" | "unknown", "transferred", "voicemail" }When a real phone call ends, on relay and realtime voice
escalation.routed{ "route": "takeover" | "handoff" | "none", "handoffToolId" }From kit 0.41.0, each time a text turn asks for a person
  • A call is outbound when POST /outbound placed it. An SMS session is outbound when a text sent through POST /sms/send opened it. Every other session is inbound: a call someone made, a text they sent, chat, email and the Playground. An SMS thread that stays quiet long enough to start a new session sends its own.
  • endedBy is agent when the agent ended or transferred the call, or the kit hung up after a voicemail. It is person when the caller hung up first, and unknown when the kit hung up because a realtime call's audio failed. transferred is true when the transfer tool handed the call to a number, and voicemail when the voicemail tool fired.
  • Texts and Playground sessions have no hang-up, so they never send session.ended. A text conversation ends on silence instead.
  • route says where an escalation went: takeover when the thread parked for a person who can join it, handoff when it went to your textHandoffToolId, which handoffToolId then names, and none when no one could take it. handoffToolId is null on the other two. The tool.completed of escalate_to_human reads the same on all three routes, so this is the event that tells them apart. See where a text escalation goes.

None of the three carries conversation content, so each arrives with every field under TELEMETRY_PROFILE=structural. Sending them never delays or fails a turn. session.ended rides the call's last batch, and Subcore starts the call's summary when it arrives. Read them like any other event, with GET /telemetry/events and eventType=session.ended, for instance. A session from a deployment on a kit before 0.35.0 has neither of the first two, so the console shows no direction or outcome for it. One before 0.41.0 sends no escalation.routed.

There is nothing to set: the kit sends all three from its own handlers.

Naming your outcome tools

A project names the tools whose success means a conversation got somewhere in outcomeByToolId, a map of tool id to outcome. In kit 0.35.0 the map moves from conversationRecords to lifecycle, so it applies whether or not the project registers a records hook. There is no alias:

// before
lifecycle: { taskCompletionToolId: 'book_appointment', /* … */ },
conversationRecords: { onClosed, outcomeByToolId: { book_appointment: 'booked', take_message: 'message_taken' } },

// after
lifecycle: {
  taskCompletionToolId: 'book_appointment',
  /* … */
  outcomeByToolId: { book_appointment: 'booked', take_message: 'message_taken' },
},
conversationRecords: { onClosed },

A map written inline under conversationRecords fails typecheck. A map held in a const and registered there still compiles, and from 0.35.0 nothing reads it. The kit's 0.35.0 changelog has a command that finds both.

The deployment refuses to start when a key names a tool it wires to no channel, other than the kit's own escalate_to_human (below), or when an outcome is blank, longer than 40 characters, or has space around it. The console stores outcome names of at most 40 characters.

Leave the transfer, end-call and voicemail tools out of the map. Their outcomes come from how the call ended, below. A key naming one renames that role: transfer_call: 'handed_off' announces and records a transfer as handed_off.

What describe announces

The describe document, which the console reads and describe_deployment returns, announces outcomes in two places. Both are additive, so describeVersion stays 1.

Each tool under tools whose id the map names carries outcome, on every channel that lists it:

{ "id": "book_appointment", "description": "…", "outcome": "booked" }

deployment.outcomes lists every outcome a session of the deployment can have, shallowest first, as { "outcome", "when", "toolId" }. when is { "tool": "<tool id>" } or { "event": "agent_ended" | "voicemail" | "transferred" }, and toolId, on an event entry, names the tool behind it. With no map, a deployment whose lifecycle names its end-call, voicemail and transfer tools announces the kit's four:

"outcomes": [
  { "outcome": "call_ended", "when": { "event": "agent_ended" }, "toolId": "end_call" },
  { "outcome": "escalated", "when": { "tool": "escalate_to_human" } },
  { "outcome": "voicemail", "when": { "event": "voicemail" }, "toolId": "leave_voicemail" },
  { "outcome": "transferred", "when": { "event": "transferred" }, "toolId": "transfer_call" }
]

The order is fixed. An ended call comes first, since nearly every finished call ends that way. Then come your mapped tools, in the map's order, then the escalation, a voicemail and a transfer. A role's entry appears only where lifecycle names its tool.

The call roles key on how the call ended, never on their tool completing. The kit refuses or undoes each in some calls by answering the tool call rather than failing it, so "the transfer tool succeeded" would call a transfer with no number to go to a transferred call. For the same reason, the role tools carry no outcome under tools.

The kit hands escalate_to_human to every SMS, chat and email turn, beside your own tools. From 0.35.0, describe lists it on those channels after your tools, with locked: true, since no agent's tool switch reaches it, and names its success escalated. A key in your map renames it, and yours wins. There is no default on a project that sets textHandoffToolId: an escalation the kit sends to that tool still completes escalate_to_human as a tool call, so name the handoff tool's outcome instead. From 0.41.0, on a project that does not set it, escalated also names an escalation the kit answered with "no one can join", since that call completes too. escalation.routed tells the two apart.

These are suggestions. The console starts each agent's default outcomes from deployment.outcomes, filtered to the tools the agent runs, and never names a session's outcome from describe by itself. After a redeploy, refresh the deployment in the console so it reads the new description.

The conversation record

A record that conversationRecords.onClosed receives names its outcome by the kit's own precedence, not by the agent's list in the console: a transfer, then a voicemail, then the last successful tool among those the map names and the kit's escalation, then hung_up for a call the person ended first, else answered. A call the agent ended stays answered. From 0.35.0, a record can read escalated where it used to read answered or hung_up, so handle it in onClosed, or rename it in the map. From 0.41.0, on a project that does not set textHandoffToolId, that includes a text conversation whose escalation the kit answered with "no one can join".

Relay or realtime voice

From kit 0.36.0, a deployment can let each agent choose its voice engine: relay, where Twilio ConversationRelay turns speech into text for a text model from modelOptions, or realtime, where a speech model from xAI or Gemini Live holds the call. Agents choose on their voice entry. It is opt-in: until a project registers realtimeOptions, its deployment answers every call the way VOICE_MODE says, as before. From kit 0.43.0 an agent can also choose the voice of its relay calls, once the project registers relayVoices.

Offering realtime models

Register realtimeOptions on the runtime beside modelOptions, keyed by the id an agent stores:

realtimeOptions: {
  'grok-voice-3.0': {
    provider: 'xai',
    model: 'grok-voice-3.0',
    voices: ['ara', 'rex', 'sal', 'eve', 'leo'],
    defaultVoice: 'ara',
    default: true,
  },
  'gemini-live-2.5-flash': {
    provider: 'gemini',
    model: 'gemini-live-2.5-flash',
    voices: ['Aoede', 'Puck', 'Charon'],
    defaultVoice: 'Aoede',
  },
},

The kit holds no catalogue of providers' models or voices, so name the ones you have keys for and are willing to pay for. The deployment refuses to start when:

  • an id is in both modelOptions and realtimeOptions, so a stored model always names one engine;
  • no option, or more than one, is the default;
  • an option's defaultVoice is not one of its voices;
  • an xai option is registered without XAI_API_KEY. A gemini option uses GOOGLE_GENERATIVE_AI_API_KEY, which every deployment already needs.

VOICE_MODE becomes the default engine, the one a call takes when its agent chose nothing. With realtimeOptions registered, the deployment serves both engines whatever VOICE_MODE says, and a call that defaults to realtime uses the option marked default. REALTIME_PROVIDER, the ?model= on XAI_REALTIME_ENDPOINT and the voice set in the environment decide no call. The boot check on VOICE_MODE=realtime still wants REALTIME_PROVIDER's key, and an unset REALTIME_PROVIDER means xAI, so a deployment that defaults to realtime and offers only Gemini sets REALTIME_PROVIDER=gemini.

The describe document lists the options as deployment.realtimeOptions, which the console and describe_deployment read:

"realtimeOptions": [
  { "id": "grok-voice-3.0", "provider": "xai", "default": true, "voices": ["ara", "rex", "sal", "eve", "leo"], "defaultVoice": "ara" },
  { "id": "gemini-live-2.5-flash", "provider": "gemini", "voices": ["Aoede", "Puck", "Charon"], "defaultVoice": "Aoede" }
]

The list is [] when the project registers none, and keeps the order you registered. deployment.models.voice still reports only the default engine: on a deployment that defaults to realtime, the id of the option marked default.

An agent can be given an option you add, or a model you add to modelOptions, once the console has read the build that registers it. Until then PUT /agents/{slug} and the console refuse it, so after a redeploy, refresh the deployment in the console.

Offering relay voices

From kit 0.43.0, register relayVoices on the runtime to let each agent choose the voice its relay calls speak in. It is one list that every relay text model shares, keyed by the voice id an agent stores:

relayVoices: {
  UgBBYS2sOqTuMpoF3BR0: { name: 'Mark', description: 'US male, young and casual', default: true },
  r1KmysJdVYZjJCm4mL3b: { name: 'Jessica', description: 'US female, young and warm' },
},

Each voice has a name, an optional description of how it sounds, which the console shows after the name, and an optional provider, the text-to-speech service Twilio ConversationRelay renders it with: ElevenLabs when absent, the one these voices are built for, or Google or Amazon. The id is the one ConversationRelay takes for that provider, such as an ElevenLabs voice id. Exactly one voice is the default. The kit holds no catalogue of voices, so list ones you have listened to on a phone call, and mark as default the voice your relay calls speak in today, so an agent that chooses none hears no change. The kit cannot ask Twilio whether a listed voice still exists. What a call does with one Twilio cannot render, such as a library voice its creator withdrew, has not been tested, so take such a voice off the list and redeploy; the agents that chose it then speak in the default.

The deployment refuses to start when:

  • an id is not one an agent can store, 1 to 128 printable ASCII characters with no space;
  • a name is blank or over 40 characters, or a description is not text or is over 80;
  • a provider is not ElevenLabs, Google or Amazon;
  • there are more than 64 voices, or not exactly one default: true;
  • the list is an array, keyed by index rather than by id, or a value that is not an object at all, such as a string or a number;
  • the deployment never answers a call on relay: VOICE_MODE=realtime, unless realtimeOptions and modelOptions both offer something, so an agent can choose a relay text model. A project whose VOICE_MODE differs between environments registers the list only where relay runs.

An empty list, or null, is the same as none. The list works with or without realtimeOptions, and needs the project's @subcore-ai/echo to be the kit's own copy, 0.6.0 or later, which writes each call's voice into its TwiML; with another copy the deployment does not start. Kit 0.43.0 holds realtimeOptions to the same echo, so move the project's echo to 0.6.0 with the kit.

With the list registered, the voice marked default is the deployment's relay voice. The voice your EchoServer's defaults name, such as TTS_VOICE_ID in the kit's subcore-box example, or echo's own where app.ts passes none, voices no call, and a call refused before it reaches an agent speaks in the default too. Without the list, every relay call speaks in the EchoServer's defaults, as before.

The describe document lists the voices as deployment.relayVoices, with provider always present:

"relayVoices": [
  { "id": "UgBBYS2sOqTuMpoF3BR0", "name": "Mark", "description": "US male, young and casual", "provider": "ElevenLabs", "default": true },
  { "id": "r1KmysJdVYZjJCm4mL3b", "name": "Jessica", "description": "US female, young and warm", "provider": "ElevenLabs" }
]

The list is [] when the project registers none. A realtime option can name its voices the same way: voiceInfo, keyed by voice id, gives some or all of its voices a name and a description, held to the same limits, and the deployment refuses to start on a key the option's voices does not list. Describe publishes it beside voices, and a voice without an entry shows its id:

voiceInfo: { ara: { name: 'Ara', description: 'warm and friendly' } },

As with realtime options, an agent can be given a voice you add once the console has read the build that registers it.

How a call picks its engine

The kit decides on every call, inbound or placed with POST /outbound, from the agent's voice entry alone:

  1. A voice model in realtimeOptions goes realtime with that option, and one in modelOptions goes relay with that text model. Anything else, or null, takes VOICE_MODE, and on realtime the default option.
  2. The agent-wide model never picks the engine. It still picks the text model of a relay call whose voice entry names none.
  3. On realtime, the voice is the agent's stored voice if the option lists it, else the one your realtimeVoice hook names, else the option's defaultVoice. The hook is still asked, so a rule of your own, such as one that reads the value an agent stores for a voice setting, keeps working.
  4. On relay, from kit 0.43.0, the voice is the agent's stored voice if relayVoices lists it, else the one marked default. Your realtimeVoice hook is never asked on relay. Without relayVoices, the EchoServer's defaults speak, as before.
  5. From kit 0.43.0 the stored voice is read against the engine the call runs, whatever picked it. A call on the default engine, because the voice model is null or one you no longer offer, reads it against that engine's list too. A voice the engine does not list takes that engine's default: a realtime voice on a relay call speaks in the default relay voice, and a relay voice on a realtime call goes to your hook, then the option's defaultVoice.

Step 5 changes one stored choice. Before 0.43.0, a voice kept from a realtime option you dropped went with that option, and the call spoke in your hook's choice or the default option's defaultVoice. Now it plays on the default option whenever that option lists it, and the hook is not asked. Before you drop a realtime option, clear the voice of each agent on it that your hook should voice.

Nothing about a choice fails a call. An option the deployment no longer offers, a provider key missing at call time, or a voice the call's engine does not list falls back, and the kit logs it once. A routing key that refuses a call still does.

When a text conversation ends

From kit 0.38.0, each agent decides how many minutes of silence end its text conversations, channel by channel. Before that release a single setting decided it for every agent on a deployment: SMS_SESSION_TIMEOUT_MINUTES, which defaults to 30. An agent stores its minutes as sessionIdleMinutes, and the deployment reads them with the rest of the agent's configuration.

The minutes that apply to a conversation decide what silence does to it:

  • An SMS thread quiet for longer than that starts a new session with the customer's next text. With that text, the kit tells the agent how long the customer was away and that the gap passed the limit, so the agent asks whether to carry on or start fresh.
  • In a project with conversationRecords, the record of an SMS, chat or email conversation closes one minute after that, and onClosed receives it. For SMS that is the moment the thread would start a new session, so a closed conversation is not joined again. The exception is an agent whose SMS minutes go up mid-conversation: a close already due under the shorter window goes out, the next text still falls inside the longer one, and onClosed receives the session's record a second time under the same id.
  • A chat or email session id belongs to whoever sends the turn, so silence never starts a new chat or email session. On those two channels, closing the record is all it does. A customer who writes again after it closes continues the same session, and onClosed receives a second record under the same id, carrying the whole session.

Since the same id can arrive twice, have your records hook update the record it already holds for that id rather than add another.

Calls end when someone hangs up. No number of quiet minutes ends one, and an agent's voice minutes change nothing on the deployment.

Which minutes apply

For a conversation on a channel, the deployment takes the first of these that is set:

  1. the agent's minutes for that channel;
  2. the agent's default;
  3. the deployment's own SMS_SESSION_TIMEOUT_MINUTES, on every text channel.

An agent that stores { "default": 20, "sms": 15 } starts a new SMS session once a thread has been quiet for more than 15 minutes, and closes a chat or email record 21 minutes after its last message. With { "sms": 15 } alone, chat and email fall back to the deployment's number. A deployment whose agents set nothing behaves as it did before 0.38.0.

The minutes arrive with the agent's configuration, so a change applies from the conversation's next message. A record already waiting to close keeps the window its last message set.

How long a conversation can stay open

An agent can store up to 10080 minutes, seven days, but each deployment honours only as long as it keeps the conversation. The deployment holds a conversation's transcript in its memory store and builds the record from it when the conversation closes. A failing onClosed is retried for a day after that. The store forgets a conversation once its time to live (TTL) has passed since the last message. So from kit 0.40.0 a deployment honours its memory TTL less a day, and never less than 1440 minutes:

Memory TTLLongest window
2 days, Memorystore's default on Cloud Run1440 minutes (24 hours)
3 days, Upstash's default2880 minutes (48 hours)
4 days4320 minutes (72 hours)
8 days or more, or never10080 minutes (seven days)

Kit 0.40.0 sends that maximum on every config read, in whole minutes:

Subcore-Session-Idle-Max-Minutes: 4320

The read cuts each of the agent's minutes to it, and to 1440 for a read that sends no such header, so the number that holds is the one of the deployment actually reading, whichever deployment in your organization answers. Kit 0.38.0 sends none, so it is always served 1440 or less, which is all it accepts: it would fail a call whose payload held a longer value. A longer row that still reaches a 0.40.0 deployment is cut to its maximum with one warning, and the call succeeds.

To keep conversations open longer, raise the deployment's memory TTL to the window plus a day, for example 4 days for 72 hours. On Cloud Run that is pulumi config set cloudrun:memoryTtl 345600; elsewhere set MEMORYSTORE_TTL or UPSTASH_TTL, in seconds. Then redeploy and refresh the deployment in the console. Every conversation's transcript then stays that long in the store, so weigh it against how long you want customers' messages kept there.

What describe reports

The describe document reports the deployment's side as deployment.sessionIdle. It is additive, so describeVersion stays 1:

"sessionIdle": { "channels": ["sms", "chat", "email"], "fallbackMinutes": 30, "maxMinutes": 1440 }

channels lists the channels the deployment ends on silence, which never include voice. fallbackMinutes reports the number it uses on those channels for an agent that stores neither the channel's minutes nor a default, which is the value of its SMS_SESSION_TIMEOUT_MINUTES. The kit reads that setting from the deployment's environment, not from this entry, which only reports it. From kit 0.40.0, maxMinutes reports the longest window it honours, worked out from its memory TTL (above); a deployment that reports none accepts 1440. A deployment on a kit before 0.38.0 reports no sessionIdle, and ends every text conversation on that setting whatever the agent stores. The console reads the field, and describe_deployment returns it. After you redeploy on 0.38.0, refresh the deployment in the console so it reads the new description.

Setting the minutes

An admin sets an agent's minutes on its Connection tab in the console, as its Session timeout: on the routing map, each channel's timeout is shown under it and edited in that channel's side sheet, in minutes or hours, and Other channels, the default row, covers the rest. Where there is no map, the same times are a card with a row per channel. A channel without a time of its own shows the number that applies: the agent's default row when it has one, else the deployment's fallbackMinutes on a channel in its sessionIdle.channels, and otherwise the console's own default for that channel. The console holds each time to the maxMinutes of the deployment the agent names, or to 24 hours when that deployment reports none, and times a session's automatic summary by the same number. The setting used to sit on the Summary Generation tab, where it decided only the summaries.

The agents API returns the minutes on the Agent object, but does not change them. A PUT /agents/{slug} that sends sessionIdleMinutes is refused with 400 UNKNOWN_FIELD.

Minutes stored before kit 0.38.0 start ending conversations when the deployment upgrades, and nothing announces it. Until then they decided only when the console summarized a session. An agent given 5 minutes on SMS for quicker summaries starts a new SMS session after 5 quiet minutes once its deployment runs 0.38.0. Before you upgrade, read each agent's sessionIdleMinutes with GET /agents, and in the console change any row you do not want to end conversations. A records hook that counts on each text record arriving SMS_SESSION_TIMEOUT_MINUTES plus one minute after the last message has to take that delay per agent instead.

Where a text escalation goes

The kit hands the agent escalate_to_human on every SMS, chat and email turn. Calling it parks the conversation in awaiting_human: every customer message after that gets your awaitingHumanReply, until a person claims the conversation in the console and hands it back. Only one kind of text conversation can be claimed: an SMS thread on a full deployment with Twilio to reply through, from the agent's own account or the deployment's. A takeover reply goes out as a text, so a chat or email conversation never can be, and a structural deployment refuses takeover.

Kit 0.41.0 parks only a conversation a person can claim. On every other one it answers escalate_to_human itself, with success: false, and nothing parks:

  • Where lifecycle.textHandoffToolId names your own handoff tool and every agent has that tool on the channel, the answer tells the agent to call it, as it has since 0.35.0.
  • Otherwise the answer tells the agent that no one can join, to say so and to offer any other way to reach your team that its prompt gives. That answer is the kit's DEFAULT_TEXT_ESCALATION_UNAVAILABLE_RESULT, unless you set your own as lifecycle.textEscalationUnavailableResult.
  • A turn that fails is not escalated. The customer gets your emptyReplyFallback, and the conversation stays with the agent.
  • A conversation already in awaiting_human goes back to the agent with the customer's next message, with a note in its history saying why.

Before 0.41.0, a project that named no handoff tool parked every chat and email escalation, and every SMS one on a structural deployment. The customer was told a person was on the way, then got awaitingHumanReply to every message until the session ended. Where a person can join, nothing changes. A Playground conversation takes the route a real one on its channel would.

Naming where a person will see it

A customer told that no one can join needs another way to reach your team. Either wire a handoff tool to the channel, such as one that takes a message for your team, and set lifecycle.textHandoffToolId to it, or give escalate_to_human an answer of your own that names the way: a number to call, an address to write to. The answer goes in the project's agents/core.ts:

lifecycle: {
  /* … */
  textEscalationUnavailableResult: {
    success: false,
    _instruction:
      'This conversation was NOT handed to a person: no one can join it. Do not say anyone is ' +
      'joining or will reply here. Tell the customer a person reads every message sent to ' +
      'support@example.com, and ask them to write there.',
  },
},

The agent's model reads it, and the customer never sees it. The kit sets escalated: false on it whatever it says. It is used only where no person can join and no handoff tool applies.

Signals only a parked conversation sends

Only a conversation that parks sends the chat stream's lifecycle line with "event": "escalated", escalated: true on the email door's reply, and core0's escalation.requested telemetry. Before 0.41.0, chat and email escalations sent them on a project that named no handoff tool. A chat host or an email caller that brought a person in when it saw escalated no longer sees it there. Give that channel a handoff tool that does what the host did, and set textHandoffToolId to it.

Every escalation, whichever route it took, sends escalation.routed. The console's default Escalated outcome holds whenever escalate_to_human completes, so it also names a session the kit answered with "no one can join". See the defaults.

Nothing announces this change when a deployment upgrades to 0.41.0. A prompt that promises a person on chat or email, with lines such as "let me connect you" or "someone will be with you shortly", is now contradicted by what escalate_to_human tells the model. Before you upgrade, change those prompts, including the prompt files an agent stores in the console or through the agents API. Have the agent call escalate_to_human and say what its answer says, or call your handoff tool. Then re-run your chat and email escalation evals, and fail any case where the agent tells the customer someone is joining.

On this page