{# HTML fragment returned by POST /chat and appended to the chat thread by htmx. #} {# ----- User message (right) ----- #}
{{ message }}
{# ----- Agent reply (left) ----- #}
{# Status / intent / confidence badges #}
{% if resp.escalated %} Escalated to human {% elif resp.auto_resolved %} Auto-resolved {% endif %} {{ resp.intent | replace('_', ' ') }}
{# Answer bubble #}
{{ resp.answer }}
{# Confidence meter #}
Confidence
{{ '%.0f' % (resp.confidence * 100) }}%
{# Refund / escalation decision card #} {% if resp.refund %}
{% if resp.refund.outcome == 'approve' %} {% elif resp.refund.outcome == 'deny' %} {% else %} {% endif %} Refund decision: {{ resp.refund.outcome | upper }} {% if resp.refund.outcome == 'approve' %} · ${{ '%.2f' % resp.refund.refund_amount }} {% if resp.refund.fee_applied %}(after ${{ '%.2f' % resp.refund.fee_applied }} return-shipping fee){% endif %} {% endif %}

{{ resp.refund.reason }}

Per {{ resp.refund.policy_citation }}
{% endif %} {# Escalation explainer card (no refund object but escalated) #} {% if resp.escalated and not resp.refund %}

Handed off to a human specialist — the agent escalates sensitive or low-confidence cases instead of guessing.

{% endif %} {# Citations as chips #} {% if resp.citations %}

Sources ({{ resp.citations | length }})

{% for c in resp.citations %} {{ c.title }} {% endfor %}
{% endif %}