iflytek/astron-agent · error · NotImplementedError

Subclasses must implement this method

Error message

Subclasses must implement this method

What it means

BaseAuditStrategy.input_review is an abstract-style placeholder: the base class defines the input-review contract and requires every concrete strategy (e.g. TextStrategy) to override it. The base method only raises NotImplementedError. It surfaces when a subclass was added or instantiated without providing its own input_review implementation.

Solutions

  1. Implement input_review in the concrete strategy subclass
  2. Ensure the pipeline selects the correct concrete strategy for the frame's content type, not the base class
  3. If using Python's abc, decorate input_review with @abstractmethod so missing implementations fail at instantiation time with a clearer TypeError

Example fix

// before (my_strategy.py)
class MyStrategy(BaseAuditStrategy):
    pass

// after
class MyStrategy(BaseAuditStrategy):
    async def input_review(self, input_frame: InputFrameAudit, span: Span) -> None:
        # dispatch review based on input_frame content type
        ...
Defensive patterns

Strategy: type-guard

Validate before calling

if type(strategy) is BaseAuditStrategy or not callable(getattr(type(strategy), "input_review", None)):
    raise TypeError(f"{type(strategy).__name__} must implement input_review")

Type guard

def implements_input_review(strategy_cls) -> bool:
    return (
        strategy_cls is not BaseAuditStrategy
        and "input_review" in strategy_cls.__dict__
    )

Try / catch

try:
    await strategy.input_review(input_frame, span)
except NotImplementedError:
    logger.error("strategy %s does not implement input_review", type(strategy).__name__)
    raise

Prevention

When it happens

Trigger: A strategy class that inherits from BaseAuditStrategy but does not override input_review is registered/instantiated and the audit pipeline calls `strategy.input_review(input_frame, span)`.

Common situations: Adding a new audit strategy for a new content type and forgetting to implement input_review; partially refactored strategy classes; instantiating BaseAuditStrategy directly instead of a concrete subclass.

Understand the failure class

Background: "NotImplementedError: Subclasses should override this method" / "must be implemented" — abstract method errors explained — this error's family across 40 libraries.

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/68c35ec680fdff22. Report an issue: GitHub.

Appendix: source

Thrown at core/workflow/infra/audit_system/strategy/base_strategy.py:51

        :param chat_app_id: LLM application ID, passed through parameter for identifying the caller
                           assigned by upstream to the LLM calling party
        :param uid: User ID, passed through parameter for identifying specific users
        """
        self.context = AuditContext(
            chat_sid=chat_sid, template_id=template_id, chat_app_id=chat_app_id, uid=uid
        )
        self.audit_apis = audit_apis

    @abstractmethod
    async def input_review(self, input_frame: InputFrameAudit, span: Span) -> None:
        """
        Input content review logic that subclasses must implement.

        :param input_frame: Input frame containing content to be audited
        :param span: Span object for tracking request context information
        :return: None
        """
        raise NotImplementedError("Subclasses must implement this method")

    @abstractmethod
    async def output_review(self, output_frame: OutputFrameAudit, span: Span) -> None:
        """
        Output content review logic that subclasses must implement.

        :param output_frame: Output frame containing content to be audited
        :param span: Span object for tracking request context information
        :return: None
        """
        raise NotImplementedError("Subclasses must implement this method")

View on GitHub (pinned to 5e758547a8)