{"record":{"id":"c2452ccabba08213","repo":"agentscope-ai/agentscope","slug":"type-self-name-does-not-implement-on-acting","errorCode":null,"errorMessage":"{type(self).__name__} does not implement on_acting","messagePattern":"(.+?) does not implement on_acting","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/agentscope/middleware/_base.py","lineNumber":165,"sourceCode":"        Args:\n            agent (`Agent`):\n                The Agent instance executing this middleware.\n            input_kwargs (`dict`):\n                Dictionary containing:\n\n                - ``tool_call`` (``ToolCallBlock``): the tool call to execute.\n                  By the time this hook is invoked the tool call has already\n                  been validated and permitted.\n            next_handler (`Callable[..., AsyncGenerator]`):\n                Callable that executes the next middleware or\n                ``_acting_impl``.\n\n        Yields:\n            `ToolChunk | ToolResponse`:\n                Intermediate ``ToolChunk`` objects followed by a final\n                ``ToolResponse`` produced by the tool.\n        \"\"\"\n        raise RuntimeError(\n            f\"{type(self).__name__} does not implement on_acting\",\n        )\n        yield  # pylint: disable=unreachable\n\n    async def on_check_permission(\n        self,\n        agent: \"Agent\",\n        input_kwargs: dict,\n        next_handler: Callable[..., Awaitable[\"PermissionDecision\"]],\n    ) -> \"PermissionDecision\":\n        \"\"\"Hook for intercepting permission checking for one tool call.\n\n        This hook runs after the tool has been resolved and its input has been\n        parsed and validated, but before the resulting decision is consumed by\n        the agent.\n\n        Middleware can delegate with ``next_handler(**input_kwargs)``, replace\n        the returned decision, or return a decision without delegating. The","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/agentscope-ai/agentscope/blob/e90f1c7592896cc95f6e5ee506194f533378247d/src/agentscope/middleware/_base.py#L147-L183","documentation":"Middleware.on_acting base stub raises RuntimeError when invoked: a middleware in the acting (tool-execution) phase chain did not override on_acting, which is required to intercept ToolChunk/ToolResponse streams.","triggerScenarios":"A middleware lacking on_acting is registered in a chain that wraps tool execution; or an override calls super().on_acting(...). Raised during agent tool use.","commonSituations":"Permission-logging or audit middlewares written for other phases accidentally added to the acting chain; refactors that renamed the method; middleware subclasses built against an older API version where the hook was optional.","solutions":["Implement async on_acting(self, agent, tool_call, next_handler) yielding ToolChunk/ToolResponse via next_handler","Remove the middleware from tool-execution chains if it doesn't apply","Check the installed version's Middleware base class for the exact expected signature"],"exampleFix":"// before\nclass MetricsMiddleware(Middleware):\n    async def on_model_call(self, agent, messages, next_handler):\n        return await next_handler(messages)\n# acting chain -> RuntimeError 235\n\n// after\nclass MetricsMiddleware(Middleware):\n    async def on_acting(self, agent, tool_call, next_handler):\n        async for chunk in next_handler(tool_call):\n            yield chunk\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_acting is not Middleware.on_acting","typeGuard":"def implements_on_acting(mw) -> bool:\n    from agentscope.middleware import Middleware\n    return type(mw).on_acting is not Middleware.on_acting","tryCatchPattern":null,"preventionTips":["Implement passthrough on_acting in every middleware added to agents that use tools","Check hook coverage in middleware unit tests","Match method names/signatures to the installed agentscope version"],"tags":["middleware","hook-not-implemented","tool-execution"],"backgroundTag":"abstract-method-not-implemented","analyzedSha":"e90f1c7592896cc95f6e5ee506194f533378247d","analyzedAt":"2026-08-28T18:24:12.087Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}