CubeLoop — a Pythonic, async-native agent harness core designed for high performance, readability, and production-grade persistence.
Python agent-frameworkagent-harnessagent-runtimeagentic-aiai-agentsai-frameworkanthropicharnessharness-engineeringharness-frameworklanggraphlanggraph-alternativellmmcpopenaipi-agentpi-agent-corepythonpython-agent
fix(hitl): guard private _bind_emit on protocol-only HitlChannel impls
xf gong48a0664c941b
diff --git a/cubepi/agent/agent.py b/cubepi/agent/agent.pyindex 97f4c98..78f5a16 100644--- a/cubepi/agent/agent.py+++ b/cubepi/agent/agent.py@@ -178,7 +178,10 @@ class Agent(Generic[TMessage]):self.checkpointer = checkpointerself.thread_id = thread_idself._channel = channel- if channel is not None:+ # _bind_emit is a _BaseChannel internal, not part of the HitlChannel+ # protocol. Third-party channels that only implement the public+ # protocol won't have it — skip the wiring instead of crashing.+ if channel is not None and hasattr(channel, "_bind_emit"):channel._bind_emit(lambda e: self._process_event(e))self._run_lock = asyncio.Lock()diff --git a/tests/hitl/test_agent_channel_wiring.py b/tests/hitl/test_agent_channel_wiring.pyindex c22b1f5..4c2ed9b 100644--- a/tests/hitl/test_agent_channel_wiring.py+++ b/tests/hitl/test_agent_channel_wiring.py@@ -43,3 +43,48 @@ def test_channel_emit_is_bound_to_agent_process_event():_agent(channel=ch)# Verify the emit callback was bound (no public API; verify via attribute)assert ch._emit is not None+++def test_agent_accepts_protocol_only_channel_without_bind_emit():+ """Regression: Agent must not require the private _bind_emit hook on the+ channel — it is a _BaseChannel internal, not part of the HitlChannel+ protocol. Third-party channels that only implement the public protocol+ should construct cleanly.++ Codex PR #127 review feedback (P2, agent/agent.py).+ """++ class ProtocolOnlyChannel:+ """Implements the HitlChannel protocol surface; no _BaseChannel+ inheritance, no _bind_emit method."""++ pending = None++ async def confirm(self, *args, **kwargs): # pragma: no cover - unused here+ return True++ async def approve(self, *args, **kwargs): # pragma: no cover - unused here+ raise NotImplementedError++ async def ask(self, *args, **kwargs): # pragma: no cover - unused here+ return {}++ def subscribe(self): # pragma: no cover - unused here+ async def gen():+ if False:+ yield None++ return gen()++ async def answer(self, *args, **kwargs): # pragma: no cover - unused here+ return None++ async def cancel(self, *args, **kwargs): # pragma: no cover - unused here+ return None++ def attach_resume_answer(self, *args, **kwargs): # pragma: no cover+ return None++ ch = ProtocolOnlyChannel()+ agent = _agent(channel=ch)+ assert agent.channel is ch