The Open Framework for Building Agents
feat(slack)!: clearer task card and typing labels (#4054)
Andrew Barbac09c0d669488
diff --git a/.changeset/slack-task-labels.md b/.changeset/slack-task-labels.mdnew file mode 100644index 000000000..d483a9e2b--- /dev/null+++ b/.changeset/slack-task-labels.md@@ -0,0 +1,5 @@+---+"eve": minor+---++Slack task cards and typing indicators name work more clearly. A task the agent hands to its own copy shows its brief instead of `agent: …`. Row titles and results use the first sentence, and results are cut to about 100 characters at a word boundary. The typing indicator shows the same labels as the card and says `Waiting on 3 tasks...` instead of naming one task and counting the rest. The `describeActionRequest` and `describeActionRequests` exports from `eve/channels/slack` are removed. A renderer can call `next()` for eve's default status, or read `presentation` from `actions.requested`.diff --git a/docs/channels/slack.mdx b/docs/channels/slack.mdxindex 5272bb8c9..1b64619fb 100644--- a/docs/channels/slack.mdx+++ b/docs/channels/slack.mdx@@ -454,19 +454,19 @@ The bases say where a call may go. `apiBaseUrl` is the base Slack Web API methodeve shows an agent's progress in two places. Short work, such as thinking or a tool call, appears in the thread status and never posts a message. [Tasks](/docs/tools/tasks), which keep working while the conversation continues, appear in a task card: one message per turn that eve updates in place. Replies post as ordinary messages, so the thread holds the conversation, the task card, and nothing else.-| Moment | Thread status |-| ---------------------------------- | ----------------------------------------------------------------------------- |-| A mention or DM arrives | `Thinking...`, right away, while the message hook is still deciding |-| The message hook drops the message | Cleared |-| The turn starts | `Working...` |-| The model reasons | The first line of its reasoning |-| The model calls tools | Its narration before the calls, or an action label such as `grep useEveAgent` |-| The turn waits on its tasks | `Waiting on researcher...`, or `Waiting on researcher and 2 more tasks...` |-| A reply posts | Cleared by Slack |+| Moment | Thread status |+| ---------------------------------- | ------------------------------------------------------------------------------- |+| A mention or DM arrives | `Thinking...`, right away, while the message hook is still deciding |+| The message hook drops the message | Cleared |+| The turn starts | `Working...` |+| The model reasons | The first line of its reasoning |+| The model calls tools | Its narration before the calls, or an action label such as `Search useEveAgent` |+| The turn waits on its tasks | `Waiting on researcher...`, or `Waiting on 3 tasks...` |+| A reply posts | Cleared by Slack |Slack clears a thread status after two minutes without a message, so during a long wait the task card is what shows the work is still going.-Action labels are the tool name plus its most telling argument, the agent name for agent calls, and `+N more` when the model requests several actions at once. They leave out the model's own `task_wait` and `task_cancel` calls. Reasoning snippets build progressively: extensions of at least four characters appear immediately, while smaller streamed deltas use a five-second refresh interval to avoid one Slack request per token.+Action labels follow the same rule as the task card titles described below, plus `+N more` when the model requests several actions at once. They leave out the model's own `task_wait` and `task_cancel` calls. Reasoning snippets build progressively: extensions of at least four characters appear immediately, while smaller streamed deltas use a five-second refresh interval to avoid one Slack request per token.Replies up to 12,000 characters render inline. Longer replies are uploaded unchanged as a Markdown snippet named `eve-response.md` with a short in-thread note, which requires the `files:write` bot scope. Upload failures are logged by the channel dispatcher; they do not trigger a model retry.@@ -480,9 +480,9 @@ When a turn starts its first task, eve posts a task card in the thread and keepsEach row shows:-- **Title:** the tool's [`label.start`](/docs/tools#label-tool-activity), the agent name and the first line of its brief for an agent task (`researcher: Find the incidents behind the checkout spike`), or the tool name.+- **Title:** the tool's [`label.start`](/docs/tools#label-tool-activity), or the tool name. An agent task shows the agent name and the first sentence of its brief (`researcher: Find the incidents behind the checkout spike`). A task the agent hands to its own copy shows the brief alone.- **Waiting:** while the task waits on an approval, an answer, or a sign-in, the row says so, as in `Waiting for approval`. In a DM or private channel it also shows the request's prompt; elsewhere it shows only what kind of request is waiting, since `approvalChannel` can send the request to one person. The request itself posts wherever `approvalChannel` sends it, and the row goes back to working once the request resolves.-- **How it ended:** the first line of the result or the agent's reply, `Failed` for a failure, or `Stopped` for a cancelled task. Failed and stopped rows never show a success check. In a DM or private channel, a failure also shows the first line of its error, as in `Failed: Rate limited`. Error text can carry internal details, so everywhere else, including proactive sessions without a known `audience`, shows `Failed` alone.+- **How it ended:** the first sentence of the result or the agent's reply, cut to about 100 characters, `Failed` for a failure, or `Stopped` for a cancelled task. Failed and stopped rows never show a success check. In a DM or private channel, a failure also shows the first sentence of its error, as in `Failed: Rate limited`. Error text can carry internal details, so everywhere else, including proactive sessions without a known `audience`, shows `Failed` alone.The plan title summarizes the turn: `Working on 2 tasks`, `1 of 2 tasks done`, `Waiting for approval`, then `Finished 2 tasks` or `Finished 3 tasks: 1 failed, 1 stopped`. A resumable task continued in a later turn appears in that turn's card.diff --git a/packages/eve/src/channel/task-card.ts b/packages/eve/src/channel/task-card.tsindex 2e478c8d5..6bdad0b48 100644--- a/packages/eve/src/channel/task-card.ts+++ b/packages/eve/src/channel/task-card.ts@@ -1,9 +1,10 @@import { isTaskControlTool } from "#protocol/task-tools.js";import type { UnstampedMessageStreamEvent } from "#protocol/message.js";+import { actionRequestName } from "#shared/action-request-name.js";import type { RuntimeActionRequest } from "#shared/action-types.js";import type { ChannelAudience } from "#shared/channel-audience.js";import type { JsonObject, JsonValue } from "#shared/json.js";-import { normalizePresentationText } from "#shared/presentation-text.js";+import { firstSentence, normalizePresentationText } from "#shared/presentation-text.js";/** A call's input travels to renderers only up to this many characters of JSON. */const MAX_ACTION_INPUT_LENGTH = 4_096;@@ -32,13 +33,16 @@ export interface TaskCardTask {readonly kind: "agent" | "tool";/** The tool or agent name. */readonly name: string;- /** The tool's start label, `agent: brief` for an agent, or the name. */+ /**+ * The tool's start label, or the name. An agent's is `researcher: brief`,+ * or the brief alone for a call to the agent's own copy.+ */readonly title: string;/** `blocked` while the task waits on a person; see {@link TaskCardTask.blockedOn}. */readonly status: TaskCardStatus | "blocked";readonly blockedOn?: TaskCardBlocker;/**- * One line describing the result once settled. A failure's line appears+ * The first sentence of the result once settled. A failure's line appears* only in a private conversation, since error text can carry internals.*/readonly summary?: string;@@ -305,7 +309,7 @@ function requestedCall(label: string | undefined,at: string,): TrackedCall {- const name = actionName(action);+ const name = actionRequestName(action);const call: { -readonly [K in keyof TrackedCall]: TrackedCall[K] } = {callId: action.callId,name,@@ -381,19 +385,6 @@ function bounded(calls: readonly TrackedCall[]): readonly TrackedCall[] {});}-function actionName(action: RuntimeActionRequest): string {- switch (action.kind) {- case "load-skill":- return "load_skill";- case "subagent-call":- return action.subagentName;- case "remote-agent-call":- return action.remoteAgentName;- default:- return action.toolName;- }-}-function actionStatus(status: string): TaskCardStatus {switch (status) {case "completed":@@ -418,9 +409,9 @@ function taskSummary(data: {}): string | undefined {switch (data.status) {case "completed":- return firstLine(resultText(data.output));+ return brief(resultText(data.output));case "failed":- return firstLine(data.error?.message);+ return brief(data.error?.message);default:return undefined;}@@ -434,13 +425,8 @@ function resultText(output: JsonValue | undefined): unknown {return fields.message ?? fields.text ?? fields.summary;}-function firstLine(value: unknown): string | undefined {- if (typeof value !== "string") return undefined;- const line = value- .split(/\r?\n/u)- .map((candidate) => candidate.trim())- .find((candidate) => candidate.length > 0);- return presentationText(line);+function brief(value: unknown): string | undefined {+ return typeof value === "string" ? firstSentence(value) : undefined;}function presentationText(value: string | undefined): string | undefined {diff --git a/packages/eve/src/client/message-action-parts.ts b/packages/eve/src/client/message-action-parts.tsindex 3d5ea7447..e0d8b119d 100644--- a/packages/eve/src/client/message-action-parts.ts+++ b/packages/eve/src/client/message-action-parts.ts@@ -1,3 +1,4 @@+import { actionRequestName } from "#shared/action-request-name.js";import type { RuntimeActionRequest, RuntimeActionResult } from "#shared/action-types.js";import type { InputRequest } from "#shared/input.js";import type {@@ -94,32 +95,16 @@ export function approvedApproval(part: EveDynamicToolPart | undefined):/** Maps a runtime action request onto its normalized tool descriptor. */export function normalizeActionRequest(action: RuntimeActionRequest): ActionDescriptor {+ const name = actionRequestName(action);switch (action.kind) {case "load-skill":- return {- kind: "load-skill",- name: "load_skill",- toolName: "eve:load-skill",- };+ return { kind: "load-skill", name, toolName: "eve:load-skill" };case "tool-call":case "workflow-tool-call":- return {- kind: "tool-call",- name: action.toolName,- toolName: action.toolName,- };+ return { kind: "tool-call", name, toolName: name };case "subagent-call":- return {- kind: "subagent-call",- name: action.subagentName,- toolName: `eve:subagent:${action.subagentName}`,- };case "remote-agent-call":- return {- kind: "subagent-call",- name: action.remoteAgentName,- toolName: `eve:subagent:${action.remoteAgentName}`,- };+ return { kind: "subagent-call", name, toolName: `eve:subagent:${name}` };}}diff --git a/packages/eve/src/execution/tasks/task-id-input.test.ts b/packages/eve/src/execution/tasks/task-id-input.test.tsnew file mode 100644index 000000000..37a24f8e0--- /dev/null+++ b/packages/eve/src/execution/tasks/task-id-input.test.ts@@ -0,0 +1,62 @@+import { describe, expect, it } from "vitest";+import { z } from "zod";++import { withTaskIdInput } from "#execution/tasks/task-id-input.js";+import type { HarnessToolDefinition } from "#harness/execute-tool.js";++function agentTool(name: string): HarnessToolDefinition {+ return {+ behavior: {+ availability: [],+ handling: {+ kind: "dispatch",+ target: {+ kind: name === "agent" ? "self-agent-call" : "subagent-call",+ nodeId: "node_1",+ subagentName: name,+ },+ },+ },+ description: "Delegate work.",+ inputSchema: z.object({ message: z.string() }),+ name,+ };+}++describe("agent call label", () => {+ it.each([+ [+ "names a subagent before the first sentence of its brief",+ "researcher",+ "Find the March incidents. Include timelines.\nThen rank them.",+ "researcher: Find the March incidents.",+ ],+ [+ "shows the brief alone for the agent's own copy",+ "agent",+ "\nInvestigate issue #4035. Summarize the report.",+ "Investigate issue #4035.",+ ],+ [+ "keeps versions and abbreviations inside one sentence",+ "agent",+ "On [email protected] the build fails, e.g. with an extension mounted. Reproduce it.",+ "On [email protected] the build fails, e.g. with an extension mounted.",+ ],+ [+ "keeps a leading list marker with its sentence",+ "agent",+ "1. Reproduce the build failure on main. Then bisect.",+ "1. Reproduce the build failure on main.",+ ],+ [+ "keeps a number after an abbreviation inside one sentence",+ "agent",+ "See PR No. 4035 for details. Then review it.",+ "See PR No. 4035 for details.",+ ],+ ["falls back to the agent's name for an empty brief", "agent", " \n", "agent"],+ ])("%s", (_name, tool, message, expected) => {+ expect(withTaskIdInput(agentTool(tool)).label?.start?.({ message })).toBe(expected);+ });+});diff --git a/packages/eve/src/execution/tasks/task-id-input.ts b/packages/eve/src/execution/tasks/task-id-input.tsindex 0ec736a9c..95c470daa 100644--- a/packages/eve/src/execution/tasks/task-id-input.ts+++ b/packages/eve/src/execution/tasks/task-id-input.ts@@ -6,7 +6,8 @@ import {import { isAgentTool } from "#execution/tasks/tool-entry-point.js";import type { HarnessToolDefinition } from "#harness/execute-tool.js";import type { JsonObject } from "#shared/json.js";-import { normalizePresentationText } from "#shared/presentation-text.js";+import { firstSentence } from "#shared/presentation-text.js";+import { AGENT_TOOL_NAME } from "#tools/framework/agent-contract.js";import { isToolSchema, withOptionalStringProperty } from "#tools/schema.js";// A `serve` tool's model input is the tool's own input plus an optional@@ -18,7 +19,7 @@ export const TASK_ID_INPUT = "taskId";/*** The tool as the model sees it: its input gains `taskId`, and its description* explains it. An agent tool also gets its activity label, the agent and the- * first line of its message: `researcher: Find the March incidents`.+ * first sentence of its message: `researcher: Find the March incidents`.*/export function withTaskIdInput(definition: HarnessToolDefinition): HarnessToolDefinition {const schema = definition.inputSchema;@@ -44,22 +45,19 @@ export function withTaskIdInput(definition: HarnessToolDefinition): HarnessToolD};}-/** `researcher: Find the March incidents`, or the agent's name when the message is empty. */+/**+ * `researcher: Find the March incidents`, from the first sentence of the+ * message. A call to the agent's own copy shows the brief alone, since its+ * name, `agent`, says nothing. The agent's name when the message is empty.+ */function agentCallLabel(name: string, input: unknown): string {const message =typeof input === "object" && input !== null? (input as { message?: unknown }).message: undefined;- const line = typeof message === "string" ? firstLine(message) : undefined;- return line === undefined ? name : `${name}: ${line}`;-}--function firstLine(text: string): string | undefined {- for (const line of text.split(/\r?\n/u)) {- const normalized = normalizePresentationText(line);- if (normalized !== "") return normalized;- }- return undefined;+ const brief = typeof message === "string" ? firstSentence(message) : undefined;+ if (brief === undefined) return name;+ return name === AGENT_TOOL_NAME ? brief : `${name}: ${brief}`;}/** A `serve` tool call's model input, split into the task it names and the tool's own input. */diff --git a/packages/eve/src/public/channels/slack/action-status.test.ts b/packages/eve/src/public/channels/slack/action-status.test.tsdeleted file mode 100644index 7f7588c7f..000000000--- a/packages/eve/src/public/channels/slack/action-status.test.ts+++ /dev/null@@ -1,103 +0,0 @@-import { describe, expect, it } from "vitest";--import {- describeActionRequest,- describeActionRequests,-} from "#public/channels/slack/action-status.js";-import type { RuntimeActionRequest } from "#shared/action-types.js";-import type { JsonObject } from "#shared/json.js";--function toolCall(toolName: string, input: JsonObject = {}): RuntimeActionRequest {- return { callId: "c1", input, kind: "tool-call", toolName };-}--describe("describeActionRequest", () => {- it("labels tool calls with the tool name plus the salient argument", () => {- expect(- describeActionRequest(toolCall("grep", { path: "packages", pattern: "useEveAgent" })),- ).toBe("grep useEveAgent");- expect(describeActionRequest(toolCall("read_file", { filePath: "agent/agent.ts" }))).toBe(- "read_file agent/agent.ts",- );- expect(describeActionRequest(toolCall("bash", { command: "pnpm test\npnpm lint" }))).toBe(- "bash pnpm test",- );- });-- it("keeps the tail of long paths and clips long commands", () => {- expect(- describeActionRequest(- toolCall("read_file", {- filePath: "/workspace/eve/packages/eve/src/runtime/actions/executor-registry.ts",- }),- ),- ).toBe("read_file actions/executor-registry.ts");-- const clipped = describeActionRequest(toolCall("bash", { command: "x".repeat(120) }));- expect(clipped.length).toBeLessThanOrEqual("bash ".length + 40);- expect(clipped.endsWith("...")).toBe(true);- });-- it("probes generic keys for tools without a salient-key entry", () => {- expect(describeActionRequest(toolCall("close_issue", { issueNumber: 42 }))).toBe(- "close_issue 42",- );- });-- it("falls back to the bare tool name without a telling argument", () => {- expect(describeActionRequest(toolCall("list_new_issues"))).toBe("list_new_issues");- });-- it("labels dispatched calls with the target name and skill loads with the skill", () => {- expect(- describeActionRequest({- callId: "c1",- description: "Reason about the issue",- input: {},- kind: "subagent-call",- name: "reasoner",- nodeId: "n1",- subagentName: "reasoner",- }),- ).toBe("reasoner");- expect(- describeActionRequest({- callId: "c1",- description: "Triage remotely",- input: {},- kind: "remote-agent-call",- name: "triage",- nodeId: "n1",- remoteAgentName: "triage",- }),- ).toBe("triage");- expect(- describeActionRequest({ callId: "c1", input: { skill: "arena" }, kind: "load-skill" }),- ).toBe("load_skill arena");- expect(- describeActionRequest({- callId: "c1",- input: { path: "agent/agent.ts" },- kind: "workflow-tool-call",- toolName: "publish",- workflowId: "publish-workflow",- }),- ).toBe("publish agent/agent.ts");- });-});--describe("describeActionRequests", () => {- it("shows the first label and a count for the rest of the batch", () => {- expect(- describeActionRequests([- toolCall("grep", { pattern: "digest" }),- toolCall("read_file", { filePath: "a.ts" }),- toolCall("read_file", { filePath: "b.ts" }),- ]),- ).toBe("grep digest +2 more");- });-- it("returns a generic label for an empty batch", () => {- expect(describeActionRequests([])).toBe("Working...");- });-});diff --git a/packages/eve/src/public/channels/slack/action-status.ts b/packages/eve/src/public/channels/slack/action-status.tsindex 7582282e5..0a1c38936 100644--- a/packages/eve/src/public/channels/slack/action-status.ts+++ b/packages/eve/src/public/channels/slack/action-status.ts@@ -1,100 +1,36 @@/**- * Typing-indicator labels for requested actions. The Slack indicator is- * plain text (`assistant.threads.setStatus` renders no markdown), so the- * label is the action's name plus its most telling argument — `grep useEve`- * or `read_file agent/agent.ts` instead of `Running grep...`.+ * Typing-indicator text for the turn's calls. It uses each call's start label,+ * the same text its task card row shows, so both surfaces name a call the same+ * way: `Run pnpm test`, `researcher: Find the March incidents`.*/+import type { ActionPresentationByCallId } from "#protocol/message.js";+import { actionRequestName } from "#shared/action-request-name.js";import type { RuntimeActionRequest } from "#shared/action-types.js";--/** Argument keys worth surfacing, most telling first, per tool. */-const SALIENT_KEYS: Readonly<Record<string, readonly string[]>> = {- bash: ["command"],- glob: ["pattern"],- grep: ["pattern", "path"],- load_skill: ["skill"],- read_file: ["filePath"],- web_fetch: ["url"],- web_search: ["query"],- write_file: ["filePath"],-};--/** Fallback keys probed on tools without a {@link SALIENT_KEYS} entry. */-const GENERIC_KEYS: readonly string[] = [- "filePath",- "path",- "pattern",- "command",- "query",- "name",- "repo",- "url",- "issueNumber",- "number",-];--const MAX_ARG_CHARS = 40;--function salientArg(toolName: string, input: Readonly<Record<string, unknown>>): string | null {- for (const key of SALIENT_KEYS[toolName] ?? GENERIC_KEYS) {- const value = input[key];- if (typeof value === "string" && value.trim().length > 0) return value;- if (typeof value === "number") return String(value);- }- return null;-}--/** Keep the tail of a path: `agent/lib/triage/cards.ts` -> `triage/cards.ts`. */-function shortenArg(text: string): string {- const oneLine = text.split(/\r?\n/u, 1)[0]?.trim() ?? "";- if (oneLine.length <= MAX_ARG_CHARS) return oneLine;- if (oneLine.includes("/") && !oneLine.includes(" ")) {- const segments = oneLine.split("/").filter((s) => s.length > 0);- const tail = segments.slice(-2).join("/");- if (tail.length <= MAX_ARG_CHARS) return tail;- }- return `${oneLine.slice(0, MAX_ARG_CHARS - 3).trimEnd()}...`;-}--function toolCallLabel(toolName: string, input: Readonly<Record<string, unknown>>): string {- const arg = salientArg(toolName, input);- return arg === null ? toolName : `${toolName} ${shortenArg(arg)}`;-}+import { AGENT_TOOL_NAME } from "#tools/framework/agent-contract.js";/**- * One action's typing-indicator label: `grep useEveAgent` for tool calls,- * the subagent or remote-agent name for dispatched calls, and- * `load_skill <name>` for skill loads.+ * The first call's label, or its tool or agent name, plus `+N more` when the+ * model requested several calls at once.*/-export function describeActionRequest(action: RuntimeActionRequest): string {- switch (action.kind) {- case "load-skill":- return toolCallLabel("load_skill", action.input);- case "remote-agent-call":- return action.remoteAgentName;- case "subagent-call":- return action.subagentName;- case "tool-call":- case "workflow-tool-call":- return toolCallLabel(action.toolName, action.input);- }-}--/**- * Typing-indicator text for one requested batch: the first action's- * {@link describeActionRequest} label, plus `+N more` when the model- * requested several actions at once.- */-export function describeActionRequests(actions: readonly RuntimeActionRequest[]): string {+export function describeActionRequests(+ actions: readonly RuntimeActionRequest[],+ presentation: ActionPresentationByCallId | undefined,+): string {const [first] = actions;if (first === undefined) return "Working...";- const label = describeActionRequest(first);- return actions.length === 1 ? label : `${label} +${actions.length - 1} more`;+ const label = presentation?.[first.callId]?.label ?? actionRequestName(first);+ return actions.length === 1 ? label : `${label} +${String(actions.length - 1)} more`;}-/** `Waiting on researcher...`, `Waiting on researcher and deploy...`, or `... and 2 more tasks...`. */+/**+ * `Waiting on researcher...` for one named task, otherwise a count such as+ * `Waiting on 3 tasks...`. The agent's own copy is never named, since its+ * name, `agent`, says nothing.+ */export function waitingOnTasks(names: readonly string[]): string {- const [first, second] = names;- if (names.length === 1) return `Waiting on ${first!}...`;- if (names.length === 2) return `Waiting on ${first!} and ${second!}...`;- return `Waiting on ${first!} and ${String(names.length - 1)} more tasks...`;+ const [only] = names;+ if (names.length === 1 && only !== AGENT_TOOL_NAME) return `Waiting on ${only!}...`;+ return names.length === 1+ ? "Waiting on a task..."+ : `Waiting on ${String(names.length)} tasks...`;}diff --git a/packages/eve/src/public/channels/slack/defaults.ts b/packages/eve/src/public/channels/slack/defaults.tsindex 51be58abe..8461765cc 100644--- a/packages/eve/src/public/channels/slack/defaults.ts+++ b/packages/eve/src/public/channels/slack/defaults.ts@@ -477,7 +477,9 @@ export const defaultEvents: SlackChannelInternalEvents = {(action) => action.kind !== "tool-call" || !isTaskControlTool(action.toolName),);if (actions.length === 0) return;- await channel.thread.startTyping(truncateTypingStatus(describeActionRequests(actions)));+ await channel.thread.startTyping(+ truncateTypingStatus(describeActionRequests(actions, event.presentation)),+ );},async "message.completed"(event, channel, _ctx) {diff --git a/packages/eve/src/public/channels/slack/index.ts b/packages/eve/src/public/channels/slack/index.tsindex 7f5ad4965..69ef2c6b0 100644--- a/packages/eve/src/public/channels/slack/index.ts+++ b/packages/eve/src/public/channels/slack/index.ts@@ -92,11 +92,6 @@ export type {TaskCardView,} from "#channel/task-card.js";-export {- describeActionRequest,- describeActionRequests,-} from "#public/channels/slack/action-status.js";-export {loadThreadContextMessages,type LoadThreadContextMessagesOptions,diff --git a/packages/eve/src/public/channels/slack/slackChannel.test.ts b/packages/eve/src/public/channels/slack/slackChannel.test.tsindex 0079f715f..b208dcd91 100644--- a/packages/eve/src/public/channels/slack/slackChannel.test.ts+++ b/packages/eve/src/public/channels/slack/slackChannel.test.ts@@ -695,7 +695,7 @@ describe("slackChannel() default event handlers", () => {expect(fetchMock).toHaveBeenCalledTimes(method === "files.getUploadURLExternal" ? 1 : 3);});- it("names the working tasks in the status while a turn waits on them", async () => {+ it("names one working task in the status while a turn waits, and counts several", async () => {const adapter = withState(getAdapter(slackChannel({ credentials: { botToken: "xoxb-test" } })),THREAD_STATE,@@ -730,10 +730,23 @@ describe("slackChannel() default event handlers", () => {ctx,);await callEvent(adapter, waiting, ctx);+ await callEvent(+ adapter,+ makeEvent("task.settled", {+ callId: "c2",+ status: "completed",+ taskId: "reviewer-1",+ turnId: "t1",+ }),+ ctx,+ );+ await callEvent(adapter, taskStarted("c4", "agent"), ctx);+ await callEvent(adapter, waiting, ctx);expect(slackStatuses(fetchMock)).toEqual([- "Waiting on researcher and 2 more tasks...",+ "Waiting on 3 tasks...","Waiting on reviewer...",+ "Waiting on a task...",]);});@@ -846,7 +859,7 @@ describe("slackChannel() default event handlers", () => {expect(ctx.state.pendingToolCallMessage).toBeNull();});- it("keeps the model's own task calls out of the typing status", async () => {+ it("shows the first call's start label in the typing status, without the model's own task calls", async () => {const adapter = withState(getAdapter(slackChannel({ credentials: { botToken: "xoxb-test" } })),THREAD_STATE,@@ -854,12 +867,13 @@ describe("slackChannel() default event handlers", () => {const ctx = buildAdapterContext(adapter, stubAccessor());const requested = (toolNames: readonly string[]) =>makeEvent("actions.requested", {- actions: toolNames.map((toolName, index) => ({- callId: `call_${String(index)}`,+ actions: toolNames.map((toolName) => ({+ callId: `call_${toolName}`,input: {},kind: "tool-call" as const,toolName,})),+ presentation: { call_search: { label: "Search checkout incidents" } },sequence: 0,stepIndex: 0,turnId: "t1",@@ -868,11 +882,9 @@ describe("slackChannel() default event handlers", () => {await callEvent(adapter, requested(["task_wait"]), ctx);expect(fetchMock).not.toHaveBeenCalled();- await callEvent(adapter, requested(["task_cancel", "search"]), ctx);- expect(fetchMock).toHaveBeenCalledTimes(1);- expect(parseSlackRequestBody(fetchMock.mock.calls[0]![1] as RequestInit)).toMatchObject({- status: "search",- });+ await callEvent(adapter, requested(["task_cancel", "search", "deploy"]), ctx);+ await callEvent(adapter, requested(["task_cancel", "deploy"]), ctx);+ expect(slackStatuses(fetchMock)).toEqual(["Search checkout incidents +1 more", "deploy"]);});it("message.completed clears typing without posting for empty delivery", async () => {diff --git a/packages/eve/src/public/channels/slack/task-card.test.ts b/packages/eve/src/public/channels/slack/task-card.test.tsindex bed6e57e6..ceed2eaa2 100644--- a/packages/eve/src/public/channels/slack/task-card.test.ts+++ b/packages/eve/src/public/channels/slack/task-card.test.ts@@ -133,7 +133,8 @@ const TWO_TASKS_STARTED: readonly UnstampedMessageStreamEvent[] = [const BOTH_TASKS_SETTLED: readonly UnstampedMessageStreamEvent[] = [createTaskSettledEvent({callId: DEPLOY_CALL,- output: "3 deploys; 14:02 changed the cache TTL\nFull log attached.",+ output:+ "The 14:02 deploy changed the cache TTL for every storefront route, so checkout requests missed the cache and queued at the origin. Full log attached.",status: "completed",taskId: "deploy-4hd8sa",turnId: TURN_ID,@@ -193,7 +194,15 @@ describe("Slack task card", () => {tasks: [{output: {- elements: [{ elements: [{ text: "3 deploys; 14:02 changed the cache TTL" }] }],+ elements: [+ {+ elements: [+ {+ text: "The 14:02 deploy changed the cache TTL for every storefront route, so checkout requests missed the…",+ },+ ],+ },+ ],},status: "complete",},diff --git a/packages/eve/src/public/channels/slack/task-card.ts b/packages/eve/src/public/channels/slack/task-card.tsindex 229871ae5..69cd64bfc 100644--- a/packages/eve/src/public/channels/slack/task-card.ts+++ b/packages/eve/src/public/channels/slack/task-card.ts@@ -28,7 +28,7 @@ const log = createLogger("slack.task-card");/** A plan block holds at most 50 tasks. */const MAX_PLAN_ROWS = 50;const MAX_TITLE_LENGTH = 80;-const MAX_LINE_LENGTH = 200;+const MAX_LINE_LENGTH = 100;/** Unfinished turns eve keeps tracking; the oldest drop first. */const MAX_TRACKED_TURNS = 20;const WRITE_RETRY_MS = 1_000;@@ -180,8 +180,12 @@ function richText(line: string): BlockKitBlock {};}+/** Cuts at a word boundary when one is near, so a row doesn't end mid-word. */function truncate(text: string, max: number): string {- return text.length <= max ? text : `${text.slice(0, max - 1)}…`;+ if (text.length <= max) return text;+ const cut = text.slice(0, max - 1);+ const space = cut.lastIndexOf(" ");+ return `${(space > max / 2 ? cut.slice(0, space) : cut).trimEnd()}…`;}/** Slack task ids must be unique in a plan; call ids are, but can carry characters Slack rejects. */diff --git a/packages/eve/src/shared/action-request-name.ts b/packages/eve/src/shared/action-request-name.tsnew file mode 100644index 000000000..7b263a6f5--- /dev/null+++ b/packages/eve/src/shared/action-request-name.ts@@ -0,0 +1,16 @@+import type { RuntimeActionRequest } from "#shared/action-types.js";++/** The tool, agent, or `load_skill` a request targets. */+export function actionRequestName(action: RuntimeActionRequest): string {+ switch (action.kind) {+ case "load-skill":+ return "load_skill";+ case "subagent-call":+ return action.subagentName;+ case "remote-agent-call":+ return action.remoteAgentName;+ case "tool-call":+ case "workflow-tool-call":+ return action.toolName;+ }+}diff --git a/packages/eve/src/shared/presentation-text.ts b/packages/eve/src/shared/presentation-text.tsindex 9c879ac07..a8f3a1bf8 100644--- a/packages/eve/src/shared/presentation-text.ts+++ b/packages/eve/src/shared/presentation-text.ts@@ -11,3 +11,19 @@ export function normalizePresentationText(text: string): string {.slice(0, MAX_ACTIVITY_TEXT_LENGTH));}++/**+ * The first sentence of the text's first non-empty line, normalized: a brief+ * for a message or result. Returns `undefined` when there is no text.+ */+export function firstSentence(text: string): string | undefined {+ for (const line of text.split(/\r?\n/u)) {+ const normalized = normalizePresentationText(line);+ if (normalized === "") continue;+ // A sentence ends at `.`, `!`, or `?` before a capital or quote, so+ // `e.g. the`, `No. 4035`, and `[email protected]` stay whole. A list marker such+ // as `1.` never ends one.+ return normalized.split(/(?<=[.!?])(?<!(?:^|\s)\d{1,2}\.)\s+(?=[\p{Lu}"'`(])/u, 1)[0];+ }+ return undefined;+}