CedarCopilot wants to merge 0 commits into staging from fix/headless-slack-channel-context
Live on prod, no production signal yet
Strict CloudWatch fallback found 6 recent prod failure log lines for [backfillSlackChannelHistory] Backfill failed (Failed query: insert into \), but the same failure had 10 log lines in the comparable pre-deploy baseline. Libra is not blaming this PR intent without a.
Strict CloudWatch fallback found 6 recent prod failure log lines for [backfillSlackChannelHistory] Backfill failed (Failed query: insert into \), but the same failure had 10 log lines in the comparable pre-deploy baseline. Libra is not blaming this PR intent without a.
single_user
Libra has verdicts on 0 of 2 tracked behaviors on prod; 2 are still being checked. Libra attributed 1 failure to this change at medium confidence and is still confirming it. Libra checks hourly for 3 days after each deploy.
When a rep messages the Cedar Slack bot something like "send my meeting preps here from now on", the headless chat agent can't see which channel/DM it's being addressed in, so it can't act on "here" , it guessed "your DM" and told the user everything was already fine.
Root cause: event.channel reaches handleSlackBotInteraction but is dropped at the runChatAgent() boundary. It only survives encoded inside the opaque threadId (slack:{team}:{channel}:{ts}), which the agent never parses. There is no channel field anywhere in the prompt or the headless chat context.
SlackOrigin { channelId, isDm } from the DM/mention/thread handler into runChatAgent.buildSlackOriginContext() , a small dependency-free module (routeHandlers/slack/slack-origin-context.ts, so it's cheap to unit-test) that produces a prompt fragment naming the concrete channel ID and mapping "here" / "this channel" to it, or stating it's a DM./cedar next DM digest passes nothing (correctly a DM), and buildSlackOriginContext(undefined) returns '' so the caller's .filter(Boolean) drops it.Scope is deliberately just the input side (letting the agent see its channel). Where a recurring output is routed is unchanged and already agent-editable , e.g. meeting-prep delivery is the meeting-prep subagent's own notify/send slack.channelId.
slack-origin-context.test.ts , channel vs DM vs none, and that a channel message names the ID + points routing at the producing surface. All green.
listSlackChannels (slack-api.ts) lists channels via the superglue slack-list-channels workflow, which uses conversations.list (workspace public channels , ~9,982 in one workspace) and returns zero private channels, even ones the user is a member of and has groups:read for. Verified against a real user token=[redacted],private_channel returns their ~103 memberships *including* private channels. So an agent asked to route to a private channel *by name* still can't discover it (the "here"/event.channelpath in this PR is unaffected). Worth a separate PR switchinglistSlackChannelstousers.conversations` with both channel types.
🤖 Generated with Claude Code
The PR passes the originating Slack channel or DM into the headless chat-agent prompt so references such as “here” resolve to the correct surface.
handleSlackBotInteraction into runChatAgent.The PR appears safe to merge after the non-blocking import-path convention issue is corrected.
The Slack-origin data is threaded into prompt construction with focused tests, and no concrete runtime or security failure remains; only the two new relative imports conflict with repository standards.
Files Needing Attention: apps/server/src/mastra/routeHandlers/slack/slack-bot-chat.ts; apps/server/src/mastra/routeHandlers/slack/tests/slack-origin-context.test.ts
| Filename | Overview |
|---|---|
| apps/server/src/mastra/routeHandlers/slack/slack-bot-chat.ts | Threads Slack-origin metadata into the agent prompt correctly, but the new helper import violates the absolute-import convention. |
| apps/server/src/mastra/routeHandlers/slack/slack-origin-context.ts | Adds a small typed prompt builder that distinguishes channel, DM, and absent-origin contexts. |
| apps/server/src/mastra/routeHandlers/slack/tests/slack-origin-context.test.ts | Covers the helper's principal output variants, but its new import also violates the absolute-import convention. |
Libra has not measured any production surfaces for this change yet.