At the end of a call with an agent, I want to be a...
# ask-ai
r
At the end of a call with an agent, I want to be able to summarize the conversation using a specific summarization prompt. Is there an example of this somewhere that I could look at?
✅ 1
t
Thanks for reaching out, James. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m responding to your request for an example summarization prompt to use at the end of a call. You can add custom Summary instructions in the Agent Builder → Call ending settings. Below are a few concise example prompts you can copy and adapt depending on the tone and level of detail you want. • Short, high-level summary ◦ "Summarize the conversation in 2–3 sentences, focusing on the caller's issue, actions taken, and final outcome." • Action-oriented summary (includes next steps) ◦ "Provide a concise summary (4–6 bullet points) covering: caller problem, troubleshooting steps performed, resolution status, any follow-up actions, and assigned owner with deadlines if applicable." • Customer-facing synopsis ◦ "Write a brief, customer-friendly summary (3–4 sentences) that explains what was discussed, what was resolved, and any next steps the customer should expect." • Internal handoff summary (detailed) ◦ "Create a 5–7 sentence summary for internal records including: caller context, key timestamps, decisions made, configuration or account details referenced, unresolved issues, and recommended next actions with priority." If you want, tell me which style you prefer (short, action-oriented, customer-facing, or internal) and I’ll tailor one precise prompt that includes template variables like
{{metadata.key}}
you can use in the Agent Builder. Sources: Agent Builder | LiveKit Documentation | Collect structured data with LiveKit Agents | LiveKit, with interactive elements
r
I'm coding my own agent with the python sdk, not using the agent builder
t
Thanks — I’m responding to your note that you’re building an agent with the Python SDK (not using the Agent Builder). Below is a concise, ready-to-use example showing how to generate a call summary with a custom summarization prompt, collect messages from
ChatContext
, call an LLM, and POST the summary to your endpoint. 1) Example summarization prompts (pick one and paste into the system message) • Short: "Summarize the conversation in 2–3 sentences, focusing on the caller's issue, actions taken, and final outcome." • Action-oriented: "Produce 4–6 bullet points: caller problem, troubleshooting steps, resolution status, follow-up actions, and owner with deadlines if applicable." • Customer-facing: "Write a 3–4 sentence customer-friendly summary explaining what was discussed, what was resolved, and next steps." • Internal detailed: "Create a 5–7 sentence internal summary including caller context, key timestamps, decisions, unresolved items, and recommended next actions with priority." 2) Minimal Python example using LiveKit SDK patterns
Copy code
from livekit.agents import llm, ChatContext
import aiohttp
import asyncio

async def generate_call_summary(summarizer: llm.LLM, chat_ctx: ChatContext, system_prompt: str) -> str:
    summary_ctx = ChatContext()
    summary_ctx.add_message(role="system", content=system_prompt)
    for item in chat_ctx.items:
        if item.type == "message" and item.role in ("user", "assistant"):
            text = (item.text_content or "").strip()
            if text:
                summary_ctx.add_message(role=item.role, content=text)
    response = await summarizer.chat(chat_ctx=summary_ctx).collect()
    return response.text.strip() if response.text else ""

async def send_summary_to_endpoint(summary: str, job_id: str, room_id: str, room_name: str, endpoint: str):
    payload = {
        "job_id": job_id,
        "room_id": room_id,
        "room": room_name,
        "summary": summary
    }
    async with aiohttp.ClientSession() as session:
        async with session.post(endpoint, json=payload) as resp:
            await resp.text()

# Usage example
async def on_call_end(summarizer, chat_ctx, job_id, room_id, room_name, endpoint):
    system_prompt = "Summarize the conversation in 2–3 sentences, focusing on the caller's issue, actions taken, and final outcome."
    summary = await generate_call_summary(summarizer, chat_ctx, system_prompt)
    await send_summary_to_endpoint(summary, job_id, room_id, room_name, endpoint)
3) Key tips • Use a system message to control tone/format. • Only include
user
and
assistant
messages in the summary context to avoid tool/instruction noise. • Trigger summarization when the agent determines the call is complete (your logic: task completion, silence detection, or explicit hangup). If you want, tell me: • which prompt style you prefer and • whether you’d like the summary as sentences, bullets, or JSON fields — and I’ll return a one-line system prompt tailored to that style and an optional variant that injects template variables like
{{metadata.case_id}}
. Sources: Agents and handoffs | LiveKit Documentation | How to Use the Supervisor Pattern for Multi-Agent Voice AI Systems | LiveKi..., with interactive elements