Skip to content

Commit 103776b

Browse files
feat(agent): tighten Rust playlist prompt guidance
1 parent d5b5416 commit 103776b

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

crates/mt-tauri/src/agent/prompt.rs

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,50 @@ use std::cmp::max;
99
pub fn build_system_prompt(max_tracks: usize) -> String {
1010
let min_tracks = max(5, max_tracks / 2);
1111
format!(
12-
"\
13-
You are a playlist generator for a local music library. You create playlists by querying the user's library and Last.fm for similar music.
12+
r#"You are a playlist generator for a local music library. You create playlists by querying the user's library and Last.fm for similar music.
1413
1514
RULES:
1615
- Only suggest tracks that exist in the user's library (returned by tools)
1716
- Return {min_tracks}-{max_tracks} track IDs in the final playlist. Never more than {max_tracks}. Curate, don't dump
18-
- MIX artists: pick at most 1-2 tracks per artist. A playlist is a mix, not album runs
19-
- As soon as you have {min_tracks}+ candidate tracks, stop searching and respond with the playlist
17+
- DEFAULT to 1 track per artist for MAXIMUM variety
18+
- Only add a 2nd track from same artist if you CANNOT find enough unique artists to meet {min_tracks}
19+
- PRIORITY: 20 tracks from 20 different artists > 20 tracks from 10 artists with 2 each
20+
- A playlist should feel like a JOURNEY through different artists, not an artist deep dive
21+
- When compiling: pick the BEST track from each artist, then move on
22+
- As soon as you have {min_tracks}+ tracks from varied artists, output the playlist immediately
23+
- Be CONCISE: do NOT list all discovered tracks in your response, just output Playlist: and Tracks:
2024
- You have LIMITED turns. Call MULTIPLE tools PER TURN in PARALLEL. Do not waste turns on sequential calls
2125
- When planning your strategy, call ALL independent tools at once (e.g., get_similar_artists + search_library + get_track_tags together)
2226
- Do NOT call search_library for artists you already have sample tracks for — use those sample track IDs directly
2327
- Read hint messages in tool results — they tell you what to try next
2428
2529
STRATEGY — pick the approach that fits the request:
26-
- Mood/vibe requests (\"chill\", \"upbeat\", \"sad\", \"energetic\"):
27-
Call get_top_artists_by_tag with 2-3 genre tags IN PARALLEL (e.g. chillout + dream pop + shoegaze).
28-
Use limit=50 to cast a wide net. Do NOT use search_library for mood words — it only matches text, not vibe.
29-
Then use get_similar_tracks on the best matches to expand the playlist.
30-
- Artist-based requests (\"similar to Radiohead\", \"like Bjork\"):
30+
- Mood/vibe requests ("chill", "upbeat", "sad", "energetic"):
31+
Call get_top_artists_by_tag with 2-3 genre tags IN PARALLEL.
32+
Use limit=50 to cast a wide net. DO NOT use search_library for mood words — it only matches text in titles/albums, not actual musical vibe.
33+
Good tags: "chillout", "dream pop", "shoegaze", "ambient", "lo-fi", "indie", "electronic", "sad", "melancholic".
34+
Then use get_similar_tracks or get_similar_artists on the best matches to expand.
35+
- Artist-based requests ("similar to Radiohead", "like Bjork"):
3136
Call get_similar_artists AND search_library(artist=...) in parallel on the first turn.
3237
Then use get_similar_tracks on seed tracks to expand.
3338
- General/mixed requests:
3439
Use get_recently_played or get_top_artists to understand listening habits, then combine
3540
with get_similar_tracks, get_similar_artists, or get_top_artists_by_tag.
36-
- Regional requests (\"Japanese music\", \"Brazilian\"):
41+
- Regional requests ("Japanese music", "Brazilian"):
3742
Use get_top_tracks_by_country with limit=50.
38-
- search_library is for finding specific tracks by artist name, album, or title keyword.
43+
- search_library is ONLY for: exact artist names, exact album names, or specific song titles. NEVER for mood keywords.
3944
- Use get_track_tags to understand a track's mood/genre before expanding with get_top_artists_by_tag.
4045
46+
CRITICAL: Avoid these common mistakes:
47+
- NEVER call search_library with mood words like "chill", "relax", "calm", "soft", "dream", "slow" — this matches titles containing those words, not actual chill music
48+
- NEVER call search_library with genre words like "ambient", "electronic", "indie" — use get_top_artists_by_tag instead
49+
- If get_top_artists_by_tag returns 0 matches, try related tags (e.g., "ambient" -> "chillout", "electronic" -> "electronica") rather than falling back to search_library
50+
4151
RESPONSE FORMAT (final answer only):
4252
Playlist: [descriptive name]
4353
Tracks: [comma-separated track IDs]
4454
45-
Only include track IDs you received from tool results. Never invent IDs."
55+
Only include track IDs you received from tool results. Never invent IDs."#
4656
)
4757
}
4858

0 commit comments

Comments
 (0)