Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix: capture stopped request before abort; map Lark terminal receipts
qiqi870d2e876eb4
diff --git a/modules/agents/opencode/agent.py b/modules/agents/opencode/agent.pyindex 48c54e279..a59058e42 100644--- a/modules/agents/opencode/agent.py+++ b/modules/agents/opencode/agent.py@@ -1664,6 +1664,12 @@ class OpenCodeAgent(OpenCodeMessageProcessorMixin, BaseAgent):request.stop_failure_reason = "not_active"return False+ # Read alongside ``task``, not after the abort. Aborting can make the+ # task settle normally, which lets ``handle_message``'s ``finally`` run+ # and pop this entry while we are still awaiting — by the time the+ # receipt branch below looks, the request it needs would be gone.+ stopped_request = self._active_ack_requests.get(request.base_session_id)+req_info = self._session_manager.get_request_session(request.base_session_id)opencode_session_id = Noneif req_info:@@ -1696,7 +1702,6 @@ class OpenCodeAgent(OpenCodeMessageProcessorMixin, BaseAgent):# the ⏹️ on the command instead of on the message that started# the turn (and leave the real 👀 behind). Codex does the same# with the request it recovers from ``clear_pending``.- stopped_request = self._active_ack_requests.get(request.base_session_id)if stopped_request is not None:await self._remove_ack_reaction(stopped_request,diff --git a/modules/im/feishu.py b/modules/im/feishu.pyindex 3e5e62975..cc0a79fee 100644--- a/modules/im/feishu.py+++ b/modules/im/feishu.py@@ -56,6 +56,16 @@ _EMOJI_MAP: Dict[str, str] = {"✍": "Typing","shrug": "Shrug","🤷": "Shrug",+ # Terminal receipts: ⏹️ stopped, ⚠️ interrupted. Lark has neither glyph, so+ # each maps to the published key whose meaning matches — ``SILENT`` for a+ # turn told to go quiet (the stop result is deliberately silent, so the+ # reaction is its only trace) and ``ERROR`` for a runtime that died mid-turn.+ "stop_button": "SILENT",+ "⏹️": "SILENT",+ "⏹": "SILENT",+ "warning": "ERROR",+ "⚠️": "ERROR",+ "⚠": "ERROR","thumbsup": "THUMBSUP","👍": "THUMBSUP","+1": "THUMBSUP",diff --git a/tests/test_feishu_reaction_emoji.py b/tests/test_feishu_reaction_emoji.pyindex cc3f54e0d..20221e462 100644--- a/tests/test_feishu_reaction_emoji.py+++ b/tests/test_feishu_reaction_emoji.py@@ -5,7 +5,13 @@ Lark rejects an unknown ``emoji_type`` with a parameter error, and the keys arelike a typo, silently, because ``add_reaction`` only warns when the normalizedvalue is non-ASCII. Every expectation below was read off the published table(https://open.feishu.cn/document/server-docs/im-v1/message-reaction/emojis-introduce)-rather than guessed from the unicode name.+rather than guessed from the unicode name. That page renders its table+client-side, so where it could not be read directly the key was confirmed+against the ``chyroc/lark`` ``type_emoji.go`` enum, in which every key carries+the official ``lark-reaction-cn/emoji_*.png`` CDN image it renders as — enough+to verify a key exists and what it depicts. Absence from that enum proves+nothing (it omits ``Shrug`` and ``GoGoGo``, both of which work), so it is only+ever used as evidence *for* a key."""import sys@@ -47,6 +53,12 @@ VERIFIED_EMOJI_TYPES = {"👏": "APPLAUSE","💪": "MUSCLE","🎉": "PARTY",+ # Terminal receipts. Lark publishes no ⏹️/⚠️ glyph; these two keys are the+ # closest published meanings (emoji_silent.png / emoji_errr.png).+ "⏹️": "SILENT",+ "⏹": "SILENT",+ "⚠️": "ERROR",+ "⚠": "ERROR",}@@ -71,26 +83,25 @@ class FeishuReactionEmojiTests(unittest.TestCase):UNCONFIRMED_REACTION_EMOJI,NOT_DELIVERED_REACTION_EMOJI,SUBAGENT_REACTION_EMOJI,+ STOPPED_REACTION_EMOJI,+ INTERRUPTED_REACTION_EMOJI,):with self.subTest(emoji=emoji):self.assertIn(emoji, _EMOJI_MAP)self.assertTrue(_normalize_emoji(emoji).isascii())- def test_terminal_receipts_are_knowingly_unmapped(self):- """⏹️/⚠️ degrade to no reaction on Lark, on purpose, for now.+ def test_terminal_receipts_stay_distinguishable(self):+ """A stop and a crash must not land on the same reaction.- The module docstring's rule is that every key is read off the published- table, never guessed, and that table was not reachable when the receipts- landed. An unmapped emoji is the safe failure: ``add_reaction`` warns and- the user loses only the receipt, whereas a guessed ``STOP`` would be- rejected wholesale. The interruption NOTICE is a real message and is- unaffected either way. Delete this test and add the two rows to- ``VERIFIED_EMOJI_TYPES`` once the keys are confirmed.+ ⏹️ is the only trace a ``/stop`` leaves — its result is deliberately+ silent — so collapsing it onto the crash key would make a clean stop+ look like a dead runtime."""- for emoji in (STOPPED_REACTION_EMOJI, INTERRUPTED_REACTION_EMOJI):- with self.subTest(emoji=emoji):- self.assertNotIn(emoji, _EMOJI_MAP)+ self.assertNotEqual(+ _normalize_emoji(STOPPED_REACTION_EMOJI),+ _normalize_emoji(INTERRUPTED_REACTION_EMOJI),+ )def test_variation_selector_forms_share_one_mapping(self):"""``_normalize_emoji`` strips colons and whitespace, not U+FE0F."""diff --git a/tests/test_opencode_stop_receipt.py b/tests/test_opencode_stop_receipt.pyindex fc4b171fa..3c91bc5fe 100644--- a/tests/test_opencode_stop_receipt.py+++ b/tests/test_opencode_stop_receipt.py@@ -133,6 +133,49 @@ class OpenCodeStopIntentTests(unittest.IsolatedAsyncioTestCase):self.assertIsNot(receipts[0][0], stop_request)self.assertEqual(agent._user_stopped_sessions, set())+ async def test_receipt_survives_handle_messages_cleanup_racing_the_abort(self):+ """The waiter that owns the turn can finish its ``finally`` mid-abort.++ ``handle_message`` is blocked on ``await task``; a task settled by the+ abort wakes it, and it pops both registries before ``handle_stop``+ resumes. Looking the request up after the abort finds nothing, so the+ receipt has to be captured up front.+ """+ agent = _agent()+ receipts: list[tuple[object, object]] = []+ agent._remove_ack_reaction = AsyncMock(+ side_effect=lambda request, *, terminal_emoji=None: receipts.append(+ (request, terminal_emoji)+ )+ )++ async def in_flight():+ await asyncio.sleep(3600)++ task = asyncio.create_task(in_flight())+ agent._active_requests["session-1"] = task+ turn_request = _request()+ agent._active_ack_requests["session-1"] = turn_request+ await asyncio.sleep(0)++ async def abort(*_args, **_kwargs):+ task.cancel()+ try:+ await task+ except asyncio.CancelledError:+ pass+ # Exactly what handle_message's finally does once its await returns.+ if agent._active_requests.get("session-1") is task:+ agent._active_requests.pop("session-1", None)+ agent._active_ack_requests.pop("session-1", None)++ agent._abort_active_request = abort++ self.assertTrue(await agent.handle_stop(_request()))++ self.assertEqual(receipts, [(turn_request, STOPPED_REACTION_EMOJI)])+ self.assertEqual(agent._active_ack_requests, {})+async def test_no_receipt_when_the_turns_request_was_not_retained(self):# Better no receipt than one stamped on the wrong message: a turn with# nothing retained (restored poll already cleaned up) just ends silently.