Task configuration:
{"task_id": "05", "task_name": "\u6dfb\u52a0\u4e00\u5f20\u95ee\u7b54\u9898\u5361\u7247\uff0c\u7136\u540e\u64a4\u9500\u6dfb\u52a0", "description": "\u6dfb\u52a0\u4e00\u5f20\u95ee\u7b54\u9898\u5361\u7247\uff0c\u6b63\u9762\u4e3aThe world is your oyster\uff0c\u80cc\u9762\u4e3aShakespeare\uff0c\u6dfb\u52a0\u5230quote\u724c\u7ec4\u4e2d\uff0c\u7136\u540e\u64a4\u9500\u6dfb\u52a0", "application_info": {"name": "anki", "executable_path": "/home/agent/anki/out/pyenv/bin/python", "args": ["/home/agent/anki/tools/run.py"], "cwd": "/home/agent/anki"}, "task_parameters": {"first_field": "The world is your oyster", "second_field": "Shakespeare", "deck_name": "\u7cfb\u7edf\u9ed8\u8ba4"}, "instruction_template": "\u6dfb\u52a0\u4e00\u5f20\u95ee\u7b54\u9898\u5361\u7247\uff0c\u6b63\u9762\u4e3a${first_field}\uff0c\u80cc\u9762\u4e3a${second_field}\uff0c\u6dfb\u52a0\u5230${deck_name}\u724c\u7ec4\u4e2d\uff08\u5982\u679c\u6ca1\u6709\uff0c\u81ea\u884c\u521b\u5efa\uff09\uff0c\u7136\u540e\u64a4\u9500\u6dfb\u52a0", "evaluation_setup": {"scripts": [{"role": "hook", "path": "hooker.js", "dependency": ["../common/hooker_common.js"]}, {"role": "handler", "path": "handler.py"}], "timeout": 60}, "events": {"card_added": {"description": "\u5361\u7247\u6dfb\u52a0", "is_key_step": true, "key_step_index": 1, "key_step_name": "\u5361\u7247\u6dfb\u52a0"}, "card_correct": {"description": "\u5361\u7247\u4fe1\u606f\u6b63\u786e", "is_key_step": true, "key_step_index": 2, "key_step_name": "\u5361\u7247\u4fe1\u606f\u6b63\u786e"}, "card_wrong": {"description": "\u5361\u7247\u4fe1\u606f\u9519\u8bef", "is_key_step": false}, "undo": {"description": "\u5361\u7247\u64a4\u9500\u6dfb\u52a0", "is_key_step": true, "key_step_index": 3, "key_step_name": "\u5361\u7247\u64a4\u9500\u6dfb\u52a0"}}, "success_conditions": ["undo"], "sql_path": "/home/agent/.local/share/Anki2/sam/collection.anki2", "total_key_steps": 2, "mcp_servers": [{"command": "/home/agent/anki-mcp-server/.venv/bin/python", "args": ["/home/agent/anki-mcp-server/run_server.py"]}]}

Hook script:
//! The script only tested in x86-64!

const TRACE_FUNCTION = [
    "storage_add_card",
    "service_undo"
]
function initHooks() {
    // iterate function name and addr, init it.
    for (const function_name of TRACE_FUNCTION){
        initHook(function_name, TRACE_MAPS[function_name]);
    }
}
initHooks();
sendLog("info", "add hooks done");

Evaluation handler:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import os
sys.path.append(os.path.dirname(__file__))
from common import *

def handle_storage_add_card(context: Context,message) -> Status:
    context.update_database()
    latest : Card = sorted(AnkiObjMap().array_by_type("card"),key=lambda x: x.mod,reverse=True)[0]
    note = latest.get_note()
    status = Status(status=StatusType.PROGRESS)
    status.emit(EventCardAdded())
    if len(note.fields) == 2 and note.fields[0] == tp.first_field and note.fields[1] == tp.second_field:
        deck = latest.get_deck()
        if deck and deck.name == tp.deck_name:
            status.emit(EventCardCorrect())
        else:
            status.emit(EventCardWrong(tp.deck_name,deck.name))
    else:
        status.emit(EventCardWrong(note.fields,f"[{tp.first_field} {tp.second_field}]"))

    return status
      

def handle_service_undo(context: Context,message) -> Status:
    time.sleep(1)
    context.update_database()
    status = Status()
    
    if not any([(len(note.fields) == 2 and note.fields[0] == tp.first_field and 
            note.fields[1] == tp.second_field) for note in AnkiObjMap().array_by_type("note")]):
        status.emit(EventUndo())
    return status

TRACE_HANDLERS = {
    "storage_add_card": handle_storage_add_card,
    "service_undo" : handle_service_undo,
}   

dependency_graph = {
    card_added_ : [],
    card_correct_ : [card_added_],
    card_wrong_ : [card_added_],
    undo_ : [card_correct_]
}
finished_list = [
    undo_
]

bind_handlers(TRACE_HANDLERS,dependency_graph,finished_list)