Skip to content

Discussion: Potential missing error handling in agent_eval (eval_main.py) #25

@huangjf11

Description

@huangjf11

Question

I noticed that in the agent_eval function in eval_main.py, when no matching model_dict is found, the code doesn't seem to handle this case. I'm wondering if this is intentional or if we should add error handling here?


Location

  • File: eval_main.py
  • Function: agent_eval

Current Code

for index in range(len(possible_answer_item_)):
    possible_keys = set(possible_answer_item_[index].keys())
    matched_dict = None
    
    for model_dict in model_result_item:
        model_keys = set(model_dict.keys())
        if possible_keys == model_keys:
            matched_dict = model_dict
            break
    
    if matched_dict:
        checker_result = agent_checker(
            matched_dict,
            possible_answer_item_[index],
        )
        
        if checker_result["valid"] == False:
            result_tmp["valid"] = False
            result_tmp["error"].append(checker_result["error"])
            result_tmp["error_type"] = checker_result["error_type"]
            is_valid = False

What should happen when matched_dict is None?

Potential issue: If ⁠checker_result⁠ was set in a previous iteration, the subsequent code might accidentally use the old ⁠checker_result⁠ from the previous loop iteration when ⁠matched_dict⁠ is ⁠None⁠ in the current iteration.

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions