{"record":{"id":"7babfcdc595b46a8","repo":"agentscope-ai/agentscope","slug":"f-type-self-name-does-not-implement-on-chec","errorCode":null,"errorMessage":"f\"{type(self).__name__} does not implement on_check_permission\"","messagePattern":"f\"(.+?) does not implement on_check_permission\"","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/agentscope/middleware/_base.py","lineNumber":209,"sourceCode":"        Args:\n            agent (`Agent`):\n                The Agent instance performing the permission check.\n            input_kwargs (`dict`):\n                Dictionary containing:\n\n                - ``tool_call`` (``ToolCallBlock``): validated call metadata\n                  used to correlate the permission decision.\n                - ``tool`` (``ToolBase``): the resolved tool instance.\n                - ``tool_input`` (``dict``): the parsed and validated input.\n            next_handler (`Callable[..., Awaitable[PermissionDecision]]`):\n                Callable that executes the next middleware or the built-in\n                permission resolution.\n\n        Returns:\n            `PermissionDecision`:\n                The decision the agent should consume.\n        \"\"\"\n        raise RuntimeError(\n            f\"{type(self).__name__} does not implement on_check_permission\",\n        )\n\n    async def on_model_call(\n        self,\n        agent: \"Agent\",\n        input_kwargs: dict,\n        next_handler: Callable[\n            ...,\n            Awaitable[\"ChatResponse\" | AsyncGenerator[\"ChatResponse\", None]],\n        ],\n    ) -> \"ChatResponse\" | AsyncGenerator[\"ChatResponse\", None]:\n        \"\"\"Hook for intercepting the model API call.\n\n        Args:\n            agent: The Agent instance executing this middleware\n            input_kwargs: Dictionary containing:\n                - messages: list[Msg]","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/agentscope-ai/agentscope/blob/e90f1c7592896cc95f6e5ee506194f533378247d/src/agentscope/middleware/_base.py#L191-L227","documentation":"Middleware.on_check_permission base stub raises RuntimeError when executed by the permission chain (execute_chain): every middleware participating in permission resolution must implement on_check_permission and return a PermissionDecision.","triggerScenarios":"A middleware registered in the permission-check chain that does not override on_check_permission; or an override delegating to super(). Raised whenever the agent evaluates permissions for a tool call with that chain active.","commonSituations":"Custom middlewares added to an agent with permission middleware enabled without implementing the permission hook; upgrading agentscope where permission middleware became part of the default chain; misordered chains that route permission checks through unrelated middlewares.","solutions":["Implement async on_check_permission(self, agent, tool_name, args, next_handler) returning a PermissionDecision (or delegating to next_handler)","If the middleware has no permission concern, ensure it's not part of the permission chain / provides a pass-through implementation","Align middleware signatures with the current agentscope version's base class"],"exampleFix":"// before\nclass LoggingMiddleware(Middleware):\n    async def on_model_call(self, agent, messages, next_handler):\n        return await next_handler(messages)\n# permission chain -> RuntimeError 236\n\n// after\nfrom agentscope.middleware import PermissionDecision\n\nclass LoggingMiddleware(Middleware):\n    async def on_check_permission(self, agent, tool_name, args, next_handler):\n        return await next_handler(tool_name, args)  # passthrough decision\n\n    async def on_model_call(self, agent, messages, next_handler):\n        return await next_handler(messages)","handlingStrategy":"type-guard","validationCode":"from agentscope.middleware import Middleware\nassert type(mw).on_check_permission is not Middleware.on_check_permission","typeGuard":"def implements_on_check_permission(mw) -> bool:\n    from agentscope.middleware import Middleware\n    return type(mw).on_check_permission is not Middleware.on_check_permission","tryCatchPattern":null,"preventionTips":["When enabling permission middleware, audit every registered middleware for the hook","Provide pass-through permission delegation in shared middleware base classes","Add integration tests covering tool permission checks"],"tags":["middleware","permissions","hook-not-implemented"],"backgroundTag":"abstract-method-not-implemented","analyzedSha":"e90f1c7592896cc95f6e5ee506194f533378247d","analyzedAt":"2026-08-28T18:24:12.087Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}