Skip to content

fix(channels): keep direct chat replies in Multica#5645

Merged
Bohan-J merged 1 commit into
multica-ai:mainfrom
beastpu:codex/fix-lark-web-chat-outbound
Jul 20, 2026
Merged

fix(channels): keep direct chat replies in Multica#5645
Bohan-J merged 1 commit into
multica-ai:mainfrom
beastpu:codex/fix-lark-web-chat-outbound

Conversation

@beastpu

@beastpu beastpu commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Closes #5644

Summary

  • classify outbound replies by task origin before consulting a channel binding
  • keep web/mobile direct-chat completions and failures inside Multica even when the session was originally created from Lark or Slack
  • preserve outbound delivery for channel-created tasks and add regression coverage for both integrations

Root cause

A chat session can retain its Lark or Slack binding after a user continues the same session from the Multica UI. The outbound subscribers treated that binding as sufficient proof that every later task originated from the external channel. Direct-chat tasks are distinguishable by a non-NULL chat_input_task_id, so the subscribers now enforce that boundary before loading installation credentials or sending.

Slack also extracts the task id from the typed chat-done payload emitted by TaskService and fails closed when task origin cannot be established.

Tests

  • go test ./internal/integrations/lark ./internal/integrations/slack -count=1
  • go test ./internal/handler ./internal/service
  • git diff --check

A local run of go test ./cmd/server reaches the existing readiness integration test but fails because /readyz and /healthz return 503 without healthy local dependencies; the focused channel, handler, and service packages pass.

@vercel

vercel Bot commented Jul 19, 2026

Copy link
Copy Markdown

@beastpu is attempting to deploy a commit to the IndexLabs Team on Vercel.

A member of the Team first needs to authorize it.

@beastpu
beastpu marked this pull request as ready for review July 20, 2026 01:58
A chat session can retain its Lark or Slack binding after a user
continues the same session from the Multica UI. The outbound subscribers
treated that binding as sufficient proof that every later task
originated from the external channel, so a web/mobile direct-chat reply
(or failure) leaked back into the bound external chat.

Direct-chat tasks are distinguishable by a non-NULL chat_input_task_id
(channel-created tasks leave it NULL). The subscribers now look up the
channel binding first and, only for bound sessions, load the task to
classify its origin before loading credentials or sending — so web-only
completions early-return on the cheap binding lookup instead of paying a
GetAgentTask query on every chat completion. Origin classification fails
closed: the in-process bus has no retry, so a transient lookup failure
drops the reply rather than risking a private turn reaching the channel.

Slack extracts the task id from the typed chat-done payload emitted by
TaskService. Adds regression coverage for both integrations: a bound
session plus a direct task sends nothing; a bound session plus a channel
task still sends exactly one reply.

Closes multica-ai#5644
@beastpu
beastpu force-pushed the codex/fix-lark-web-chat-outbound branch from bc0ee2a to ea8cbf3 Compare July 20, 2026 02:19
@Bohan-J

Bohan-J commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the fix, @beastpu! 🙏

We reviewed this end-to-end and verified the core invariant: classifying task origin by chat_input_task_id (non-NULL = web/mobile direct-chat task, NULL = channel/legacy task) correctly keeps direct-chat replies inside Multica while still delivering genuine channel replies, and it fails closed whenever the task origin can't be established. Nicely scoped, with regression coverage for both Lark and Slack. CI is green.

Merging now — appreciate the contribution! 🚀

@Bohan-J
Bohan-J merged commit 387e4fe into multica-ai:main Jul 20, 2026
5 checks passed
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.

[Bug]: Web chat replies leak into a bound Lark/Feishu conversation

2 participants