Skip to content

[BUG] validation error for AnalystOutput #106

@rjavadi

Description

@rjavadi

Bug Description


 Item 9 failed: 1 validation error for AnalystOutput
flagged_transaction_ids
  Input should be a valid string [type=string_type, input_value=['5d6de366f9d9b374', '7c2...0e', '3d3bf35982b11b91'], input_type=list]
    For further information visit https://errors.pydantic.dev/2.12/v/string_type

Steps to Reproduce

In implementations/aml_investigation/03_evaluation.ipynb , cell under running the experiment I got this error.

The eval fails at AnalystOutput validation in AmlInvestigationTask: the schema says comma-separated str, but the agent output often uses a JSON list. Fixing it means either widening the schema (e.g. str | list[str] + a validator that normalizes to one representation) or tightening the agent/output instructions so it always emits a comma-separated string.

Code snippet (if applicable):

Expected Behavior

We shouldn't get error message for AnalystOutput object validation.

Actual Behavior

Environment

Coder platform for the project

Screenshots/Logs

Additional Context

Possible Solution

# In cases.py:

@field_validator("flagged_transaction_ids", mode="before")
    @classmethod
    def _normalize_flagged_transaction_ids(cls, value: Any) -> str:
        """Accept comma-separated str or JSON list from model output; store as str."""
        if value is None:
            return ""
        if isinstance(value, str):
            return value
        if isinstance(value, list | tuple | set):
            return ",".join(str(item).strip() for item in value if str(item).strip())
        return str(value).strip()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions