Repository navigation
feat: let the agent message you first on feishu - #31283
Conversation
Feishu was the one shipped channel that could only reply to an inbound message, so a cron result, a subagent completion, the auto-compaction notice, an owner-DM send_message and a dashboard mirror never reached a Feishu user. A send with no reply anchor is now a new message (im.v1.message.create) to an allow-listed open_id or, while allow_group is on, an allow-listed group chat_id. Which one is read from the live rosters, never from the id's shape, and an id on neither raises. The spool restart notice keeps its reply. Allow-listed DMs and groups are offered as available targets, and each turn binds its DM or group as the session's origin, so unattended output for a Feishu session comes back to it.
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. Every send is placed by a live allow-list lookup, so a forged or stale link can only reach a DM or group that is already allow-listed. The generic senders (owner notices, the notice sent when an inbound conversation is unbound, delivery containment) pass an address already resolved from a link or target, so changing what Notes
[DESIGN-REVIEWED] 768c9fc Description read[DESCRIPTION-READ] 1860f2b028279923723196f9820a5c785dcf3650515408de6bf1d6d703d8815e That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks: the Goal names issue #7846's decision, every item serves Feishu messaging you first, and each one goes through the existing transport seams ( What this change shipsInventory (9 items) — 9 justifiedIntent: let a Feishu user receive cron results, finished background tasks, compaction notices and
[FIRST-PRINCIPLES-REVIEWED] 768c9fc Description read[DESCRIPTION-READ] 07e39b527576e6f7812b061625ebe2d2e1eea5b747de9f0ffa3e1196c4c7a8d9 That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approved by Crew Captain for the on-call: checks green, PR Readiness passed, review lanes clean on this head. The on-call accepted the linked issue labels.
Problem / Motivation
Goal: The agent can message a Feishu user first: a cron result, a finished background task, the auto-compaction notice and a
send_messagereach the allow-listed Feishu DM or group they belong to.Feishu was the one shipped channel that could only reply to an inbound message. With no inbound message to answer, nothing could be sent: a silent cron reported nowhere, subagent completions and the compaction notice never arrived,
send_messageto Feishu fell back to a dashboard notification, the dashboard could not mirror a session into Feishu, and every Feishu DM target was listed as unavailable.Why it matters
Anyone who set Feishu up to be told when unattended work finishes gets nothing back on Feishu. The work completes, the answer exists, and the Feishu user has to open the dashboard to find it. Every other channel already delivers these messages.
Not a goal
open_idinallowed_open_ids, or a group inallowed_group_idswhileallow_groupis on, can receive a message.direct_peer_of, session resume).im:message:send_as_bot, which setup already asks for, for both reply and send.What changed (motivation → approach → change)
The platform has the verb Feishu was missing:
im.v1.message.createsends a new message to a person (receive_id_type=open_id) or a group (chat_id). The decision on #7846 was to support unprompted sends to configured DMs and groups only, the same rule as the other channels.send_messageopen_idor groupchat_id; anything else raisesmay_send_togroup:targets whileallow_groupis on, rechecked when resolvedsupports_proactive_sendFalseTrueorigin_conversationWhether an id is a DM or a group is read from the live allow-lists, never from its
ou_/oc_prefix, so removing someone from the list stops the messages at once. No proactive send replies to a stored message id: the session map can be rewritten from inside the sandbox, and a message id names no chat the transport can check, so even a forged link reaches only an allow-listed DM or group. The client getssend_newbesidesend_reply, sharing its chunking and grading; the unreadable-attachment answer inreceivecalls the client's reply directly.#7823 (streaming cards) is still open, conflicts with main and has had no commit since 2026-10-23, so this ships plain text instead of waiting on its card path; switching
send_newto cards is a small change once #7823 lands.The messaging and session specs, the Feishu setup guide (
feishu-integration.md) and the channel capability matrix (channel-capabilities.md) say Feishu can message you first; comments inchat_mirror.py,mcp_tools/messaging.pyandautonudge_service/model.pythat named Feishu as reply-only are corrected. Builds on #19123 by @chenmingwei23, which added the DM half of the same idea.Backwards compatibility
Breaking:
FeishuTransport.send_messageused to reply toconversation_idas a message id; it now sends a new message only to an allow-listed address and raises otherwise. Writer sweep on origin/main @ 42e5c9a: every caller of a Feishusend_message, each handled as follows.Reader: src/kiro_crew/feishu/transport.py:FeishuTransport.receive -- chat -- the unreadable-attachment answer calls
LarkClient.send_replydirectly;test_feishu_transport.py::TestUnreadableInboundIsAnsweredReader: src/kiro_crew/messaging/inbound_spool.py:replay_spooled -- release -- passes the spool route marker as
thread_id; the notice goes to the DM or group the marker names, as a new message quoting the entry;test_feishu_transport.py::TestSendMessage::test_a_spool_route_sends_to_the_chat_its_marker_namesReader: src/kiro_crew/dashboard/messaging_api/channel_delivery.py:_deliver_channel_dm -- cron -- reached Feishu never on main (
supports_proactive_send=False); now resolves an allow-listedopen_id;test_mcp_send_message_routing.pyReader: src/kiro_crew/dashboard/chat_turn/recipient.py:_deliver_cross_surface_reply -- chat -- refused Feishu on main; now reads the origin or mirror link, which holds the address;
test_feishu_dispatch.py::TestTurn::test_the_turn_binds_its_dm_or_group_as_the_originReader: src/kiro_crew/dashboard/chat_mirror.py:api_chat_slot_mirror_link -- chat -- refused Feishu on main; links through
resolve_configured_target;test_chat_mirror.py::TestMirrorLink::test_proactive_channel_acceptedNo Feishu link existed on main to migrate: the mirror endpoint refused the channel and no Feishu turn bound an origin.
Tests
test_feishu_transport.py: a send goes toopen_idfor a DM andchat_idfor a group, and raises for a message id, an empty id or a revoked peer; a spool route sends to the chat its marker names and never replies to the stored message id, and a DM marker naming a group, an unknown marker or a foreignthread_idis refused;may_send_toagrees; DM and group targets are available, and a group stops being a target or a recipient whenallow_groupturns off; a refused send raises.test_feishu_client_send_new.py(new):send_newbuildsmessage.createwithreceive_id_type,receive_id,msg_type=textand the unescaped content, and answersFalsewhen Feishu refuses.test_feishu_sdk_contract.py: through the reallark-oapiSDK (HTTP stubbed), the create call isPOST /open-apis/im/v1/messages?receive_id_type=open_idwith that body. Runs where thefeishuextra is installed.test_feishu_dispatch.py: a DM turn bindsChannelLink("feishu", <open_id>)as its origin and a group turn itschat_id.test_chat_mirror.py,test_mcp_send_message_routing.py: no shipped channel is non-proactive any more, and the "roster admits it but no target" case now uses Teams, which still needs an inbound message first.Determinism: the 12 new or changed tests passed 20 runs at
-n0and 10 at-n 4 --dist loadgroup --max-worker-restart=2besidetest_feishu_renderer.pyandtest_feishu_gateway.py; the five touched files (216 tests) passed in a shuffled order (seed 7650).Manual verification
test_feishu_sdk_contract.pywas run locally withlark-oapiinstalled (8 passed), and_sync_createwas also driven withreceive_id_type=chat_idthe same way. Not run against a live Feishu tenant.Screenshots / video
N/A — no frontend file changes; the dashboard's existing target picker lists the Feishu targets the backend now marks available.
Related Issues
Closes #7846
Sibling sweep
N/A — a
feat:PR.Pattern harvest
N/A — a
feat:PR.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)