Skip to content

CubeLoop — a Pythonic, async-native agent harness core designed for high performance, readability, and production-grade persistence.

fix(hitl): use get_running_loop + tighten resume-slot-keep test assertion

xf gonge772e6e2a117
diff --git a/cubepi/hitl/channel.py b/cubepi/hitl/channel.py
index 9d24731..b96c326 100644
--- a/cubepi/hitl/channel.py
+++ b/cubepi/hitl/channel.py
@@ -138,7 +138,7 @@ class _BaseChannel:
timeout_seconds=effective_timeout,
)
self._pending = req
- self._future = asyncio.get_event_loop().create_future()
+ self._future = asyncio.get_running_loop().create_future()
exc_caught: BaseException | None = None
signal_task: asyncio.Future[Any] | None = None
diff --git a/tests/hitl/test_in_memory_channel.py b/tests/hitl/test_in_memory_channel.py
index 70d41b7..3a515b5 100644
--- a/tests/hitl/test_in_memory_channel.py
+++ b/tests/hitl/test_in_memory_channel.py
@@ -215,6 +215,7 @@ async def test_attach_resume_answer_qid_mismatch_keeps_slot():
for a different question and should NOT be popped)."""
ch = InMemoryChannel()
ch.attach_resume_answer("tc-OLD", True)
+ assert ch._resume_slot == ("tc-OLD", True) # baseline
async def host():
while ch.pending is None:
@@ -226,3 +227,6 @@ async def test_attach_resume_answer_qid_mismatch_keeps_slot():
asyncio.create_task(host())
ans = await ch.approve(tool_name="bash", tool_call_id="tc-NEW", args={})
assert ans.decision == "deny"
+ # Slot for the OLD qid is still pre-loaded (the implementation should
+ # NOT pop it just because a different qid came through).
+ assert ch._resume_slot == ("tc-OLD", True)