Skip to content

feat(slack): report a finished task back to its originating channel/thread (ent#224) - #1762

Closed
dolho wants to merge 1 commit into
feat/223-slack-per-channel-proactive-consentfrom
feat/224-slack-completion-report-back
Closed

dolho wants to merge 1 commit into
feat/223-slack-per-channel-proactive-consentfrom
feat/224-slack-completion-report-back

Conversation

@dolho

@dolho dolho commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Closes the partner scenario from the 2026-07-23 call: user asks in Slack → agent delegates a ~10-minute job → job succeeds → nobody tells the user.

Stacked on #1761 (ent#223 consent) — it needs the per-channel consent gate. Base is the #1761 branch; retarget to dev once that merges.

The issue called this "a join". It wasn't — two things were missing

  1. Channel context didn't survive delegation. The A→B path never forwarded source_channel*, so B's row had no destination. ParallelTaskRequest gains parent_execution_id; chat_execution_service copies the parent's channel/chat/thread down (fail-open). MCP chat_with_agent gains an optional execution_id, mirroring the feat: effect-scoped idempotency keys for outbound side effects #1084 effect tools.
  2. Nothing reported at the terminal. New channel_completion_report posts the outcome to the originating channel/thread, hooked at both CAS-won chokepoints beside spawn_task_terminal_event (feat: system-emitted agent.task.completed/failed events at execution terminal (async caller report-back) #1578) — success and failure, since a silent failure is the bug.

⚠️ The load-bearing safety rule

A direct channel turn is synchronous and already replies inline, and those rows carry triggered_by == the channel name. Reporting them would duplicate every normal Slack reply in a customer workspace. So we report only when the context was INHERITED (triggered_by not in {slack, telegram, whatsapp}). That single condition is what keeps this from spamming the partner.

Also: ent#223 consent-gated · at-most-once via effect_guard (#1084) keyed on the resolved destination, never the generated body · Slack-only in v1 · fail-soft (a reporting failure never disturbs an execution that already completed and was billed).

Tests — 12, green

Double-post guard across all three channel triggers · delegated reporting into the right thread · consent + unbound gates · no-context / non-Slack / missing-row no-ops · failure terminals report · replay doesn't re-post · never-raises.

Honest limits

Related to ent#224 · needs #1761

🤖 Generated with Claude Code

…hread (ent#224)

The reported failure: a user asks in Slack, the agent delegates a ~10-minute job
to another agent, the job succeeds — and nobody tells the user. The trigger side
worked; the completion side died silently.

Two things were actually missing, and both are fixed here:

1. Channel context did not survive delegation. The A->B path never forwarded
   source_channel*, so B's row had no destination and B's terminal had nowhere to
   report. ParallelTaskRequest gains parent_execution_id; chat_execution_service
   copies the parent's channel/chat/thread down to the child (fail-open — a miss
   changes nothing). MCP chat_with_agent gains an optional execution_id so a
   delegating agent can pass its own execution, mirroring the #1084 effect tools.

2. Nothing reported at the terminal. channel_completion_report posts the outcome
   to the originating channel/thread, hooked at both CAS-won terminal chokepoints
   beside spawn_task_terminal_event (#1578) — success AND failure, because a
   silent failure is the bug being closed.

The no-double-post rule is the load-bearing part: a direct channel turn is
synchronous and the adapter already replies inline, and those rows carry
triggered_by == the channel name. Reporting them would duplicate every normal
Slack reply in a customer workspace, so we report ONLY when the context was
INHERITED (triggered_by not in {slack, telegram, whatsapp}).

Gated by ent#223 per-channel consent, at-most-once via effect_guard (#1084) keyed
on the resolved destination (never the generated body), Slack-only in v1, and
fail-soft throughout — a reporting failure never disturbs an execution that
already completed and was billed.

12 unit tests: the double-post guard across all three channel triggers, delegated
reporting into the right thread, consent + unbound gates, no-context/non-Slack/
missing-row no-ops, failure terminals reporting, replay not re-posting, and the
never-raises guarantee.

Related to ent#224
@dolho

dolho commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #1763, which consolidates all three Slack partner follow-ups (ent#222 / ent#223 / ent#224) into a single OSS PR — they share a migration chain and ent#224 is gated by ent#223's consent flag, so reviewing them separately was artificial. Every commit from this branch is included there, plus the Alembic head fix. The enterprise half stays in trinity-enterprise#232 (repo boundary).

@dolho dolho closed this Jul 24, 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.

1 participant