Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

[slack]: optional audience on proactive receive targets (#2842)

Zach Cowan3f20c8047277
diff --git a/.changeset/slack-proactive-audience.md b/.changeset/slack-proactive-audience.md
new file mode 100644
index 000000000..023128f5d
--- /dev/null
+++ b/.changeset/slack-proactive-audience.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+Add optional `audience` on Slack proactive `receive` / `ctx.send` targets so webhook and schedule handoffs can pass channel visibility without an extra Slack API call.
diff --git a/docs/guides/instrumentation.md b/docs/guides/instrumentation.md
index 8d13e5028..0bcb4ff22 100644
--- a/docs/guides/instrumentation.md
+++ b/docs/guides/instrumentation.md
@@ -58,7 +58,7 @@ You are responsible for ensuring any observability or eval provider is approved
The third configurable surface, [runtime context events](#runtime-context), attaches per-model-call values to these spans.
-Built-in messaging channels classify their instrumentation metadata with an `audience`: `public`, `private`, or `unknown`. Slack public channels and Chat SDK workspace-visible threads are public; direct and private conversations are private; platform surfaces without enough visibility evidence remain unknown.
+Built-in messaging channels classify their instrumentation metadata with an `audience`: `public`, `private`, or `unknown`. Slack public channels and Chat SDK workspace-visible threads are public; direct and private conversations are private; platform surfaces without enough visibility evidence remain unknown. Proactive Slack `receive` / `ctx.send` handoffs stay `unknown` unless the caller passes `audience` on the target, for example when a webhook or schedule already knows the destination channel is public.
## Channel delivery traces
diff --git a/packages/eve/src/public/channels/slack/slackChannel.test.ts b/packages/eve/src/public/channels/slack/slackChannel.test.ts
index 744ec8744..a9d7dde67 100644
--- a/packages/eve/src/public/channels/slack/slackChannel.test.ts
+++ b/packages/eve/src/public/channels/slack/slackChannel.test.ts
@@ -3722,7 +3722,7 @@ describe("slackChannel().receive", () => {
const [continuationToken, input] = send.mock.calls[0]!;
expect(continuationToken).toBe("C123:1700000000.000001");
expect(input.message).toBe("do the thing");
- expect(input.state).toEqual({
+ expect(input.state).toMatchObject({
channelId: "C123",
installationTeamId: null,
threadTs: "1700000000.000001",
@@ -3732,6 +3732,46 @@ describe("slackChannel().receive", () => {
expect(input.auth.principalId).toBe("p");
});
+ it("persists an explicit public audience on the proactive send state", async () => {
+ const send = vi.fn().mockResolvedValue({ id: "s" });
+ await buildReceive()(
+ {
+ message: "do the thing",
+ target: { audience: "public", channelId: "C123", threadTs: "1700000000.000001" },
+ auth: null,
+ },
+ mockChannelContext(send),
+ );
+ expect(fetchMock).not.toHaveBeenCalled();
+ expect(send.mock.calls[0]![1].state).toMatchObject({ audience: "public" });
+ });
+
+ it("persists an explicit private audience on the proactive send state", async () => {
+ const send = vi.fn().mockResolvedValue({ id: "s" });
+ await buildReceive()(
+ {
+ message: "do the thing",
+ target: { audience: "private", channelId: "C_PRIVATE", threadTs: "1700000000.000001" },
+ auth: null,
+ },
+ mockChannelContext(send),
+ );
+ expect(send.mock.calls[0]![1].state).toMatchObject({ audience: "private" });
+ });
+
+ it("omits audience from proactive send state when the target does not supply one", async () => {
+ const send = vi.fn().mockResolvedValue({ id: "s" });
+ await buildReceive()(
+ {
+ message: "do the thing",
+ target: { channelId: "C123", threadTs: "1700000000.000001" },
+ auth: null,
+ },
+ mockChannelContext(send),
+ );
+ expect(send.mock.calls[0]![1].state).not.toHaveProperty("audience");
+ });
+
it("selects and persists the installation workspace for proactive sends", async () => {
fetchMock.mockResolvedValueOnce(
new Response(JSON.stringify({ ok: true, ts: "1800000000.000900" }), {
diff --git a/packages/eve/src/public/channels/slack/slackChannel.ts b/packages/eve/src/public/channels/slack/slackChannel.ts
index 404cb239f..b6d28df81 100644
--- a/packages/eve/src/public/channels/slack/slackChannel.ts
+++ b/packages/eve/src/public/channels/slack/slackChannel.ts
@@ -72,7 +72,7 @@ import {
} from "#public/channels/upload-policy.js";
import { verifySlackRequest, type SlackWebhookVerifier } from "#public/channels/slack/verify.js";
import { defineChannel, POST, type Channel } from "#public/definitions/channel.js";
-import type { ChannelAudience } from "#shared/channel-audience.js";
+import { normalizeChannelAudience, type ChannelAudience } from "#shared/channel-audience.js";
import { markEventHandled } from "./utils.js";
export type {
@@ -278,6 +278,12 @@ export interface SlackChannelCredentials {
export interface SlackReceiveTarget {
readonly channelId: string;
readonly threadTs?: string;
+ /**
+ * Optional audience for proactive receives. Omit to leave `unknown`.
+ * Pass when the caller already knows channel visibility, for example a
+ * webhook or schedule that classified the Slack destination before handoff.
+ */
+ readonly audience?: ChannelAudience;
/** Slack workspace whose app installation supplies credentials for this send. */
readonly installationTeamId?: string;
/**
@@ -988,16 +994,31 @@ async function receiveOnSlack(
// Threadless proactive runs need distinct identities until their first
// Slack post supplies the real thread timestamp and re-keys the session.
const continuationThreadTs = threadTs || crypto.randomUUID();
+ const audience =
+ receiveTarget.audience === undefined
+ ? undefined
+ : normalizeChannelAudience(receiveTarget.audience);
+ const state: {
+ channelId: string;
+ installationTeamId: string | null;
+ threadTs: string | null;
+ teamId: string | null;
+ triggeringUserId: string | null;
+ audience?: ChannelAudience;
+ } = {
+ channelId,
+ installationTeamId: installationTeamId ?? null,
+ threadTs: threadTs || null,
+ teamId: deps.teamId ?? null,
+ triggeringUserId: deps.triggeringUserId ?? null,
+ };
+ if (audience !== undefined) {
+ state.audience = audience;
+ }
return deps.from(slackContinuationToken(channelId, continuationThreadTs)).send(input.message, {
auth: input.auth,
- state: {
- channelId,
- installationTeamId: installationTeamId ?? null,
- threadTs: threadTs || null,
- teamId: deps.teamId ?? null,
- triggeringUserId: deps.triggeringUserId ?? null,
- },
+ state,
title: input.title,
});
}
diff --git a/research/channel-audience-content-policy.md b/research/channel-audience-content-policy.md
index 5d05dcc8d..d6619a61e 100644
--- a/research/channel-audience-content-policy.md
+++ b/research/channel-audience-content-policy.md
@@ -1,7 +1,7 @@
---
issue: https://github.com/vercel/eve/issues/2331
status: proposed
-last_updated: "2026-08-31"
+last_updated: "2026-09-01"
---
# Audience-aware trace content policy
@@ -20,7 +20,7 @@ Channels may project one of three values from their existing synchronous `metada
type ChannelAudience = "public" | "private" | "unknown";
```
-The field is optional for authored channels. Eve normalizes absent, malformed, and unsupported values to `unknown`. Built-in channel metadata interfaces require the field and classify only from platform evidence already captured during dispatch; ambiguous and proactive destinations remain `unknown` rather than performing observability-only network requests.
+The field is optional for authored channels. Eve normalizes absent, malformed, and unsupported values to `unknown`. Built-in channel metadata interfaces require the field and classify only from platform evidence already captured during dispatch; ambiguous and proactive destinations remain `unknown` rather than performing observability-only network requests. Proactive Slack `receive` / `ctx.send` targets may optionally supply `audience` when the caller already knows channel visibility, for example a webhook that classified the Slack destination before handoff.
The normalized audience is persisted with session trace state and exported as `agent.channel.audience` only on each `agent.session` window. Durable Eve state and an internal OpenTelemetry context key make the same value available to descendant export policies without duplicating a public attribute onto every span. Local subagents inherit the parent audience. A remote agent with principal forwarding propagates the immutable origin audience and the current hop's effective directional ceiling through one `eve.audience` W3C Baggage member. The receiver accepts it only with the same `trustedForwarders` decision that admitted the principal, then intersects it with its own process policy. Every later hop forwards that intersection; malformed and mixed-version assertions become metadata-only.