{"record":{"id":"6b2b0fc6296bc1f3","repo":"agentscope-ai/agentscope","slug":"invalid-permission-decision-behavior-decision-be","errorCode":null,"errorMessage":"Invalid permission decision behavior: {decision.behavior}","messagePattern":"Invalid permission decision behavior: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/agentscope/agent/_agent.py","lineNumber":2522,"sourceCode":"                    # The ended event for the tool result\n                    yield ToolResultEndEvent(\n                        reply_id=self.state.reply_id,\n                        tool_call_id=tool_call.id,\n                        state=chunk.state,\n                        metadata=chunk.metadata,\n                    )\n\n                else:\n                    # Intermediate ToolChunk — convert to streaming events\n                    async for evt in self._convert_tool_chunk_to_event(\n                        tool_call.id,\n                        chunk.content,\n                    ):\n                        yield evt\n\n            return\n\n        raise ValueError(\n            f\"Invalid permission decision behavior: {decision.behavior}\",\n        )\n\n    async def _acting(\n        self,\n        tool_call: ToolCallBlock,\n    ) -> AsyncGenerator[\"ToolChunk | ToolResponse\", None]:\n        \"\"\"Raw tool execution entry point (maybe wrapped by middleware).\n\n        This method is the hook point for ``on_acting`` middleware.  It\n        delegates to :meth:`_acting_impl` which wraps\n        ``toolkit.call_tool`` directly.  Permission checking and context\n        writes are **not** part of this method — they are handled by\n        :meth:`_execute_tool_call` before and after this call.\n\n        Args:\n            tool_call (`ToolCallBlock`):\n                The tool call block to execute.","sourceCodeStart":2504,"sourceCodeEnd":2540,"githubUrl":"https://github.com/agentscope-ai/agentscope/blob/e90f1c7592896cc95f6e5ee506194f533378247d/src/agentscope/agent/_agent.py#L2504-L2540","documentation":"A defensive ValueError raised in the agent's permission handling when a permission decision object carries a behavior the agent does not know how to execute. The permission engine returns decisions like allow/deny/ask; an unrecognized behavior means the decision producer and consumer are out of sync.","triggerScenarios":"A custom acting middleware or permission hook returns a PermissionDecision with a behavior value outside the supported set, reaching the fall-through branch after the handled behaviors yield events and return.","commonSituations":"Upgrading agentscope where new decision behaviors were added but custom middleware returns an old/new mismatched enum; typos in behavior strings; third-party middleware incompatible with the installed agent version.","solutions":["Check the value of decision.behavior in your middleware/hook against the PermissionBehavior enum supported by your installed agentscope version","Pin/upgrade agentscope so middleware and agent share the same decision enum","Return only documented behaviors (ALLOW/DENY/ASK equivalents) from custom permission logic"],"exampleFix":"# before\ndef my_middleware(...):\n    decision = PermissionDecision(behavior=\"approve\")  # unknown\n\n# after\nfrom agentscope.agent import PermissionBehavior\ndecision = PermissionDecision(behavior=PermissionBehavior.ALLOW)","handlingStrategy":"validation","validationCode":"from agentscope.agent import PermissionBehavior  # adjust import\n\ndef behavior_supported(behavior) -> bool:\n    try:\n        return behavior in set(PermissionBehavior)\n    except TypeError:\n        return False","typeGuard":"def is_known_behavior(value) -> bool:\n    return isinstance(value, str) and value in {\"allow\", \"deny\", \"ask\"}","tryCatchPattern":"try:\n    await agent.run(msg)\nexcept ValueError as e:\n    if \"Invalid permission decision behavior\" in str(e):\n        fix_middleware_behavior(); raise","preventionTips":["Pin agentscope versions between app and middleware","Only return enum members, never raw strings, for behaviors","Add unit tests asserting middleware returns valid behaviors"],"tags":["agentscope","permissions","middleware","internal-invariant"],"backgroundTag":"invalid-enum-value","analyzedSha":"e90f1c7592896cc95f6e5ee506194f533378247d","analyzedAt":"2026-08-28T18:24:12.087Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}