Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

fix(studio): exclude Feishu control events from delivery history (#5154)

yufeng307b4e0b37fc
diff --git a/bot/tests/test_studio.py b/bot/tests/test_studio.py
index 0ee48025e..6c25c0d3d 100644
--- a/bot/tests/test_studio.py
+++ b/bot/tests/test_studio.py
@@ -137,19 +137,45 @@ async def test_pause_drops_new_inbound_messages(channel):
assert channel.store.history("connection") == []
-async def test_delivery_failure_is_not_reported_as_sent(channel, monkeypatch):
[email protected]("accepted", [False, True])
+async def test_delivery_status_matches_send_result(channel, monkeypatch, accepted):
from vikingbot.channels.feishu import FeishuChannel
- monkeypatch.setattr(FeishuChannel, "send", AsyncMock(return_value=False))
+ monkeypatch.setattr(FeishuChannel, "send", AsyncMock(return_value=accepted))
result = await channel.send(
OutboundMessage(
SessionKey(type="feishu", channel_id="cli_test", chat_id="studio:connection:group"),
"answer",
)
)
- assert not result
+ assert result is accepted
+ assert bool(channel.last_sent) is accepted
+ message = channel.store.history("connection")[0]
+ assert message["content"] == "answer"
+ assert message["status"] == ("sent" if accepted else "send_failed")
+
+
+ "metadata,emoji",
+ [
+ ({"action": "processing_tick", "tick_count": 0}, "StatusInFlight"),
+ ({"action": "add_reaction", "emoji": "THINKING"}, "THINKING"),
+ ],
+)
+async def test_control_events_do_not_create_delivery_history(channel, monkeypatch, metadata, emoji):
+ reaction = AsyncMock()
+ monkeypatch.setattr(channel, "send_processing_reaction", reaction)
+ await channel.send(
+ OutboundMessage(
+ SessionKey(type="feishu", channel_id="cli_test", chat_id="studio:connection:group"),
+ "",
+ metadata={**metadata, "message_id": "m1"},
+ )
+ )
+ reaction.assert_awaited_once_with("m1", emoji)
+ assert channel.store.history("connection") == []
+ assert channel.store.conversations("connection") == []
assert channel.last_sent is None
- assert channel.store.history("connection")[0]["status"] == "send_failed"
def test_public_config_never_returns_credentials_and_filters_accounts(tmp_path):
diff --git a/bot/vikingbot/studio/providers/feishu/channel.py b/bot/vikingbot/studio/providers/feishu/channel.py
index 7b380a503..a7b7ed880 100644
--- a/bot/vikingbot/studio/providers/feishu/channel.py
+++ b/bot/vikingbot/studio/providers/feishu/channel.py
@@ -196,7 +196,9 @@ class StudioFeishuChannel(FeishuChannel):
),
)
accepted = await super().send(msg)
- if msg.is_normal_message:
+ # Control actions use RESPONSE events, but are not chat deliveries.
+ is_control_action = msg.metadata.get("action") in ("add_reaction", "processing_tick")
+ if msg.is_normal_message and not is_control_action:
if accepted:
self.last_sent = now()
if not msg.metadata.get("studio_verification"):
diff --git a/web-studio/src/components/app-shell.tsx b/web-studio/src/components/app-shell.tsx
index c8681bb82..c38504465 100644
--- a/web-studio/src/components/app-shell.tsx
+++ b/web-studio/src/components/app-shell.tsx
@@ -128,13 +128,6 @@ const NAV_ITEMS: readonly NavItem[] = [
titleKey: 'navigation.compile.title',
to: '/compile',
},
- {
- icon: BrainIcon,
- id: 'agentExperience',
- section: 'workspace',
- titleKey: 'navigation.agentExperience.title',
- to: '/agent-experience',
- },
{
icon: MessagesSquareIcon,
id: 'sessions',
@@ -142,6 +135,13 @@ const NAV_ITEMS: readonly NavItem[] = [
titleKey: 'navigation.sessions.title',
to: '/sessions',
},
+ {
+ icon: BrainIcon,
+ id: 'agentExperience',
+ section: 'operations',
+ titleKey: 'navigation.agentExperience.title',
+ to: '/agent-experience',
+ },
{
icon: ScrollTextIcon,
id: 'requestLogs',