Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

feat(eve): show action contents in Slack typing labels (#622)

Rui3983d360a8f6
diff --git a/.changeset/slack-action-typing-labels.md b/.changeset/slack-action-typing-labels.md
new file mode 100644
index 000000000..b03a0e309
--- /dev/null
+++ b/.changeset/slack-action-typing-labels.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+The Slack channel's default typing indicator for `actions.requested` now shows the action's contents instead of a generic `Running <tool>...` label: the tool name plus its most telling argument (`grep useEveAgent`, `read_file agent/agent.ts`), the subagent or remote-agent name for dispatched calls, and `+N more` for batches. The label helpers are exported from `eve/channels/slack` as `describeActionRequest` and `describeActionRequests` for use in custom handlers.
diff --git a/docs/channels/slack.mdx b/docs/channels/slack.mdx
index a8eeb5e73..eb0a82a5e 100644
--- a/docs/channels/slack.mdx
+++ b/docs/channels/slack.mdx
@@ -99,7 +99,7 @@ when you need the bearer token itself.
### Delivery
-The default handlers reply in-thread and show progress. Typing indicators post automatically: `Thinking…` on inbound, `Working…` on `turn.started`, a truncated reasoning snippet on `reasoning.appended`, and tool status on `actions.requested`. Reasoning snippets build progressively: extensions of at least four characters appear immediately, while smaller streamed deltas use the five-second refresh interval to avoid one Slack request per token. Override `events["reasoning.appended"]` if you prefer generic wording. Override `onAppMention` or the `events` handlers to customize.
+The default handlers reply in-thread and show progress. Typing indicators post automatically: `Thinking…` on inbound, `Working…` on `turn.started`, a truncated reasoning snippet on `reasoning.appended`, and an action label on `actions.requested` — the tool name plus its most telling argument (`grep useEveAgent`, `read_file agent/agent.ts`), the subagent or remote-agent name for dispatched calls, and `+N more` when the model requests several actions at once. The model's own pre-tool narration, when present, takes precedence over the derived label. Reasoning snippets build progressively: extensions of at least four characters appear immediately, while smaller streamed deltas use the five-second refresh interval to avoid one Slack request per token. Override `events["reasoning.appended"]` if you prefer generic wording. Override `onAppMention` or the `events` handlers to customize.
When a session starts without a `threadTs` (say, from a schedule or `receive(slack, ...)`), 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.
diff --git a/packages/eve/src/public/channels/slack/action-status.test.ts b/packages/eve/src/public/channels/slack/action-status.test.ts
new file mode 100644
index 000000000..c13759003
--- /dev/null
+++ b/packages/eve/src/public/channels/slack/action-status.test.ts
@@ -0,0 +1,94 @@
+import { describe, expect, it } from "vitest";
+
+import {
+ describeActionRequest,
+ describeActionRequests,
+} from "#public/channels/slack/action-status.js";
+import type { RuntimeActionRequest } from "#runtime/actions/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");
+ });
+});
+
+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.ts
new file mode 100644
index 000000000..ea6ac3cdb
--- /dev/null
+++ b/packages/eve/src/public/channels/slack/action-status.ts
@@ -0,0 +1,91 @@
+/**
+ * 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...`.
+ */
+import type { RuntimeActionRequest } from "#runtime/actions/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)}`;
+}
+
+/**
+ * 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.
+ */
+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":
+ 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 {
+ const [first] = actions;
+ if (first === undefined) return "Working...";
+ const label = describeActionRequest(first);
+ return actions.length === 1 ? label : `${label} +${actions.length - 1} more`;
+}
diff --git a/packages/eve/src/public/channels/slack/defaults.ts b/packages/eve/src/public/channels/slack/defaults.ts
index 38d4b5640..a6d01506e 100644
--- a/packages/eve/src/public/channels/slack/defaults.ts
+++ b/packages/eve/src/public/channels/slack/defaults.ts
@@ -1,6 +1,7 @@
import type { SessionAuthContext } from "#channel/types.js";
import { createLogger, extractErrorId, formatErrorHint } from "#internal/logging.js";
+import { describeActionRequests } from "#public/channels/slack/action-status.js";
import { buildSlackAuthContext, slackUserIdFromAuthContext } from "#public/channels/slack/auth.js";
import {
buildAuthCompletedText,
@@ -182,8 +183,7 @@ export const defaultEvents: SlackChannelInternalEvents = {
await channel.thread.startTyping(truncateTypingStatus(buffered));
return;
}
- const labels = event.actions.map((a) => (a.kind === "tool-call" ? a.toolName : a.kind));
- await channel.thread.startTyping(truncateTypingStatus(`Running ${labels.join(", ")}...`));
+ await channel.thread.startTyping(truncateTypingStatus(describeActionRequests(event.actions)));
},
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.ts
index 4ab220380..84f733493 100644
--- a/packages/eve/src/public/channels/slack/index.ts
+++ b/packages/eve/src/public/channels/slack/index.ts
@@ -52,6 +52,11 @@ export {
export { defaultSlackAuth } from "#public/channels/slack/defaults.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.ts b/packages/eve/src/public/channels/slack/slackChannel.ts
index a391f06b4..af6f012b6 100644
--- a/packages/eve/src/public/channels/slack/slackChannel.ts
+++ b/packages/eve/src/public/channels/slack/slackChannel.ts
@@ -169,7 +169,7 @@ export interface SlackChannelState {
* Buffered text from a `message.completed` event whose `finishReason`
* was `"tool-calls"`. The default `actions.requested` handler uses the
* first non-empty line as the next typing indicator, surfacing the
- * model's pre-tool narration instead of "Running ...". Cleared at
+ * model's pre-tool narration instead of the action label. Cleared at
* `turn.started` and after use.
*/
pendingToolCallMessage?: string | null;