import { CodeTabs } from '../views/docs/CodeTabs';
import { Callout, NextLink, PropTable } from '../views/docs/prose';
export const HANGUP_SIG_PY = `call.hangup(final_instructions: str = "")`;

export const HANGUP_SIG_TS = `await call.hangup(final_instructions?: string): Promise<void>`;

export const HANGUP_EX_PY = `@agent.on_task_complete("collect_order")
def on_order_collected(call: guava.Call):
    call.hangup(
        final_instructions="Thank them for their time, mention the confirmation number, then hang up."
    )`;

export const HANGUP_EX_TS = `agent.onTaskComplete("collect_order", async (call: guava.Call) => {
  await call.hangup(
    "Thank them for their time, mention the confirmation number, then hang up."
  );
});`;

## hangup()

`call.hangup()` is a soft hangup. Rather than cutting the call immediately, it hands the agent a final instruction and lets it close the conversation naturally before ending the call. Callers hear a proper goodbye.

<CodeTabs
  python={{ code: HANGUP_SIG_PY, filename: "signature" }}
  typescript={{ code: HANGUP_SIG_TS, filename: "signature" }}
/>

<PropTable rows={[
  {
    name: "final_instructions",
    type: "str",
    desc: "What the agent should do before hanging up. If omitted, the agent ends the conversation naturally with no special instructions.",
  },
]} />

### Example

<CodeTabs
  python={{ code: HANGUP_EX_PY, filename: "example.py" }}
  typescript={{ code: HANGUP_EX_TS, filename: "example.ts" }}
/>

<Callout>
  <span className="text-primary font-semibold">Tip:</span> Be specific in your final instructions. The agent will try to fulfill them naturally — including mentioning a confirmation number, scheduling next steps, or expressing appropriate warmth.
</Callout>

<NextLink section="reach-person" label="reach_person()" />
