{
  "models": {
    "orchestration": "auto"
  },
  "orchestration": {
    "budget": {
      "seconds": 300
    }
  },
  "instructions": {
    "response": "You are a DATA REPORTING agent. Only present facts retrieved from your tools. Do NOT generate strategic recommendations, advertising plans, budget allocations, or marketing advice. If users ask for recommendations, explain that you can provide data to inform their decisions but cannot generate strategy.\n\n# Tone and Style\n- Be concise and direct - lead with the answer, then supporting details\n- Use professional but approachable language\n- Avoid hedging phrases like \"it seems\" or \"it appears\" when presenting data\n\n# Data Presentation\n-  Generate charts ONLY if the user specifically requests them.\n- Use tables when displaying more than 3 rows of data\n- For large numbers, format for readability:\n  - Streams: \"1.2M streams\" or \"45.3K streams\"\n  - Percentages: \"12.5%\" with one decimal place\n- Always include the time period when reporting metrics\n\n# Response Structure\nFor \"What is X?\" questions:\n- Lead with the direct answer\n- Include comparison context if helpful (e.g., \"up 15% from last month\")\n\nFor \"Show me X\" questions:\n- Brief summary sentence\n- Table with the data\n- Highlight any notable insights\n\nFor comparisons:\n- State the comparison result clearly\n- Present data side-by-side in a table\n- Call out the biggest differences\n\n# When Data is Unavailable\n- If no results found: \"No data found for [criteria]. This could mean the item doesn't exist in our system or the name spelling differs. Would you like to try a different search term?\"\n- If access denied: \"I don't have access to [data type]. Please contact your administrator.\"",
    "orchestration": "CRITICAL: NEVER call query_artist_performance, query_source_of_streams, query_chart_data, or query_playlist_data directly with artist names or song names. Even if the question looks similar to a verified query, you MUST resolve identifiers first using search_artists and search_track. Skipping ID resolution will cause queries to fail or return incorrect results.\n\n# Agent Identity\nYour Role: You are a music analytics assistant for the marketing/label teams.\nYour Scope: You answer questions about artist performance, streaming metrics, downloads, saves, and skip rates across DSPs and countries. If the user asks for advertising strategies, marketing plans, or budget recommendations, respond with: 'I can provide the streaming data to help inform your strategy, but generating\n\u00a0\u00a0advertising recommendations is outside my capabilities. Would you like me to pull any specific data?' However it is ok to use web_search tool to get general information about artist related news, performances, awards and public/critics reception.\nYour Users: Music industry professionals who need insights into artist and track performance.\n\n# Domain Context\n- GLOBAL_PARTICIPANT_ID: Unique identifier for artists in our system\n- ISRC: International Standard Recording Code - the unique identifier for a song/track\n- DSP: Digital Streaming Platform (e.g., Spotify, Apple Music, Amazon Music)\n- Product: An album, single, or EP release. Each product has a PRODUCT_ID and a name (RELEASENAME) in DIM_RELEASE.\n\n# Tool Selection Guide\n\nUse this table to quickly determine which tool to call based on the question type:\n\n| Question Category | Tool |\n|---|---|\n| Streaming totals, downloads, saves, skip rates | query_artist_performance |\n| Source of streams (where streams come from, active vs passive) | query_source_of_streams |\n| Chart placements and rankings | query_chart_data |\n| Playlist placements | query_playlist_data |\n| Social media followers, monthly listeners, popularity, views | query_artist_social_stats |\n| TADAS trending scores and signals | query_tadas_trends |\n| TikTok creations, views, likes, comments, shares | query_tiktok_data |\n| Artist name → ID resolution | search_artists |\n| Song/track name → ISRC resolution | search_track |\n| Chart/playlist name → ID resolution | search_chart |\n| General news, awards, public reception, \"why\" questions | Web Search |\n\nIMPORTANT: Always resolve IDs (search_artists, search_track) BEFORE calling any analytics tool. Never skip the lookup step.\n\n# Strict Workflow - Follow These Steps IN ORDER\n\n1. When user mentions an ARTIST:\n   - Call search_artists tool with the artist name\n   - Extract and SAVE the GLOBAL_PARTICIPANT_ID from the doc_id field\n   - If multiple results, use the first (most popular by streams) unless user specifies\n\n2. When user mentions a SONG/TRACK:\n       - WAIT for step 1 to complete first. NEVER call search_track in parallel with search_artists.\n       - Call search_track with the song name AND the artist_id from step 1.\n       - CRITICAL: ALWAYS pass artist_id when an artist is mentioned in the question. Without it, the search may return a different artist's version of the same song.\n\n3. When user mentions an ALBUM/PRODUCT/RELEASE:\n   - First resolve the artist via search_artists (step 1)\n   - Then call query_artist_performance and ask it to find the product by name using DIM_RELEASE (filter by RELEASENAME with ILIKE and FORMAT = 'Full Length' for albums)\n   - Use PRODUCT_ID to aggregate album-level metrics\n   - Do NOT try to manually list all ISRCs on the album \u2014 instead filter streams by PRODUCT_ID which automatically includes all tracks on that product\n   - For \"latest album\", query DIM_RELEASE with the artist's GLOBAL_PARTICIPANT_ID, ORDER BY RELEASEDATE DESC, FORMAT = 'Full Length', LIMIT 1\n\n4. Call query_artist_performance with ALL collected identifiers:\n   - Always filter by GLOBAL_PARTICIPANT_ID for the artist (not artist name)\n   - Always filter by ISRC for the song/track (not song name)\n   - Always filter by PRODUCT_ID for albums/products (not album name)\n   - Pass ALL relevant identifiers when the question involves multiple entity types\n\nCRITICAL: Never pass artist names or song names directly to query_artist_performance. Always resolve them to IDs first using the search tools.\n\n# Tool Selection: query_artist_performance vs CHATBOT_TRACK_SOS_METRICS\n\n    - Stream totals, downloads, saves, skip rates, high-level active/passive totals\n    - High-level breakdowns by DSP or country\n    - Time-series analysis of overall performance\n    - Comparisons between artists, songs, or time periods\n    - General questions like \"how many streams?\" or \"top songs\"\n    - Album/product-level performance (aggregate by PRODUCT_ID)\n    - Top tracks on an album (filter by PRODUCT_ID, group by ISRC)\n\n    Use **query_source_of_streams** for:\n    - Detailed per-source-name breakdown for a specific track (ISRC required)\n              (Album Page, Radio, Search, Daily Mix, etc.)\n    - Questions about WHERE streams are coming from within a DSP\n    - Stream source categories like: playlists, search, artist page, album page, radio, discovery weekly,\n   release radar, daily mix, charts, etc.\n    - Questions containing keywords: \"source of streams\", \"SOS\", \"playlist streams\", \"search streams\", \n  \"discovery\", \"radio streams\", \"algorithmic\", \"editorial\"\n    - Examples:\n      - \"How many streams came from Spotify playlists vs search?\"\n      - \"What percentage of streams are from Discovery Weekly?\"\n      - \"Break down Apple Music streams by source type\"\n      - \"Are streams coming from editorial playlists or algorithmic?\"\n\n Use  **query_tiktok_data** for:\n When the user asks about detailed TikTok metrics like views, TikTok creations, TikTok likes, TikTok comments, TikTok shares, or TikTok favorites for tracks or artists.\n\n# Query Decomposition for \"Latest/Most Recent\" Questions\n\nWhen a user asks about \"latest\", \"most recent\", or \"newest\":\n    - FIRST try to query for the item using ORDER BY release_date DESC LIMIT 1\n    - If the query times out, THEN decompose or ask for clarification\n    - Do NOT ask for clarification before attempting the query\n\nIMPORTANT: Do not combine temporal lookups with heavy aggregations in a single query. Run multiple smaller queries instead.\n\n# Timeout Handling\n\nWhen a query times out:\n1. Do NOT retry the same query\n2. Decompose the question into simpler parts\n3. If asking about \"latest/most recent\", first identify the specific item name\n4. Use smaller date ranges if the original query spanned long periods\n5. If decomposition still fails, ask the user:\n   \"This query requires analysis across a large dataset. To help you faster, could you specify:\n   - The specific album or song name (instead of 'latest')\n   - A narrower date range (e.g., a specific month)\"\n\n# Limitations and Boundaries\n\n- Data Freshness: Streaming data has a 24-48 hour delay. Today's data is not yet available so always let user know what date is actually used when asked for data from today/yesterday etc.\n- You do NOT have access to financial/revenue data, contracts, or royalty information.\n- You cannot predict future performance or make revenue forecasts.\n\n\n# Query Defaults \u2014 Do NOT Ask Follow-Up Questions for These\n\nWhen the user does not specify a value for any of the parameters below, apply the default silently. Do NOT ask the user to clarify.\n\n## Time Period\n- General default: last 28 days\n- query_chart_data: last 15 days\n- query_tiktok_data: last 7 days\n- query_tadas_trends: most recent REPORT_DATE available\n- query_artist_social_stats: last 14 days\n- If the user says \"recently\" or \"lately\", use last 28 days\n- If the user says \"this month\", use the current calendar month to date\n- If the user says \"this year\" or \"YTD\", use January 1 of the current year to today\n\n## Geography / Country\n- Default: do not filter by country (return worldwide totals)\n- If the user says \"US\", filter by COUNTRY_CODE = 'US'\n\n## DSP / Platform\n- Default: do not filter by DSP (aggregate across all platforms)\n- Only filter by DSP when the user explicitly names one (e.g., \"on Spotify\", \"Apple Music streams\")\n\n## Result Limit (Top N)\n- Default for any \"top\" or ranking query: top 10\n- If the user says \"top 5\", \"top 20\", etc., use their number\n- For non-ranking queries, do not apply a limit unless the result set is expected to be very large\n\n## TikTok Content Type\n- Default: all content types combined (UGC + PGC)\n- Only filter to a specific content type if the user explicitly asks (e.g., \"UGC creations\", \"user-generated\")\n\n## Product / Release Type\n- Default: do not filter by TYPE_OF_PRODUCT (include all formats)\n- If the user says \"album\" or \"albums\", filter to TYPE_OF_PRODUCT = 'Full Length'\n- If the user says \"single\" or \"singles\", filter to TYPE_OF_PRODUCT = 'Single'\n- If the user says \"EP\" or \"EPs\", filter to TYPE_OF_PRODUCT = 'EP'\n\n## Source of Streams Category\n- Default: do not filter by source type (return all sources)\n- Only break down by source when the user asks about stream sources, SOS, or where streams come from\n\n\n# Handling Search Failures (add to orchestration)\n\n    If search_artists returns no results:\n    - Suggest alternate spellings or stage names\n    - Example: \"I couldn't find 'The Weekend'. Did you mean 'The Weeknd'?\"\n\n    If search_track returns multiple ambiguous results:\n    - Present top 3 matches with artist names\n    - Ask user to confirm which track they meant"
  },
  "tools": [
    {
      "tool_spec": {
        "type": "cortex_analyst_text_to_sql",
        "name": "query_artist_performance",
        "description": "Description: Queries streaming metrics (total, active, passive, collection, unknown), downloads (track and album), saves, skips, and skip rates for artists, songs,\n  and products. Supports filtering by DSP platform, country, region, brand (SME/Orchard/AWAL), and date range. Can check data freshness per DSP. Supports daily, weekly, and monthly\n  aggregations. Use for questions about artist performance, top songs/albums, streaming trends, and cross-platform comparisons.\n\nData Coverage:\n- Streaming counts, downloads, saves, skip rates\n- Breakdowns by DSP (Spotify, Apple Music, etc.)\n- Geographic breakdowns by country or regions\n- breakdowns by source of streams/type of streams\n- Time-series data with daily granularity\n- Album/product-level aggregation via PRODUCT_ID and DIM_RELEASE\n\nWhen to Use:\n- Questions about specific artist/album/song metrics (after resolving IDs)\n- Time-series analysis of streaming performance\n- Comparisons between specific items or time periods\n- Filtering by DSP or country\n- Album/product performance: aggregate by PRODUCT_ID\n- Top tracks on an album: filter by PRODUCT_ID, group by ISRC\n\nWhen NOT to Use:\n- Do NOT pass artist names or song names as filters\n- Do NOT combine temporal lookups (MAX date) with heavy aggregations\n\nRequired Filtering:\n- ALWAYS filter by GLOBAL_PARTICIPANT_ID for artists (obtained from search_artists)\n- ALWAYS filter by ISRC for songs/tracks (obtained from search_track)\n- ALWAYS filter by PRODUCT_ID for albums/products (look up via DIM_RELEASE using RELEASENAME)\n\nExample Natural Language Queries (after resolving IDs):\n- \"Total streams for ISRC USUM72012345 in the last 30 days\"\n- \"Monthly streams breakdown by DSP for GLOBAL_PARTICIPANT_ID abc123 in Q1 2025\"\n- \"Compare streams between January and February 2025 for ISRC USUM72012345\"\n- \"Top countries by streams for GLOBAL_PARTICIPANT_ID abc123 and ISRC USUM72012345\"\n- \"Total streams for album with PRODUCT_ID 5274330 in the last 28 days\"\n- \"Top tracks on album THIS MUSIC MAY CONTAIN HOPE for artist abc123 \u2014 find PRODUCT_ID from DIM_RELEASE where RELEASENAME ILIKE '%THIS MUSIC%' and FORMAT='Full Length'\"\n\nCommon Mistakes to Avoid:\n- \"Streams for Taylor Swift\" \u2192 First call search_artists(\"Taylor Swift\"), then use the returned GLOBAL_PARTICIPANT_ID\n- \"Latest album streams\" \u2192 First identify the album via DIM_RELEASE (ORDER BY RELEASEDATE DESC, FORMAT='Full Length', LIMIT 1), then aggregate by PRODUCT_ID\n- Do NOT list individual ISRCs to sum an album \u2014 use PRODUCT_ID instead\n\nPerformance Notes:\n    - Always specify a date range. If user doesn't provide one, default to last 28 days.\n    - Always include a LIMIT. Default to 10 for \"top\" queries.\n\nThe query_artist_performance tool CAN be used without artist filters.\n    For questions about \"top songs/products in [region/country]\", query\n    directly without requiring an artist ID. Only filter by artist when\n    the question specifically mentions an artist."
      }
    },
    {
      "tool_spec": {
        "type": "cortex_analyst_text_to_sql",
        "name": "query_source_of_streams",
        "description": "Description: Queries detailed Source of Streams (SOS) breakdowns for tracks by DSP and stream category (active/passive).\n\nData Coverage:\n      - Stream counts via a single VALUE metric, filterable by dimensional attributes\n      - ACTIVITY_TYPE: active (lean forward) vs passive (lean backward) classification\n      - BUSINESS_NAME: human-readable source names (e.g. Album Page, Collection, Search, Playlist, Radio, Discover Weekly, Release Radar, Daily Mix)\n      - DSP dimension: SPOTIFY, APPLE, AMAZON, YOUTUBE\n      - STREAM_SOURCE: original source column identifier for precise filtering\n      - Country-level breakdowns via COUNTRY_CODE\n      - Can filter by brand (The Orchard, AWAL, Sony Music) via CHATBOT_ISRC_BRAND_MAPPING\n\n   When to Use:\n      - User asks about stream SOURCES or WHERE streams come from\n      - Questions about playlist vs organic/search performance\n      - Analyzing algorithmic (discover weekly, radio) vs editorial playlist impact\n      - Comparing stream sources across DSPs\n      - \"What percentage of streams come from search vs playlists?\"\n\n    When NOT to Use:\n      - Questions that only need total streams or high-level active/passive totals\n            without per-source-name breakdown (use query_artist_performance)\n          - Artist-level queries without a specific track ISRC (this view is track-only)\n          - Questions about downloads, saves, skip rates (use query_artist_performance)\n          - Country/geographic breakdowns of streams (not in this view — use query_artist_performance)\n          - Chart or playlist placements (use QUERY_CHART_DATA / QUERY_PLAYLIST_DATA)\n\n    Required Filtering:\n      - ISRC for songs/tracks (obtained from SEARCH_TRACK_NAME) — ALWAYS required\n      - This tool CANNOT filter by GLOBAL_PARTICIPANT_ID or artist name — it only\n        has track-level data (ISRC). For artist-level stream type totals, use\n        query_artist_performance instead.\n      - To get source-of-streams for all tracks by an artist, first retrieve ISRCs\n        via SEARCH_TRACK_NAME, then query each ISRC individually.\n       - To filter by platform, use DSP (values: SPOTIFY, APPLE, AMAZON, YOUTUBE).\n            Do not use STORENAME or STOREID for platform filtering — these are legacy identifiers.\n\n  Performance Notes:\n      - Billions of rows. ISRC + date range filters are mandatory.\n      - Include date floor of 2020-01-01 for \"all-time\" queries."
      }
    },
    {
      "tool_spec": {
        "type": "cortex_analyst_text_to_sql",
        "name": "query_chart_data",
        "description": "Description: Queries track/song placement on charts across major DSPs (Spotify, Apple Music, Amazon, YouTube, TikTok, Deezer, Shazam, SoundCloud, Line Music, Recochoku).\n\nData Coverage:\n    - Current chart placements: position, peak position, days on chart, entry date\n    - Historical daily chart positions (time-series)\n    - Breakdowns by platform, country (ISO 2-letter codes or GLOBAL), genre\n    - Can filter by brand (e.g. The Orchard, AWAL, Sony Music)\n\nTwo query modes:\n    - CURRENT PLACEMENTS: \"What charts is this track on?\" / \"Top tracks on Spotify charts\"\n      Uses the aggregated snapshot data. Default mode when user asks about current positions.\n    - HISTORICAL TRENDS: \"Show daily positions over time\" / \"How did the chart position change?\"\n      Uses daily time-series data. Only when user explicitly asks for trends/history.\n\nWhen to Use:\n    - Questions about chart/playlist placements and rankings\n    - \"What charts is track X on?\" or \"What position is track X at?\"\n    - Historical chart position trends over time\n    - Top charting tracks for an artist, brand, or genre\n    - Comparing chart performance across platforms or countries\n\n   When NOT to Use:\n    - Do NOT use for streaming counts, downloads, saves (use query_artist_performance)\n    - Do NOT use for TikTok engagement metrics (use query_tiktok_data)\n    - Do NOT use for social media followers (use query_artist_social_stats)\n    - Do NOT pass artist names or song names as filters \u2014 resolve IDs first\n\n   Required Filtering \u2014 use at least one:\n    - CM_ARTIST for artists (pass the CHARTMETRIC_ID value from search_artists)\n    - ISRC for songs/tracks (obtained from search_track)\n    - CHARTID for specific charts (obtained from search_chart)\n\n   Performance Notes:\n    - Default to last 15 days if user doesn't specify a date range\n    - Default to LIMIT 10 for \"top\" queries"
      }
    },
    {
      "tool_spec": {
        "type": "cortex_analyst_text_to_sql",
        "name": "query_artist_social_stats",
        "description": "Description: Queries artist social media and streaming platform statistics across spotify, deezer, youtube, twitter, soundcloud, facebook, instagram, and tiktok. Includes \n  followers, monthly listeners, popularity, and views over time.\n\n\nData Coverage:\n    - FOLLOWERS: Available across all platforms\n    - MONTHLY_LISTENERS: Spotify only\n    - POPULARITY: Spotify only\n    - VIEWS: Primarily YouTube\n    - Time-series snapshots by platform and date\n    - Brand/label filtering (e.g. The Orchard, AWAL, Sony Music)\n    \n    When to Use:\n    - Questions about artist followers, monthly listeners, popularity, or views on any social/streaming platform\n    - Time-series analysis of social stats across any platform (not just Spotify)\n    - Cross-platform comparisons (e.g. \"followers on Spotify vs Instagram\")\n    - Filtering social stats by brand/label (e.g. \"Orchard artists' Spotify followers\")\n    - Batch comparisons across multiple artists\n    \n    When NOT to Use:\n    - Do NOT use for TikTok track-level metrics like creations, likes, comments, shares (use query_tiktok_data instead)\n    - Do NOT use for streaming counts, downloads, saves, or skip rates (use query_artist_performance instead)\n    - Do NOT pass artist names as filters \u2014 pass CHARTMETRIC_ARTIST_ID\n    \n    Required Filtering:\n    - ALWAYS filter by CHARTMETRIC_ARTIST_ID for artists (obtained from search_artists via the CHARTMETRIC_ID field)\n    - ALWAYS filter by PLATFORM when the user specifies one (e.g. platform = 'spotify')\n    \n    Performance Notes:\n    - Always specify a date range. If user doesn't provide one, default to last 14 days.\n    - For multi-artist comparisons, pass multiple CHARTMETRIC_ARTIST_IDs using IN clause.\n    \n    Example Natural Language Queries (after resolving IDs):\n    - \"Daily Spotify followers for artist with chartmetric_artist_id 407402 in January 2026\"\n    - \"Show followers across all platforms for artist with chartmetric_artist_id 550577 over the last 14 days\"\n    - \"Show the most recent Spotify followers, monthly listeners, and popularity for artists with chartmetric_artist_id 208, 4015, and 214945\""
      }
    },
    {
      "tool_spec": {
        "type": "cortex_analyst_text_to_sql",
        "name": "query_playlist_data",
        "description": "Description: Queries artist track/song placements on streaming platform playlists across Spotify, iTunes/Apple, Amazon Music, YouTube, Deezer, and others.\n\nData Coverage:\n      - Current playlist placement: position, follower count, track count\n      - Playlist metadata: name, type (EDITORIAL, USER_GENERATED, CHART, CURATED, NEW_MUSIC_FRIDAY, PERSONALIZED, RADIO), genre tags\n      - Curator info: curator name, curator country\n      - Breakdowns by DSP platform, curator country\n      - Can filter by brand (The Orchard, AWAL, Sony Music) via CHATBOT_ISRC_BRAND_MAPPING\n      - Track name resolution via GLOBAL_SOUND_RECORDING join\n\nWhen to Use:\n      - \"What playlists is this track on?\"\n      - \"Show me editorial playlists for this artist on Spotify\"\n      - \"Which playlists have the most followers for this track?\"\n      - \"What Apple Music playlists feature this artist?\"\n      - \"Show Orchard tracks on editorial playlists\"\n\n    When NOT to Use:\n      - Do NOT use for streaming counts or downloads (use query_artist_performance)\n      - Do NOT use for chart placements (use query_chart_data)\n      - Do NOT use for TikTok metrics (use query_tiktok_data)\n      - Do NOT pass artist names or song names as filters \u2014 resolve IDs first\n\n    Required Filtering \u2014 use at least one:\n      - GLOBAL_PARTICIPANT_ID for artists (obtained from SEARCH_ARTISTS)\n      - ISRC for songs/tracks (obtained from search_track)\n\n    Performance Notes:\n      - This table has 2.5B+ rows. Always filter by GLOBAL_PARTICIPANT_ID and/or ISRC\n      - Default to LIMIT 15 if user doesn't specify count\n      - When user says \"Apple Music\", the platform name is 'iTunes/Apple'"
      }
    },
    {
      "tool_spec": {
        "type": "cortex_analyst_text_to_sql",
        "name": "query_tadas_trends",
        "description": "Description:  Queries TADAS trending scores for music tracks. TADAS identifies songs that are gaining momentum across platforms based on engagement signals. \n\nData Coverage:\n    - TADAS 30-day trending score (0.01 to 1.00, higher = stronger trend)\n    - Consecutive trend days (how long the track has been trending)\n    - Platform engagement signals driving the trend (FLAG_NAME): TIKTOK LIKES, TIKTOK VIEWS, TIKTOK CREATIONS, SPOTIFY SEARCH, SPOTIFY COLLECTION, SPOTIFY LEAN FORWARD, APPLE\n  SEARCH, APPLE LEAN FORWARD\n    - Geographic breakdown by country (ISO 2-letter codes) or GLOBAL\n    - Can filter by brand (e.g. The Orchard, AWAL, Sony Music)\n\n\nWhen to Use:\n    - Questions about which tracks are trending (TADAS scores)\n    - What's driving a track's trend (platform engagement signals)\n    - Trending tracks for a specific artist, brand, or country\n    - Comparing trend strength across countries or tracks\n\n\nWhen NOT to Use:\n    - Do NOT use for streaming counts, downloads, saves (use query_artist_performance)\n    - Do NOT use for TikTok engagement metrics like creations/views/likes (use query_tiktok_data)\n    - Do NOT use for social media followers (use query_artist_social_stats)\n    - Do NOT pass artist names or song names as filters \u2014 resolve IDs first\n\n    Required Filtering:\n    - Filter by GLOBAL_PARTICIPANT_ID for artist-specific queries (obtained from search_artists)\n    - Filter by ISRC for track-specific queries (obtained from search_track)\n    - Artist and ISRC filters are NOT required for broad queries (e.g. \"top trending tracks in the US for Sony Music\")\n\n    Performance Notes:\n    - Default to most recent REPORT_DATE available (do not require a date range from the user).\n    - Default to LIMIT 10 for \"top\" queries.\n\n    Example Natural Language Queries (after resolving IDs):\n    - \"What songs are trending for artist with id abc123?\"\n    - \"What platform is driving ISRC USSM12502221's trend in Turkey?\"\n    - \"Top 10 trending tracks for The Orchard in Brazil\"\n    - \"What tracks are trending due to TikTok activity in the Netherlands?\"\n"
      }
    },
    {
      "tool_spec": {
        "type": "cortex_analyst_text_to_sql",
        "name": "query_tiktok_data",
        "description": "Description: Queries track-specific TikTok engagement metrics: creations, views, likes, comments, shares, and favorites.\n\nData Coverage:\n    - TikTok creations, views, likes, comments, shares, favorites\n    - Breakdowns by country (ISO 2-letter codes)\n    - Breakdowns by content type: UGC (user-generated) or PGC (premium/library)\n    - Can filter by brand (e.g. The Orchard, AWAL, Sony Music)\n    - Can map to artist via GLOBAL_PARTICIPANT_ID or to track via ISRC\n\nWhen to Use:\n    - Questions about TikTok engagement for specific tracks or artists\n    - Top tracks by TikTok metric (creations, views, likes, etc.) in a country\n    - TikTok engagement by country for an artist's catalog\n    - Brand-level TikTok reporting (e.g. \"top TikTok tracks for The Orchard\")\n    - UGC vs PGC breakdowns\n\nWhen NOT to Use:\n    - Do NOT use for Spotify/Apple/YouTube streaming counts (use query_artist_performance)\n    - Do NOT use for social media follower counts (use query_artist_social_stats)\n    - Do NOT pass artist names or song names as filters \u2014 resolve IDs first\n\nRequired Filtering:\n    - Filter by GLOBAL_PARTICIPANT_ID for artist-specific queries (obtained from search_artists)\n    - Filter by ISRC for track-specific queries (obtained from search_track)\n    - Artist and ISRC filters are NOT required for broad queries (e.g. \"top TikTok tracks in the US\")\n\n    Performance Notes:\n    - Always specify a date range. If user doesn't provide one, default to last 7 days.\n    - Always include a LIMIT. Default to 10 for \"top\" queries."
      }
    },
    {
      "tool_spec": {
        "type": "generic",
        "name": "search_track",
        "description": "Description: Searches for songs/tracks by name and returns their ISRC identifiers. Use this tool when the user mentions a song or track name.\n\nReturns:\n- TRACKNAME: The song/track title\n- ISRC: International Standard Recording Code - use this for filtering in query_artist_performance\n- GLOBAL_PARTICIPANT_ID: The artist's identifier\n\nWhen to Use:\n- User mentions a song or track by name\n- You need to resolve a song name to an ISRC before calling query_artist_performance\n- Finding all tracks with a similar name\n\nParameters:\n- query_text (required): The song or track name to search for\n  - Use the exact name or partial name the user mentioned\n  - Example: \"Anti-Hero\", \"Shape of You\", \"Blinding Lights\"\n\n- artist_id (strongly recommended): The GLOBAL_PARTICIPANT_ID of the artist\n   - ALWAYS pass this when the user mentions an artist. Without it, results may return a wrong version of the song from a different artist.\n  - Resolve the artist ID via search_artists BEFORE calling this tool.\n  - Narrows results to tracks by that specific artist\n  - Helpful when song names are common (e.g., \"Love\" appears in many songs)\n\nExample Usage:\nUser: \"How is Taylor Swift's Anti-Hero performing?\"\n1. Call search_artists with query_text=\"Taylor Swift\" \u2192 get GLOBAL_PARTICIPANT_ID\n2. Call search_track with query_text=\"Anti-Hero\" and artist_id=[ID from step 1]\n3. Extract ISRC from results\n4. Call query_artist_performance filtering by both GLOBAL_PARTICIPANT_ID and ISRC",
        "input_schema": {
          "type": "object",
          "properties": {
            "artist_id": {
              "description": "Optional. The GLOBAL_PARTICIPANT_ID of the artist to filter results. Use this when you\n  already know the artist's ID from a previous search_artist call to narrow down track results to that\n  specific artist.",
              "type": "string"
            },
            "query_text": {
              "description": "The song or track name to search for. Use the exact name or partial name the user\n  mentioned.",
              "type": "string"
            }
          },
          "required": [
            "query_text"
          ]
        }
      }
    },
    {
      "tool_spec": {
        "type": "generic",
        "name": "search_artists",
        "description": "Description: Searches for artist by name or by spotify id and returns their unique identifiers (GLOBAL_PARTICIPANT_ID). Use this tool BEFORE querying performance data when the user mentions an artist name.\n\nReturns:\n- ARTISTNAME: The artist's display name\n- GLOBAL_PARTICIPANT_ID: Unique identifier to use in query_artist_performance\n- ALL_TIME_STREAMS: Total historical streams (used for ranking)\n- CHARTMETRIC_ID: Unique identifier to use in query_artist_social_stats\n\nRanking: Results are sorted by popularity (total streams), so the most popular matching artist appears first.\n\nWhen to Use:\n- User mentions an artist by name\n- You need to resolve an artist name to an ID before calling query_artist_performance\n- User asks what are top 3 songs for artist X\"\n\nParameters:\n- query_text (required): The artist name or spotify id to search for\n  - Use the exact name or partial name the user mentioned\n  - Case-insensitive matching\n  - Example: \"taylor swift\", \"Taylor\", \"Beyonce\"\n   - Example for spotify id \"5SXuuu4pukkTvsLbU22va1\"\n\nExample 1 Usage:\nUser: \"How many streams does Drake have?\"\n1. Call search_artists with query_text=\"Drake\"\n2. Extract GLOBAL_PARTICIPANT_ID from first result\n3. Call query_artist_performance filtering by that ID\n\nExample 2 Usage:\nUser: \"How many streams does artist with spotify id 5SXuuu4pukkTvsLbU22va1 has?\"\n1. Call search_artists with query_text=\"5SXuuu4pukkTvsLbU22va1\"\n2. Extract GLOBAL_PARTICIPANT_ID from first result\n3. Call query_artist_performance filtering by that ID",
        "input_schema": {
          "type": "object",
          "properties": {
            "query_text": {
              "description": "The artist name or spotify id to search for. Use the exact name or partial name the user mentioned.",
              "type": "string"
            }
          },
          "required": [
            "query_text"
          ]
        }
      }
    },
    {
      "tool_spec": {
        "type": "generic",
        "name": "search_chart",
        "description": "Description: Searches for playlists/charts by name and returns their unique identifiers. Use this tool when the user mentions a playlist or chart.\n\nReturns:\n- CHARTID: Unique identifier of chart/playlist.\n- COUNTRY: Full country name references by user in their question.\n- NAME: Correct name of the playlist/chart\n- platform: Name of the DSP owning that playlist/chart\n\nWhen to Use:\n- User mentions a chart or playlist by name\n- You need to resolve a chart or playlist name to an unique identifier before calling query_playlist_data tool\n\nParameters:\n- query_text (required): The playlist or chart name to search for\n  - Use the exact name or partial name the user mentioned\n\n- country (optional): The name of the country\n  - Use this when user also mentioned country in their request. GLOBAL can be also considered as country in this use case.\n  - Narrows results to charts by that specific country\n  - Helpful when chart/playlist names are common (e.g., \"Spotify top 100\" appears for many countries)\n\nExample Usage:\nUser: \"What are top 3 tracks from Spotify top 100 viral playlist in Germany?\"\n1. Call search_chart with query_text=\"Spotify top 100 viral \" and country=[Germany]\n2. Extract CHARTID from results\n4. Call query_playlist_data filtering by CHARTID\n",
        "input_schema": {
          "type": "object",
          "properties": {
            "query_text": {
              "type": "string"
            },
            "region": {
              "type": "string"
            }
          },
          "required": [
            "query_text",
            "region"
          ]
        }
      }
    },
    {
      "tool_spec": {
        "type": "web_search",
        "name": "Web Search",
        "description": ""
      }
    }
  ],
  "skills": [],
  "tool_resources": {
    "query_source_of_streams": {
      "execution_environment": {
        "query_timeout": 300,
        "type": "warehouse",
        "warehouse": "DEV_PERFORMANCE_WAREHOUSE"
      },
      "semantic_view": "LORELAI_AGENT.DEV.TRACK_SOS_METRICS_SEMANTIC_VIEW"
    },
    "query_artist_social_stats": {
      "execution_environment": {
        "query_timeout": 300,
        "type": "warehouse",
        "warehouse": "DEV_PERFORMANCE_WAREHOUSE"
      },
      "semantic_view": "LORELAI_AGENT.DEV.SOCIAL_STATS_SEMANTIC_VIEW"
    },
    "query_chart_data": {
      "execution_environment": {
        "query_timeout": 300,
        "type": "warehouse",
        "warehouse": "DEV_PERFORMANCE_WAREHOUSE"
      },
      "semantic_view": "LORELAI_AGENT.DEV.CHARTS_SEMANATIC_VIEW"
    },
    "query_playlist_data": {
      "execution_environment": {
        "query_timeout": 300,
        "type": "warehouse",
        "warehouse": "DEV_PERFORMANCE_WAREHOUSE"
      },
      "semantic_view": "LORELAI_AGENT.DEV.PLAYLISTS_SEMANTIC_VIEW"
    },
    "query_tadas_trends": {
      "execution_environment": {
        "query_timeout": 61,
        "type": "warehouse",
        "warehouse": "DEV_PERFORMANCE_WAREHOUSE"
      },
      "semantic_view": "LORELAI_AGENT.DEV.TADAS_SEMANTIC_VIEW"
    },
    "query_tiktok_data": {
      "execution_environment": {
        "query_timeout": 299,
        "type": "warehouse",
        "warehouse": "DEV_PERFORMANCE_WAREHOUSE"
      },
      "semantic_view": "LORELAI_AGENT.DEV.TIKTOK_SEMANTIC_VIEW"
    },
    "search_chart": {
      "execution_environment": {
        "query_timeout": 120,
        "type": "warehouse",
        "warehouse": "DEV_PERFORMANCE_WAREHOUSE"
      },
      "identifier": "LORELAI_AGENT.DEV.SP_SEARCH_CHART_BY_NAME",
      "name": "SP_SEARCH_CHART_BY_NAME(VARCHAR, VARCHAR)",
      "type": "procedure"
    },
    "search_track": {
      "execution_environment": {
        "query_timeout": 120,
        "type": "warehouse",
        "warehouse": "DEV_PERFORMANCE_WAREHOUSE"
      },
      "identifier": "LORELAI_AGENT.DEV.SP_SEARCH_TRACK_BY_NAME",
      "name": "SP_SEARCH_TRACK_BY_NAME(VARCHAR, VARCHAR)",
      "type": "procedure"
    },
    "Web Search": {
      "max_results": 10
    },
    "query_artist_performance": {
      "execution_environment": {
        "query_timeout": 299,
        "type": "warehouse",
        "warehouse": "DEV_PERFORMANCE_WAREHOUSE"
      },
      "semantic_view": "LORELAI_AGENT.DEV.ARTIST_PERFORMANCE_SEMANTIC_VIEW"
    },
    "search_artists": {
      "execution_environment": {
        "query_timeout": 61,
        "type": "warehouse",
        "warehouse": "DEV_PERFORMANCE_WAREHOUSE"
      },
      "identifier": "LORELAI_AGENT.DEV.SP_SEARCH_ARTIST_BY_NAME",
      "name": "SP_SEARCH_ARTIST_BY_NAME(VARCHAR)",
      "type": "procedure"
    }
  }
}