Skip to navigation

Continuity

View as MarkdownOpen in Claude

Continuity carries a conversation across a switch between voice and chat. At the end of each leg it stores the leg’s transcript and medium. The next leg of the same conversation starts with that dialogue as its convo param, followed by a user turn that records the switch and a system note not to answer again what was already handled.

install(agent) works through the agent’s per-request configuration callback and runs after the one the agent already has, so set the agent’s own callback with set_dynamic_config_callback() first. It also registers an on_call_end() handler.

from signalwire.operations.infobot import Continuity, LegStore, say_into_call

Parameters

All parameters are keyword-only.

store
LegStore | NoneDefaults to None

Where the legs are kept. Defaults to a new LegStore().

include_tools
boolDefaults to True

Whether tool calls and results from earlier legs are carried over.

switch_note
Callable[[str, str], str]

switch_note(previous_medium, current_medium) returns the system note added after the carried dialogue. Defaults to default_switch_note.

switch_turn
Callable[[str], str]

switch_turn(current_medium) returns the user turn that records the switch. Defaults to default_switch_turn.

resolve_id
Callable[[dict[str, Any]], str] | NoneDefaults to None

Returns the conversation id for a request. Defaults to the chat’s conversation_id, else the call id.

report
Callable[[dict[str, Any]], None] | NoneDefaults to None

Receives {"conversation_id": ..., "legs": [...]}, the whole conversation so far, at the end of each leg.

visitor_context
Callable[[dict[str, Any]], dict[str, Any] | None] | NoneDefaults to None

Returns global data to set from each request’s body, or None.

LegStore

LegStore(*, cache_dir=None) keeps one JSON file per conversation in a temporary directory on this host, consistent within one process. It’s meant for development. store.set_store(load=..., append=...) moves storage to your own database, with load(conversation_id) returning a list of legs and append(conversation_id, leg) returning whether it was stored.

build_seed() and medium_of(), which build the carried dialogue and read a request’s medium, are also exported from signalwire.operations.infobot.

say_into_call

say_into_call(call_id, text, *, role="assistant", client=None) speaks a message on a live AI call from elsewhere, through the REST API’s calling.ai_message(). Without client, it creates a RestClient() from the SIGNALWIRE_PROJECT_ID, SIGNALWIRE_API_TOKEN, and SIGNALWIRE_SPACE environment variables.

Example

from signalwire import AgentBase
from signalwire.operations.infobot import Continuity
agent = AgentBase(name="support", route="/support")
Continuity().install(agent)