Skip to content

feat: let the agent message you first on feishu - #31283

Merged
bolichen97 merged 1 commit into
mainfrom
fix/7846-feishu-proactive-send
Nov 6, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/7846-feishu-proactive-send

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

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_message reach 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_message to 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

What changed (motivation → approach → change)

The platform has the verb Feishu was missing: im.v1.message.create sends 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.

Before After
send_message a reply to whatever id it was given always a new message, to an allow-listed open_id or group chat_id; anything else raises
Spooled restart notice a reply to the spooled message a new message to the DM or group its route marker names
may_send_to refused every non-spool send the same address lookup as the send
Configured targets every DM listed unavailable DMs available; groups added as group: targets while allow_group is on, rechecked when resolved
supports_proactive_send False True
A Feishu turn's session no origin link its DM or group bound as origin and mirror, through the shared origin_conversation

Whether 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 gets send_new beside send_reply, sharing its chunking and grading; the unreadable-attachment answer in receive calls 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_new to 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 in chat_mirror.py, mcp_tools/messaging.py and autonudge_service/model.py that 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_message used to reply to conversation_id as 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 Feishu send_message, each handled as follows.
Reader: src/kiro_crew/feishu/transport.py:FeishuTransport.receive -- chat -- the unreadable-attachment answer calls LarkClient.send_reply directly; test_feishu_transport.py::TestUnreadableInboundIsAnswered
Reader: 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_names
Reader: 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-listed open_id; test_mcp_send_message_routing.py
Reader: 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_origin
Reader: 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_accepted

No 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 to open_id for a DM and chat_id for 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 foreign thread_id is refused; may_send_to agrees; DM and group targets are available, and a group stops being a target or a recipient when allow_group turns off; a refused send raises.
  • test_feishu_client_send_new.py (new): send_new builds message.create with receive_id_type, receive_id, msg_type=text and the unescaped content, and answers False when Feishu refuses.
  • test_feishu_sdk_contract.py: through the real lark-oapi SDK (HTTP stubbed), the create call is POST /open-apis/im/v1/messages?receive_id_type=open_id with that body. Runs where the feishu extra is installed.
  • test_feishu_dispatch.py: a DM turn binds ChannelLink("feishu", <open_id>) as its origin and a group turn its chat_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 -n0 and 10 at -n 4 --dist loadgroup --max-worker-restart=2 beside test_feishu_renderer.py and test_feishu_gateway.py; the five touched files (216 tests) passed in a shuffled order (seed 7650).

Manual verification

test_feishu_sdk_contract.py was run locally with lark-oapi installed (8 passed), and _sync_create was also driven with receive_id_type=chat_id the 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

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

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.
@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners November 6, 2026 08:32
@bolichen97
bolichen97 requested a review from Zedmor November 6, 2026 08:32
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 6, 2026
@bolichen97
bolichen97 enabled auto-merge (squash) November 6, 2026 08:43
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 768c9fc7249f5734359ff30ecf5803f3133a4cf9 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 768c9fc7249f5734359ff30ecf5803f3133a4cf9 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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 send_message accepts breaks none of them.

Notes

  • inbound_spool.py:replay_spooled used to send the restart notice as a reply to the spooled message. It now sends a new message to the chat. In a busy group, people lose the visual link to the message they had sent. That's a small UX cost; mention it in the spec, or in the notice text itself.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 768c9fc7249f5734359ff30ecf5803f3133a4cf9 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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 (configured_targets, resolve_configured_target, may_send_to, origin_conversation).

What this change ships

Inventory (9 items) — 9 justified

Intent: let a Feishu user receive cron results, finished background tasks, compaction notices and send_message output without writing to the bot first. ADDITION.

  1. Cron results, subagent completions and compaction notices now reach the allow-listed Feishu DM or group — justified
  2. send_message to Feishu now always sends a new message to an allow-listed open_id or chat_id, and raises for anything else — justified
  3. The spooled restart notice now arrives as a new message in its DM or group instead of as a reply — justified
  4. Feishu DMs now show as available targets in the dashboard picker — justified
  5. Allowed Feishu groups appear as group: targets while allow_group is on — justified
  6. A Feishu turn binds its DM or group as the session's origin and mirror — justified
  7. The owner-DM route (session=feishu) now delivers instead of falling back to a dashboard notification — justified
  8. A dashboard session can now be mirrored into Feishu, and dashboard turns post into that chat — justified
  9. New client verb send_new, which shares chunking with send_reply — justified

[FIRST-PRINCIPLES-REVIEWED] 768c9fc

Description read

[DESCRIPTION-READ] 07e39b527576e6f7812b061625ebe2d2e1eea5b747de9f0ffa3e1196c4c7a8d9

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 768c9fc7249f5734359ff30ecf5803f3133a4cf9 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 768c9fc

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 768c9fc7249f5734359ff30ecf5803f3133a4cf9 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 768c9fc7249f5734359ff30ecf5803f3133a4cf9 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 768c9fc

Verdict parsed from the review's SHA-scoped output markers for commit 768c9fc7249f5734359ff30ecf5803f3133a4cf9.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 768c9fc7249f5734359ff30ecf5803f3133a4cf9 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 6, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@bolichen97
bolichen97 merged commit 65eb7f2 into main Nov 6, 2026
97 checks passed
@bolichen97
bolichen97 deleted the fix/7846-feishu-proactive-send branch November 6, 2026 09:52
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feishu is the only channel that cannot be sent to unprompted — no cron, subagent or compaction notice reaches it

2 participants