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
feat(hitl): HitlRequestEvent, HitlAnswerEvent, AgentSuspendedEvent, AgentAbortedEvent
xf gong350b978486ba
diff --git a/cubepi/agent/types.py b/cubepi/agent/types.pyindex f2511d7..f9e0348 100644--- a/cubepi/agent/types.py+++ b/cubepi/agent/types.py@@ -170,6 +170,29 @@ class ToolExecutionEndEvent(BaseModel):no reason)."""+class HitlRequestEvent(BaseModel):+ type: Literal["hitl_request"] = "hitl_request"+ request: Any # forward-declared; cubepi.hitl.types.HitlRequest+++class HitlAnswerEvent(BaseModel):+ type: Literal["hitl_answer"] = "hitl_answer"+ question_id: str+ answer: Any+ cancelled: bool = False+ timed_out: bool = False+++class AgentSuspendedEvent(BaseModel):+ type: Literal["agent_suspended"] = "agent_suspended"+ pending_request: Any # forward-declared; cubepi.hitl.types.HitlRequest+++class AgentAbortedEvent(BaseModel):+ type: Literal["agent_aborted"] = "agent_aborted"+ reason: str++AgentEvent = (AgentStartEvent| AgentEndEvent@@ -181,6 +204,10 @@ AgentEvent = (| ToolExecutionStartEvent| ToolExecutionUpdateEvent| ToolExecutionEndEvent+ | HitlRequestEvent+ | HitlAnswerEvent+ | AgentSuspendedEvent+ | AgentAbortedEvent)AgentEventSink = Callable[[AgentEvent], Awaitable[None]]diff --git a/tests/hitl/test_events.py b/tests/hitl/test_events.pynew file mode 100644index 0000000..da059a2--- /dev/null+++ b/tests/hitl/test_events.py@@ -0,0 +1,40 @@+from cubepi.agent.types import (+ AgentAbortedEvent,+ AgentSuspendedEvent,+ HitlAnswerEvent,+ HitlRequestEvent,+)+from cubepi.hitl.types import ConfirmRequest, HitlRequest+++def _req() -> HitlRequest:+ return HitlRequest(+ question_id="q-1",+ thread_id="t-1",+ payload=ConfirmRequest(prompt="ok?"),+ created_at=0.0,+ )+++def test_hitl_request_event_construct():+ e = HitlRequestEvent(request=_req())+ assert e.type == "hitl_request"+ assert e.request.question_id == "q-1"+++def test_hitl_answer_event_construct():+ e = HitlAnswerEvent(question_id="q-1", answer=True)+ assert e.type == "hitl_answer"+ assert e.cancelled is False+ assert e.timed_out is False+++def test_agent_suspended_event_construct():+ e = AgentSuspendedEvent(pending_request=_req())+ assert e.type == "agent_suspended"+ assert e.pending_request.question_id == "q-1"+++def test_agent_aborted_event_construct():+ e = AgentAbortedEvent(reason="user closed")+ assert e.type == "agent_aborted"