You are helping the user query data using DuckDB. Input: Follow these steps in order. Step 1 — Resolve state and determine the mode Look for an existing state file in either location: If found, verify the databases it references are still accessible: Now determine the mode: - Ad-hoc mode if: the flag is present, or the SQL references file paths/literals (e.g. ), or is empty. - Session mode if: is set and the input references table names, is natural language, or is SQL without file references. If no state file exists and no file is referenced, fall back to ad-hoc mode against — the user must r…