My custom addon only working when I launch Anki from command line

Hey, I created an addon for my own work and it is not published on anki’s website. The objective of the addon is to populate a field at the time of the answer with text from a different card.
When I run Anki, the addon doesn’t work but when I run Anki from the command line then the addon works.

Source code of add on: NidIndex/ · main · Rahul Wadhwani / Cid Index Add On Anki · GitLab

This is how I am running Anki. If I run it this way, the addon works.

$  /Applications/          
Anki starting...
Initial setup...
Running with temporary Qt5 compatibility shims.
Run with DISABLE_QT5_COMPAT=1 to confirm compatibility with Qt6.
Preparing to run...

DevTools listening on ws://

Does anyone know why this might be happening?

PS: Please feel free to give me feedback on the addon; it is the first time I have built something for Anki and I sure there are gaps in my implementation. Thank you!

When I mention that it doesn’t work, it doesn’t populate the {{edit:Index:}} field in the card.

You don’t need to use the reviewer_did_answer_card hook here. The text was not showing up in the first card because of it, and I suspect it can cause other issues.

diff --git a/NidIndex/ b/NidIndex/
index b54cf0e..14400a7 100644
--- a/NidIndex/
+++ b/NidIndex/
@@ -1,10 +1,6 @@
 from aqt import mw
-from aqt import gui_hooks
 from anki import hooks
 from anki.template import TemplateRenderContext
-from aqt.reviewer import Reviewer
-from import Card
-from typing import Literal

 def add_text_to_index_field(field_text: str,
@@ -33,8 +29,4 @@ def add_text_to_index_field(field_text: str,
                 return html_str

-def render_after_answer(reviewer: Reviewer, card: Card, ease: Literal[1, 2, 3, 4]) -> None:
-    hooks.field_filter.append(add_text_to_index_field)

That fixed the problem.
Thank you so much, abdo.