From 7b564653ab5c82612d31f9a6404aadf0ea469fc3 Mon Sep 17 00:00:00 2001 From: Bryant Date: Fri, 24 Jul 2026 19:03:47 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20(exceptions):=20Export=20Pol?= =?UTF-8?q?icyViolationError=20and=20OpTerminatedError?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both classes exist in agent_assembly.exceptions and are documented across several docs pages as top-level imports, but were absent from the __init__ lazy-export tables, so `from agent_assembly import PolicyViolationError` (and OpTerminatedError) raised ImportError. Wire them through the lazy-export machinery exactly like the sibling ToolExecutionBlockedError export. Refs AAASM-5056 Co-Authored-By: Claude Opus 4.8 (1M context) --- agent_assembly/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/agent_assembly/__init__.py b/agent_assembly/__init__.py index f100befd..9ec709b5 100644 --- a/agent_assembly/__init__.py +++ b/agent_assembly/__init__.py @@ -34,6 +34,8 @@ "AdapterValidationError": _MODULE_EXCEPTIONS, "ToolExecutionBlockedError": _MODULE_EXCEPTIONS, "MCPToolBlockedError": _MODULE_EXCEPTIONS, + "PolicyViolationError": _MODULE_EXCEPTIONS, + "OpTerminatedError": _MODULE_EXCEPTIONS, "AuditEvent": _MODULE_TYPES, "CallStackNode": _MODULE_TYPES, "CallStackNodeKind": _MODULE_TYPES, @@ -56,6 +58,8 @@ "AdapterValidationError", "ToolExecutionBlockedError", "MCPToolBlockedError", + "PolicyViolationError", + "OpTerminatedError", "AuditEvent", "CallStackNode", "CallStackNodeKind", @@ -116,7 +120,11 @@ def __dir__() -> list[str]: from agent_assembly.exceptions import ConfigurationError as ConfigurationError from agent_assembly.exceptions import GatewayError as GatewayError from agent_assembly.exceptions import MCPToolBlockedError as MCPToolBlockedError + from agent_assembly.exceptions import OpTerminatedError as OpTerminatedError from agent_assembly.exceptions import PolicyError as PolicyError + from agent_assembly.exceptions import ( + PolicyViolationError as PolicyViolationError, + ) from agent_assembly.exceptions import ( ToolExecutionBlockedError as ToolExecutionBlockedError, ) From d266850336468cf968feeb9360e88e8610ef79e3 Mon Sep 17 00:00:00 2001 From: Bryant Date: Fri, 24 Jul 2026 19:04:15 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E2=9C=85=20(exceptions):=20Guard=20top-lev?= =?UTF-8?q?el=20PolicyViolationError/OpTerminatedError=20exports?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Regression test for AAASM-5056: asserts both classes import from the package top level, appear in __all__, and resolve to the same objects as in agent_assembly.exceptions. Refs AAASM-5056 Co-Authored-By: Claude Opus 4.8 (1M context) --- test/unit/test_exceptions.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/unit/test_exceptions.py b/test/unit/test_exceptions.py index b5eac6c7..f4030e02 100644 --- a/test/unit/test_exceptions.py +++ b/test/unit/test_exceptions.py @@ -1,5 +1,7 @@ from __future__ import annotations +import agent_assembly +import agent_assembly.exceptions as exceptions from agent_assembly import MCPToolBlockedError @@ -13,3 +15,14 @@ def test_mcp_tool_blocked_error_exposes_tool_and_server_metadata() -> None: assert str(error) == "blocked" assert error.tool_name == "search_docs" assert error.server == "https://mcp.example.test" + + +# AAASM-5056: these two classes are documented as top-level imports; guard +# against them silently dropping out of the package's public export tables. +def test_policy_violation_and_op_terminated_are_top_level_exports() -> None: + from agent_assembly import OpTerminatedError, PolicyViolationError + + assert "PolicyViolationError" in agent_assembly.__all__ + assert "OpTerminatedError" in agent_assembly.__all__ + assert PolicyViolationError is exceptions.PolicyViolationError + assert OpTerminatedError is exceptions.OpTerminatedError