***

title: on_summary
slug: /reference/python/agents/agent-base/on-summary
description: Handle post-prompt summaries generated after a conversation ends.
max-toc-depth: 3
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

[set-post-prompt]: /docs/server-sdks/reference/python/agents/agent-base/set-post-prompt

[set-post-prompt-url]: /docs/server-sdks/reference/python/agents/agent-base/set-post-prompt-url

Callback method invoked when a post-prompt summary is received after a conversation
ends. Override this method in a subclass to process summaries -- for example, saving
them to a CRM, triggering follow-up workflows, or logging call outcomes.

A post-prompt must be configured via
[`set_post_prompt()`][set-post-prompt]
for summaries to be generated.

<Note>
  The default implementation does nothing. You must override it in a subclass or set a
  [`set_post_prompt_url()`][set-post-prompt-url]
  to receive summaries at an external endpoint.
</Note>

## **Parameters**

<ParamField path="summary" type="Optional[dict[str, Any]]" required={true} toc={true}>
  The summary object generated by the AI based on your post-prompt instructions.
  `None` if no summary could be extracted from the response.
</ParamField>

<ParamField path="raw_data" type="Optional[dict[str, Any]]" default="None" toc={true}>
  The complete raw POST data from the post-prompt request, including metadata
  like `call_id` and the full AI response.
</ParamField>

## **Returns**

`None`

## **Example**

```python {14}
from signalwire import AgentBase

class SupportAgent(AgentBase):
    def __init__(self):
        super().__init__(name="support", route="/support")
        self.set_prompt_text("You are a helpful customer support agent.")
        self.set_post_prompt("""
            Summarize this call as JSON:
            - intent: caller's primary intent
            - resolved: yes/no/partial
            - sentiment: positive/neutral/negative
        """)

    def on_summary(self, summary, raw_data=None):
        if summary:
            call_id = raw_data.get("call_id") if raw_data else "unknown"
            print(f"Call {call_id} summary: {summary}")
            # save_to_database(call_id, summary)

agent = SupportAgent()
agent.run()
```