Backend Scheduler Interface and Gathering New Cards

Hi there,

  1. I am interested in implementing a custom algorithm for new card gather order*. What would be the recommended way (if it exists) of interacting with Anki’s backend to accomplish this?

  2. As a corollary question: I have only written add-ons in older (pre-FSRS support) versions of Anki. There, I am used to the syntax for interacting with the scheduler. Since only one scheduler may be enabled across all of a profile’s decks at a time, I wonder if this interface is maintained regardless of which scheduler has been set by the user? For example, will the syntax always work regardless of which scheduler is being used?

*(In particular, each new note corresponds to a DAG vertex and I want to topologically sort them such that cards are introduced after their dependencies. Maybe changing new card gather order isn’t what I should be looking for here, if so let me know…)


Since V3, it’s no longer possible to modify parts of the scheduler’s logic using add-ons. Most logic is implemented in Rust. You may able to get something done by implementing a new Scheduler class however and overriding col.sched but it’s not possible to selectively only modify the gathering order as far as I know and my guess is that you’ll need to patch a lot of other methods that use Rust methods to call your code instead.

Yes, it’ll work because all schedulers are based on the Scheduler class (there’s only V3 anyway nowadays).


I see, thanks for the response. How does the repositioning of cards work internally? I wonder if there is a straightforward way to programmatically edit those queue numbers.

Failing all of this, I suppose a workaround might be to set gathering order to be sequential and re-insert all new cards in the desired order upon the addition of any new cards. But this would scale laughably poorly…

Right now I am just grabbing new cards via new_cards = mw.col.find_cards(f"deck:{deck_name} is:new") and then modifying each of values mw.col.getCard(card_id).due to acheive the desired ordering. What are the drawbacks of this approach?

That’s what I was going to suggest. I think it’s a reasonable approach. You can also maybe periodically re-sort new cards to make sure newly added cards are in the correct order.

1 Like