Skip to content

[Apple Notes] search-notes AI tool cannot find older notes — no search/filter parameter, returns only 250 most recent #25707

@jasondk

Description

@jasondk

Extension

https://www.raycast.com/raycast/apple-notes

Raycast Version

1.104.6

OS Version

26.2

Description

The search-notes AI tool accepts no input parameters — the AI cannot pass a search query. The underlying getNotes() function runs:

ORDER BY note.zmodificationdate1 DESC
LIMIT 250

This means only the 250 most recently modified notes are returned. Any note outside that window is invisible to the AI. The AI scans the returned list in-context, but if the target note isn't there, it simply can't find it — even though the note exists.

Suggested Fix

Add an optional searchText input parameter to the search-notes tool and pass it through to the SQL query as a filter:

// In tools/search-notes.ts
type Input = {
  /** Optional search text to filter notes by title or snippet. */
  searchText?: string;
};

export default async function (input: Input) {
  const { maxQueryResults } = getPreferenceValues();
  const max = Number.isNaN(parseInt(maxQueryResults)) ? 250 : parseInt(maxQueryResults);
  const notes = await getNotes(max, [], input.searchText);
  return notes;
}
// In api/getNotes.ts — add searchText parameter and SQL filter
export async function getNotes(maxQueryResults: number, filterByTags: string[] = [], searchText?: string) {
  const escapedSearch = searchText ? searchText.replace(/'/g, "''") : "";
  const searchFilter = searchText
    ? `AND (note.ztitle1 LIKE '%${escapedSearch}%' OR note.zsnippet LIKE '%${escapedSearch}%')`
    : "";
  // ...apply searchFilter in the WHERE clause...
}

This way, the LIKE filter narrows the result set at the SQL level and the 250 limit applies only to matching notes, so older notes that match are found. Ideally, parameterized queries should be used if executeSQL supports them, to avoid SQL injection risks.

Steps To Reproduce

  1. Have more than 250 notes in Apple Notes
  2. Ask the AI to find a note that was last modified a long time ago (e.g. "What's in my note called [old note title]?")
  3. The AI calls search-notes with no parameters (because the tool doesn't accept any)
  4. The old note is not in the 250 most recent results
  5. The AI reports it can't find the note, even though it exists

Current Behaviour

search-notes returns only the 250 most recently modified notes, with no way to pass a search query. Notes older than the 250th-most-recently-modified note are completely invisible to the AI, even if they exactly match the user's request. The AI reports that the note doesn't exist, even when it does.

Expected Behaviour

search-notes should accept an optional searchText parameter that filters results at the SQL level (by title and/or snippet), so the AI can search for notes by name/content and find them regardless of how recently they were modified. The 250-result limit should apply to the filtered result set, not the entire notes library.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingextensionIssues related to one of the extensions in the Storeextension: apple-notesIssues related to the apple-notes extension

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions