Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

docs: clarify inbound channel hand-offs (#4043)

OwenKephartae6821da9d1c
diff --git a/docs/channels/custom.mdx b/docs/channels/custom.mdx
index 6f7d8ebb7..f3919ee18 100644
--- a/docs/channels/custom.mdx
+++ b/docs/channels/custom.mdx
@@ -3,7 +3,7 @@ title: "Custom Channels"
description: "Author custom HTTP and WebSocket channels with routes, events, metadata, continuation tokens, and file uploads."
---
-When eve doesn't ship a channel for your surface, you build one. Custom channels expose HTTP or WebSocket endpoints, parse incoming requests, start or resume sessions, observe runtime events, and own delivery back to your platform.
+Build a custom channel to connect an HTTP or WebSocket endpoint to your agent. It can host a conversation or pass incoming events to another channel.
## File location and identity
@@ -232,45 +232,54 @@ The bridge server does not listen on its own port. It receives only upgrade even
## Cross-channel hand-off
-Route handlers can start or resume an agent session on a different channel via `ctx.to(channel, target).send(message, options)`. This is an agent hand-off: the message becomes turn input and invokes the model on the destination channel. Use it when an inbound request should pivot the conversation, such as an incident webhook that opens an investigation thread in Slack.
+Use `ctx.to(channel, target).send(message, { auth })` in a route handler to start or resume a conversation on another channel. The agent runs and replies on the destination channel. The hand-off doesn't start a session on the source channel, which returns only its HTTP response.
-To post a provider notification without starting an agent turn, call the destination provider's API instead. If that notification must survive process failures, use an application-owned outbox; see [Durable cross-channel notifications](../patterns/durable-cross-channel-notifications).
+This webhook filters incoming events and asks the agent to investigate in Slack. Import the destination channel's default export; `verifyAndParseEvent` is a helper you implement in your application.
-```ts
+```ts title="agent/channels/intake.ts"
import { defineChannel, POST } from "eve/channels";
+
+import { verifyAndParseEvent } from "../lib/inbound-events";
import slack from "./slack";
export default defineChannel({
routes: [
- POST("/incident", async (req, ctx) => {
- const incident = await req.json();
+ POST("/intake/events", async (req, ctx) => {
+ const event = await verifyAndParseEvent(req);
+ if (!event) return new Response("unauthorized", { status: 401 });
+ if (event.kind !== "actionable") return new Response("ok");
ctx.waitUntil(
ctx
.to(slack, { channelId: "C0123ABC" })
- .send(`Investigate ${incident.reference}: ${incident.title}`, {
+ .send(`Investigate ${event.reference}: ${event.summary}`, {
auth: {
- authenticator: "incidentio",
+ authenticator: "intake",
principalType: "service",
- principalId: incident.actor.id,
- attributes: { reference: incident.reference, severity: incident.severity },
+ principalId: event.source,
+ attributes: {},
},
}),
);
-
return new Response("ok");
}),
],
});
```
-Semantics:
+Before sending:
+
+- Verify the provider's signature and validate the payload, including size limits. Derive `event.source` from the verified sender, not an untrusted payload field.
+- Filter out events that should not reach the agent.
+- Deduplicate retried events in your application if duplicates would cause unwanted sessions or posts. `send(...)` does not deduplicate them.
+
+The supplied `auth` identifies who started the session, available to tools and event handlers as `session.auth.initiator`.
+
+The destination's `receive` hook defines the target fields and how they map to a session. See [Slack proactive sessions](./slack#proactive-sessions) for its target options. To let people continue the conversation, configure the destination's inbound handlers to accept follow-ups.
+
+`ctx.to(...)` is a route-handler API, not a method on every platform callback. [Handler-form schedules](../schedules#handler-form-run) provide the same operation as `to(...)`.
-- The target channel's authored `receive(input, { from })` hook owns the continuation-token format and initial state. Callers supply the target to `to(...)`, then the message and auth to `send(...)`.
-- `auth` flows through to `session.auth.initiator` so the target's event handlers and the agent's tools can read who started the session.
-- Calling `ctx.to(...).send(...)` does not also start a session on the current channel. The inbound channel's response is whatever the route handler returns explicitly.
-- `send(...)` is not a direct provider-message API. It supplies input to the agent on the destination channel.
-- The first argument is the target channel module's default export. Import it directly from `agent/channels/<name>.ts`. Identity is matched by reference.
+For notifications that don't need an agent turn, use the platform's API instead. See [Durable cross-channel notifications](../patterns/durable-cross-channel-notifications) when those posts also need retries.
## Channel metadata
diff --git a/docs/channels/overview.mdx b/docs/channels/overview.mdx
index cacdd9343..7bb817be4 100644
--- a/docs/channels/overview.mdx
+++ b/docs/channels/overview.mdx
@@ -3,15 +3,23 @@ title: "Overview"
description: "How users reach your agent: the channel contract, the base eve HTTP channel, and authoring custom channels."
---
-A channel is the edge adapter between a platform and your agent. It does three things:
+A channel connects a platform to your agent. For conversations, it:
-- Normalizes platform input into a user message.
-- Owns the channel-local address that maps a platform conversation to its current durable session.
-- Decides delivery, meaning how, where, and whether a response goes back.
+- Converts incoming messages into agent input.
+- Maps each platform conversation to an eve session.
+- Decides how, where, and whether to deliver replies.
+
+A channel can also receive events and pass them to another channel, without starting a conversation of its own.
eve ships a base HTTP channel plus first-class platform channels, and you can author your own. Browse the full set in the [Integrations](/integrations) gallery and choose the Channels filter.
-After a channel normalizes input, eve runs the same agent runtime regardless of where the message came from. Tools and instructions do not need channel-specific logic.
+After a channel dispatches a message, eve runs the same agent runtime regardless of where the event came from. Tools and instructions do not need channel-specific logic.
+
+## Choose where the conversation lives
+
+The agent doesn't have to reply where an event arrived. A webhook, for example, can start a conversation in a team chat without sending an agent reply to the webhook's source.
+
+Use a [cross-channel hand-off](./custom#cross-channel-hand-off) when the conversation belongs elsewhere. The destination channel handles the session, replies, and follow-up messages. To post a notification without running the agent, use the platform's API instead.
## Audience
@@ -72,9 +80,7 @@ The eve channel is the framework's default HTTP session API, the routes the term
## Custom channels
-When eve doesn't ship a channel for your surface, build one with `defineChannel` from `eve/channels`. A custom channel declares route handlers (`GET`, `POST`, `PUT`, `PATCH`, `DELETE`, `WS`), an `events` map, and uses `send(address, input)` to start or resume a session. See [Custom channels](./custom) for the full walkthrough, including WebSocket routes, cross-channel agent hand-off, channel metadata, address tokens, and file uploads.
-
-A cross-channel `send(...)` supplies input to the agent and invokes the model on the destination channel. eve does not currently provide a direct cross-channel provider-message queue. To post without starting a turn, use the provider API. See [Durable cross-channel notifications](../patterns/durable-cross-channel-notifications) when delivery also needs application-managed retries and deduplication.
+Build a channel with `defineChannel` from `eve/channels` when you need your own HTTP or WebSocket endpoint. Its routes can start conversations on that channel or hand work to another one. See [Custom channels](./custom) for examples and the authoring API.
## Relationship to the Chat SDK
diff --git a/docs/channels/slack.mdx b/docs/channels/slack.mdx
index f85e50d74..41d674e50 100644
--- a/docs/channels/slack.mdx
+++ b/docs/channels/slack.mdx
@@ -458,8 +458,6 @@ When the model replies while its [tasks](/docs/tools/tasks) keep working, that r
Outbound text preserves bare `@` tokens as literal text. To mention a user, embed Slack's `<@USER_ID>` syntax directly or use `channel.thread.mentionUser(userId)`.
-When a session starts without a `threadTs` (say, from a schedule's `to(slack, target).send(...)`), eve gives it a unique temporary continuation token. The first agent post anchors the session to the Slack message timestamp, and later posts and mentions resume that same session. Pass `initialMessage` with a `Card` to land a structured anchor first instead. `threadTs` and `initialMessage` are mutually exclusive.
-
The example below overrides `onAppMention` to gate on an authored message. The built-in completion handler still posts the reply and uploads long responses as snippets. Event handlers receive `(eventData, channel, ctx)`, with Slack platform handles on `channel.thread` and `channel.slack`:
```ts
@@ -543,9 +541,20 @@ The private authorization button uses the label **Sign in**, so long connection
### Proactive sessions
-Start a session without an inbound message through `ctx.to(slack, target).send(message, { auth })` from another channel, or `to(slack, target).send(message, { auth })` from a schedule `run` handler. The proactive target shape is `{ channelId, installationTeamId?, threadTs?, initialMessage?, audience? }`. It defaults to `unknown`; pass `audience` only when the caller already knows the destination's visibility. Set `installationTeamId` to the app installation workspace when a function-form bot token must select an installation. This sends turn input to the agent; it is not a direct Slack post.
+Start a Slack conversation from a [webhook on another channel](./custom#cross-channel-hand-off) or a [schedule](../schedules#handler-form-run), without waiting for someone to message the app.
+
+Pass `{ channelId }` as the target to start a new thread. The agent's first post becomes the thread's root message. You can also set these target fields:
+
+| Field | Use |
+| -------------------- | ----------------------------------------------------------------------------------------- |
+| `threadTs` | Continue an existing thread instead of creating one. |
+| `initialMessage` | Post a card as the thread root before the agent runs. Cannot be combined with `threadTs`. |
+| `installationTeamId` | Select the app installation workspace when using a function-form bot token. |
+| `audience` | Set the destination's visibility when you know it. Defaults to `unknown`. |
+
+The default mention handler lets teammates continue the session by mentioning the app in the thread. To accept replies without a mention, [configure an `onMessage` hook and the required Slack subscriptions and scopes](#continue-conversations-without-repeated-mentions).
-To post without invoking the model, use `ctx.thread.post(...)` in an inbound Slack handler or `channel.thread.post(...)` in an `events` handler. Use `callSlackApi(...)` where no Slack channel context exists. For application-managed retries and deduplication, see [Durable cross-channel notifications](../patterns/durable-cross-channel-notifications).
+For a Slack post without an agent turn, use `ctx.thread.post(...)` in an inbound handler or `channel.thread.post(...)` in an `events` handler. Outside a handler, use [`callSlackApi(...)`](#slack-api-calls-outside-a-handler).
### Attachments