Skip to content

Add personal library playlist search to find_music#105

Open
devin-ai-integration[bot] wants to merge 1 commit into
developfrom
devin/1782411394-library-playlist-search
Open

Add personal library playlist search to find_music#105
devin-ai-integration[bot] wants to merge 1 commit into
developfrom
devin/1782411394-library-playlist-search

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

find_music now searches the user's personal Apple Music library playlists alongside the existing catalog search. This lets the user say "play my Sound Bath Journey playlist" and have Loop find it from their library.

What changed:

MusicController.findMusic() now returns a library_playlists array in addition to the existing songs, albums, playlists (catalog) keys. The catalog search is untouched.

// New private method on MusicController:
private func findLibraryPlaylists(query: String, limit: Int) async -> [[String: Any]]

Search strategy:

  1. Try MusicLibrarySearchRequest(term:types:) for efficient server-side library search
  2. If that fails or returns empty, fall back to MusicLibraryRequest<Playlist>() → fetch all → client-side name.contains(query) filter
  3. On any error, return [] — catalog results are still returned normally

Response shape change (additive only):

{
  "status": "ok",
  "songs": [...],
  "albums": [...],
  "playlists": [...],          // catalog playlists (unchanged)
  "library_playlists": [       // NEW — user's personal library
    { "id": "p.abc123", "type": "library_playlist", "title": "Sound Bath Journey", "source": "library" }
  ]
}

MusicSkill.systemPromptFragment and the find_music tool description updated to mention library playlists so the LLM knows to look at them.

How to test:

  1. Build and run on a device with an Apple Music subscription and saved playlists.
  2. Invoke find_music with a query matching a personal library playlist name.
  3. Verify library_playlists contains the match, and playlists still has catalog results.
  4. Pass the library playlist id (e.g. p.…) to play_music with target_type: "playlist" — playback should work (the existing play() already handles p.-prefixed library IDs).

Link to Devin session: https://app.devin.ai/sessions/a362cf082d6b47d18ca994b09ee23e7f

Search the user's Apple Music library playlists alongside the existing
catalog search. Results are returned in a separate library_playlists
array so callers can distinguish library vs catalog playlists.

Uses MusicLibrarySearchRequest for efficient server-side search with a
MusicLibraryRequest<Playlist> fallback for client-side filtering when
the search endpoint is unavailable.

Co-Authored-By: bot_apk <apk@cognition.ai>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author
Original prompt from API User

#``# Goal
Update the existing Apple Music find_music skill/tool in LoopHarness to also search the user's personal library playlists — not just the public Apple Music catalog.

#``# Context
Currently, find_music only hits the public catalog search endpoint (https://api.music.apple.com/v1/catalog/{storefront}/search). This means user-created or saved playlists in their personal Apple Music library don't appear in results. The user wants to be able to say "play my Sound Bath Journey playlist" and have Loop find it from their library.

#``# What to do

  1. Find the existing Apple Music search/find implementation in the LoopHarness codebase (likely in a skill or tool file related to music/Apple Music).
  2. Add a library playlist search alongside the existing catalog search. Use the Apple Music API library endpoint:
    • GET https://api.music.apple.com/v1/me/library/playlists — lists all playlists in the user's personal library
    • Optionally use GET https://api.music.apple.com/v1/me/library/search?term={query}&amp;types=playlists if available (this endpoint searches within the user's library)
    • This requires the music.user-library-read scope on the Apple Music developer token / user token.
  3. Merge or separate the results — return personal library playlists in a library_playlists array (or merge into the existing playlists array with a flag indicating it's from the library vs catalog). Either way, make it clear in the response which playlists are from the user's library.
  4. Ensure the existing catalog search behavior is unchanged — this is purely additive.
  5. Make sure any necessary auth token handling (developer token + user music token) is in place for the library endpoint. If the existing code already has user token handling, reuse it. If not, add the user music token flow.
  6. Test that the existing catalog search still works and the new library search returns results.

#``# Constraints

  • Don't break existing find_music behavior.
  • Keep the change f... (351 chars truncated...)

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@vercel

vercel Bot commented Jun 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
loop-harness Ready Ready Preview, Comment Jun 25, 2026 6:19pm

@devin-ai-integration devin-ai-integration Bot requested a review from ashbhat June 25, 2026 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants