Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

1.1 KB
Raw Blame
"""Nested browser denials stop the owner before the rejected tool returns."""

import asyncio
from types import SimpleNamespace

from dodaios.agent_chat.service import AgentChatService


async def test_cancel_signal_is_immediate_and_does_not_touch_another_chat():
    loop = asyncio.get_running_loop()
    own = SimpleNamespace(turn_id="own-turn", task=loop.create_future(), cancel=asyncio.Event())
    other = SimpleNamespace(turn_id="other-turn", task=loop.create_future(), cancel=asyncio.Event())
    service = object.__new__(AgentChatService)
    service._running = {"own": own, "other": other}
    service._approvals = {"a": loop.create_future(), "b": loop.create_future()}
    service._approval_session = {"a": "own", "b": "other"}
    try:
        assert service.signal_cancel("own")
        assert own.cancel.is_set()
        assert service._approvals["a"].result() == "cancel"
        assert not other.cancel.is_set()
        assert not service._approvals["b"].done()
        assert not service.signal_cancel("missing")
    finally:
        own.task.cancel()
        other.task.cancel()
        service._approvals["b"].cancel()