{#- Failures first: what broke, how often, and whether the turn survived. Built from the timeline's rows, so scoping and the content mode already apply; the error text itself stays behind the same audited reveal as the timeline. -#} {% set failures = (trace_timeline or {}).get('failures') %} {% set can_reveal_failure = trace_permissions and trace_permissions['trace.reveal'] and trace_content_mode != 'metadata' %} {% set during = (' in ' ~ trace_timeline.failure_phrase) if trace_timeline.failure_phrase else '' %} {% macro failure_ranges() -%} {%- endmacro %} {% if failures and (trace_timeline.rows or selected_root_trace_id) %}
{% if failures.total %}

{{ failures.total }} failure{{ '' if failures.total == 1 else 's' }} in {{ failures.turns }} turn{{ '' if failures.turns == 1 else 's' }}{{ during }}

{% if failures.stopped %}{{ failures.stopped }} turn{{ ' was' if failures.stopped == 1 else 's were' }} stopped or did not finish.{% else %}The agent carried on and finished {{ 'it' if failures.turns == 1 else 'all of them' }}.{% endif %}

{{ failure_ranges() }}
{% else %}

{% if trace_timeline.failure_phrase %}No failures in {{ trace_timeline.failure_phrase }}{% else %}No failures in {{ trace_timeline.rows|length }} recorded event{{ '' if trace_timeline.rows|length == 1 else 's' }}{% if selected_root_trace_id %} for this turn{% endif %}{% endif %}.

{{ failure_ranges() }}
{% endif %} {% if selected_root_trace_id %}Show every turn for this agent{% endif %}
{% endif %}