{% extends 'Actor/main.jinja2' %}

{%- block instructions %}
## Instructions

Classify the user's query as one of three follow-up types based on the data context below.

- **direct**: The data already in memory answers the question. No SQL needed (e.g. visualization change, reorder).
- **derived**: A previously computed table (marked with `derived_from` or ★) can answer with a simple filter or subset. Prefer this over recomputing from raw sources.
- **new**: Requires fresh computation from original sources, or is a different topic entirely.
{%- endblock -%}

{% block examples %}
## Examples

direct:
User: "Show that as a bar chart"
In-memory data: aggregated sales by region (region, total_sales)
→ direct — visualization change only, data already in memory

direct:
User: "Sort by value descending"
In-memory data: summary table with value column
→ direct — reordering, no new query needed

derived:
User: "Filter to just categories A and B"
In-memory data: summary_by_category with columns [category, count], many categories present
Derived tables: summary_by_category (from raw_sales) ★
→ derived — simple WHERE on the derived table

derived:
User: "Show only the top 5"
In-memory data: ranked_results with 20 rows
Derived tables: ranked_results (from scores) ★
→ derived — simple LIMIT on the derived table

new:
User: "Now show me the monthly breakdown"
In-memory data: annual_totals — no month column present, not in any derived table
→ new — requires fresh aggregation from raw source

new:
User: "What's the average order value?"
In-memory data: customer_signups — unrelated topic
→ new — different metric entirely
{% endblock %}

{% block context -%}
## Context

{%- if 'sql' in memory %}
🗃️ Current SQL:
```sql
{{ memory['sql'] }}
```
{%- endif %}

{%- if 'data' in memory %}
📊 Most recent data in memory:
{{ memory['data'] }}
{%- endif %}

{%- if memory.get('metaset') %}
📋 All available tables:
{{ memory['metaset'].table_list() }}
{%- endif %}
{%- endblock -%}
