In-call tools
Hanging up and combining call control with hooks.
Call control is expressed the same way as every other agent capability: as tools the agent is explicitly given. An agent that should be able to hang up gets cosmo.end_call. Nothing is implied.
Hanging up: cosmo.end_call
const agent = client.agent({
instructions: '…End the call politely once the delivery window is confirmed.',
tools: [{ kind: 'server', name: 'cosmo.end_call' }],
});When the model calls it, the server ends the phone leg and the session winds down — your event stream finishes with the terminal session-ended item like any other shutdown. Without this tool the agent cannot hang up; the call ends when the human does, a silence-timeout EndCall hook fires, or your code calls session.end().
Give the model clear hang-up criteria in the instructions. The tool grants the ability; the instructions supply the judgment.
cosmo.end_call has no typed tool kind yet. In TypeScript it is opted into via the deprecated generic server-tool reference ({ kind: 'server', name: 'cosmo.end_call' }) until it graduates to a typed kind — see Server tools. The Python SDK no longer ships the generic reference, so a Python agent cannot grant model-initiated hang-up until the typed kind lands — the call ends when the human hangs up, an EndCall hook fires, or your code calls session.end().
Guarding call control
Call-control tools are server tools, so PreToolUse hooks don't intercept them — the guarantee is in which tools you grant, plus the server hooks you declare:
from cosmo_ai.hooks import SilenceTimeout, Say, EndCall
agent = client.agent(
instructions="…",
hooks=[
SilenceTimeout(timeout_seconds=30,
action=Say(prompt="Check if the caller is still there."),
max_count=2, reset_mode="on_user_speech"),
SilenceTimeout(timeout_seconds=90,
action=EndCall(farewell="I'll let you go — call back anytime.")),
],
)This combination — explicit grants, described policy, declarative timeouts — is the whole call-control story: no hidden telephony mode, just composed primitives you can read back off the agent config.