iflytek/astron-agent · error · NotImplementedError

MockAuditAPI.know_ref is not implemented yet

Error message

MockAuditAPI.know_ref is not implemented yet

What it means

MockAuditAPI.know_ref is a stub for the `/audit/v3/aichat/knowRef` endpoint (knowledge-reference screening in LLM content-security scenarios). It raises NotImplementedError because the mock implementation was never written. Any audit flow that routes knowledge-reference checks through the mock client fails immediately.

Solutions

  1. Configure the real audit API client for this environment instead of the mock
  2. Implement know_ref in MockAuditAPI mirroring the real client's contract (e.g. log-and-pass-through no-op)
  3. Disable or skip the know_ref audit step when the mock client is in use

Example fix

// before (mock_audit_api.py)
async def know_ref(self, text: str, **kwargs: Any) -> None:
    # path = f"/audit/v3/aichat/knowRef"
    # TODO: To be implemented
    raise NotImplementedError("MockAuditAPI.know_ref is not implemented yet")

// after
async def know_ref(self, text: str, **kwargs: Any) -> None:
    logger.info("mock know_ref skipped: %s", text)
    return None
Defensive patterns

Strategy: try-catch

Validate before calling

from infra.audit_system.audit_api.mock.mock_audit_api import MockAuditAPI
if isinstance(audit_api, MockAuditAPI) and know_ref_required:
    raise RuntimeError("know_ref screening requires the real audit API, not MockAuditAPI")

Type guard

def supports_know_ref(api) -> bool:
    impl = getattr(type(api), "know_ref", None)
    return impl is not None and not getattr(impl, "_is_stub", False)

Try / catch

try:
    await audit_api.know_ref(text)
except NotImplementedError:
    logger.warning("know_ref not implemented by %s; skipping knowledge-ref audit", type(audit_api).__name__)

Prevention

When it happens

Trigger: Calling `await MockAuditAPI().know_ref(text, **kwargs)` — typically when the LLM response content-security pipeline checks referenced websites/knowledge bases while the mock audit API is the configured client.

Common situations: Local dev or test environments that default to the mock audit API; enabling a security policy that includes know_ref screening without switching to the real audit service; a newly added audit step not yet mirrored in the mock.

Related errors


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

Appendix: source

Thrown at core/workflow/infra/audit_system/audit_api/mock/mock_audit_api.py:272

        :param text: Text content to be processed
        :param kwargs: Additional keyword arguments
        :return: None
        """
        # path = f"/audit/v3/aichat/outputMedia"
        # TODO: To be implemented
        raise NotImplementedError("MockAuditAPI.output_media is not implemented yet")

    async def know_ref(self, text: str, **kwargs: Any) -> None:
        """
        In LLM content security scenarios, filter, detect and identify websites, knowledge bases
        and other data referenced during LLM responses, and process and respond accordingly based on security policies.
        :param text: Text content to be processed
        :param kwargs: Additional keyword arguments
        :return: None
        """
        # path = f"/audit/v3/aichat/knowRef"
        # TODO: To be implemented
        raise NotImplementedError("MockAuditAPI.know_ref is not implemented yet")

View on GitHub (pinned to 5e758547a8)