Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

[2/5] feat(eve): let tools label activity (#2717)

Ben Pankow1a4f0b3ae8d3
diff --git a/.changeset/cool-tools-label.md b/.changeset/cool-tools-label.md
new file mode 100644
index 000000000..2fb103dad
--- /dev/null
+++ b/.changeset/cool-tools-label.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+Allow tools to define an input-aware activity label for channel presentation. Framework tools now provide readable labels for shell, file, skill, fetch, and search actions.
diff --git a/docs/reference/typescript-api.md b/docs/reference/typescript-api.md
index f24ecb5b1..7a56c9d8d 100644
--- a/docs/reference/typescript-api.md
+++ b/docs/reference/typescript-api.md
@@ -54,7 +54,7 @@ export default defineTool({
| `mockModel` | `eve/evals` | Deterministic fixture agent models | [Evals](../evals/overview) |
| `useEveAgent` | `eve/react`, `eve/vue`, `eve/svelte` | frontend | [Frontend](../guides/frontend/overview) |
-Tool-wide authoring helpers such as `defineTool`, `defineWorkflowTool`, `defineDynamic`, and `disableTool` come from `eve/tools`. Capability-specific definitions and helpers use their own subpaths (see [Built-in tools](../concepts/built-in-tools)): reusable definitions such as `bash` and `glob` come from `eve/tools/<name>`, `webSearch` comes from `eve/tools/web_search`, `experimental_workflow` comes from `eve/tools/workflow`, `sleep` comes from `eve/tools/sleep`, and approval policies and types come from `eve/tools/approval`. The route verbs `GET`/`HEAD`/`POST`/`PUT`/`PATCH`/`DELETE`/`OPTIONS`/`WS` plus `disableRoute` come from `eve/channels`, and the channel auth helpers `localDev`/`vercelOidc`/`placeholderAuth` come from `eve/channels/auth`.
+Tool-wide authoring helpers and types such as `defineTool`, `defineWorkflowTool`, `defineDynamic`, `disableTool`, and `ToolLabelDefinition` come from `eve/tools`. Capability-specific definitions and helpers use their own subpaths (see [Built-in tools](../concepts/built-in-tools)): reusable definitions such as `bash` and `glob` come from `eve/tools/<name>`, `webSearch` comes from `eve/tools/web_search`, `experimental_workflow` comes from `eve/tools/workflow`, `sleep` comes from `eve/tools/sleep`, and approval policies and types come from `eve/tools/approval`. The route verbs `GET`/`HEAD`/`POST`/`PUT`/`PATCH`/`DELETE`/`OPTIONS`/`WS` plus `disableRoute` come from `eve/channels`, and the channel auth helpers `localDev`/`vercelOidc`/`placeholderAuth` come from `eve/channels/auth`.
`AgentReasoningDefinition` is exported from `eve` for the top-level `defineAgent({ reasoning })` setting. `AgentLimitsDefinition` is exported for `defineAgent({ limits })`. `AgentWorkflowDefinition` and `AgentWorkflowWorldDefinition` are exported from `eve` for the `defineAgent({ experimental: { workflow } })` config shape. `ExperimentalWorkflowToolInput` is exported from `eve/tools/workflow`; `WebSearchToolInput` and `WebSearchProvider` are exported from `eve/tools/web_search`.
diff --git a/docs/tools/overview.mdx b/docs/tools/overview.mdx
index 4ed24245b..93b229ec2 100644
--- a/docs/tools/overview.mdx
+++ b/docs/tools/overview.mdx
@@ -32,6 +32,30 @@ A tool definition needs:
When a tool returns structured data, add an optional `outputSchema`. With Zod or Standard Schema it also types the `execute` return.
+### Label tool activity
+
+Use `label.start(input)` to describe a call in user-facing activity. The callback receives the validated tool input, so it can select the useful fields without exposing the full argument object:
+
+```ts title="agent/tools/deploy.ts"
+export default defineTool({
+ description: "Deploy a project to an environment.",
+ inputSchema: z.object({
+ project: z.string(),
+ environment: z.enum(["preview", "production"]),
+ }),
+ label: {
+ start: ({ project, environment }) => `Deploy ${project} to ${environment}`,
+ },
+ async execute(input) {
+ return deploy(input);
+ },
+});
+```
+
+The label is presentation only. It does not replace the path-derived tool name, enter model input, or change execution. eve records the bounded label on the corresponding public action event so activity renderers and other authorized stream consumers can use it without interpreting raw tool data. Built-in channel activity can show `Deploy storefront to production` instead of `deploy`; if the callback throws or returns an empty label, activity falls back to the tool name.
+
+Provided tools define labels for `bash`, `glob`, `grep`, `load_skill`, `read_file`, `web_fetch`, `web_search`, and `write_file`.
+
### Stream preliminary tool results
For a `defineTool` executor with the default execution mode, an async generator streams complete
diff --git a/packages/eve/extension-contracts/compatibility/channel/v18.ts b/packages/eve/extension-contracts/compatibility/channel/v18.ts
new file mode 100644
index 000000000..9657836a3
--- /dev/null
+++ b/packages/eve/extension-contracts/compatibility/channel/v18.ts
@@ -0,0 +1,10 @@
+import { defineChannel, POST } from "#public/channels/index.js";
+
+export default defineChannel({
+ routes: [
+ POST("/continue/:sessionId", async (_request, { attachSession, params }) => {
+ const result = await attachSession(params.sessionId!).send("Continue.", { auth: null });
+ return Response.json({ accepted: result.status === "accepted" });
+ }),
+ ],
+});
diff --git a/packages/eve/extension-contracts/compatibility/connection/v14.ts b/packages/eve/extension-contracts/compatibility/connection/v14.ts
new file mode 100644
index 000000000..c9adb6c9f
--- /dev/null
+++ b/packages/eve/extension-contracts/compatibility/connection/v14.ts
@@ -0,0 +1,6 @@
+import { defineMcpClientConnection } from "#public/connections/index.js";
+
+export default defineMcpClientConnection({
+ description: "Call-aware MCP service",
+ url: "https://example.com/mcp",
+});
diff --git a/packages/eve/extension-contracts/compatibility/dynamicInstructions/v17.ts b/packages/eve/extension-contracts/compatibility/dynamicInstructions/v17.ts
new file mode 100644
index 000000000..745446593
--- /dev/null
+++ b/packages/eve/extension-contracts/compatibility/dynamicInstructions/v17.ts
@@ -0,0 +1,8 @@
+import { defineDynamic, defineInstructions } from "#public/instructions/index.js";
+
+export default defineDynamic({
+ events: {
+ "session.started": (_event, ctx) =>
+ defineInstructions({ markdown: `Use session ${ctx.session.id} for correlation.` }),
+ },
+});
diff --git a/packages/eve/extension-contracts/compatibility/dynamicSkill/v16.ts b/packages/eve/extension-contracts/compatibility/dynamicSkill/v16.ts
new file mode 100644
index 000000000..bd9ab80cf
--- /dev/null
+++ b/packages/eve/extension-contracts/compatibility/dynamicSkill/v16.ts
@@ -0,0 +1,11 @@
+import { defineDynamic, defineSkill } from "#public/skills/index.js";
+
+export default defineDynamic({
+ events: {
+ "turn.started": (_event, ctx) =>
+ defineSkill({
+ description: `Review session ${ctx.session.id}.`,
+ markdown: "# Review\n\nCheck each claim.",
+ }),
+ },
+});
diff --git a/packages/eve/extension-contracts/compatibility/dynamicTool/v29.ts b/packages/eve/extension-contracts/compatibility/dynamicTool/v29.ts
new file mode 100644
index 000000000..84cdfafc3
--- /dev/null
+++ b/packages/eve/extension-contracts/compatibility/dynamicTool/v29.ts
@@ -0,0 +1,18 @@
+import { z } from "zod";
+
+import { defineDynamic, defineTool } from "#public/tools/index.js";
+
+export default defineDynamic({
+ events: {
+ "session.started": () =>
+ defineTool({
+ description: "Delegate a background report.",
+ execution: "background",
+ inputSchema: z.object({ reportId: z.string() }),
+ async *execute({ reportId }) {
+ yield { reportId };
+ return { reportId };
+ },
+ }),
+ },
+});
diff --git a/packages/eve/extension-contracts/compatibility/hook/v21.ts b/packages/eve/extension-contracts/compatibility/hook/v21.ts
new file mode 100644
index 000000000..0c142b202
--- /dev/null
+++ b/packages/eve/extension-contracts/compatibility/hook/v21.ts
@@ -0,0 +1,9 @@
+import { defineHook } from "#public/hooks/index.js";
+
+export default defineHook({
+ events: {
+ "turn.started"(event, ctx) {
+ console.info(event.meta.id, event.data.turnId, ctx.session.id);
+ },
+ },
+});
diff --git a/packages/eve/extension-contracts/compatibility/schedule/v10.ts b/packages/eve/extension-contracts/compatibility/schedule/v10.ts
new file mode 100644
index 000000000..639fc8dd7
--- /dev/null
+++ b/packages/eve/extension-contracts/compatibility/schedule/v10.ts
@@ -0,0 +1,8 @@
+import { defineSchedule } from "#public/schedules/index.js";
+
+export default defineSchedule({
+ cron: "0 9 * * *",
+ run({ waitUntil, appAuth }) {
+ waitUntil(Promise.resolve(appAuth.principalId));
+ },
+});
diff --git a/packages/eve/extension-contracts/compatibility/subagent/v9.ts b/packages/eve/extension-contracts/compatibility/subagent/v9.ts
new file mode 100644
index 000000000..344e5db11
--- /dev/null
+++ b/packages/eve/extension-contracts/compatibility/subagent/v9.ts
@@ -0,0 +1,6 @@
+import { defineAgent } from "#public/index.js";
+
+export default defineAgent({
+ description: "Delegate research tasks.",
+ model: "anthropic/claude-sonnet-5",
+});
diff --git a/packages/eve/extension-contracts/compatibility/tool/v30.ts b/packages/eve/extension-contracts/compatibility/tool/v30.ts
new file mode 100644
index 000000000..ba196a3e3
--- /dev/null
+++ b/packages/eve/extension-contracts/compatibility/tool/v30.ts
@@ -0,0 +1,20 @@
+import { z } from "zod";
+import { defineTool, defineWorkflowTool } from "#public/tools/index.js";
+
+export const write = defineTool({
+ description: "Write an approved message.",
+ inputSchema: z.object({ message: z.string() }),
+ outputSchema: z.object({ written: z.string() }),
+ approval: ({ toolInput }) => (toolInput?.message ? "user-approval" : "not-applicable"),
+ execute: (input) => ({ written: input.message }),
+ toModelOutput: (output) => ({ type: "text", value: output.written }),
+});
+
+export const workflow = defineWorkflowTool({
+ description: "Run a report workflow.",
+ inputSchema: z.object({ report: z.string() }),
+ async execute(input) {
+ "use workflow";
+ return { report: input.report };
+ },
+});
diff --git a/packages/eve/extension-contracts/reports/channel/v19.json b/packages/eve/extension-contracts/reports/channel/v19.json
new file mode 100644
index 000000000..1f86ce84a
--- /dev/null
+++ b/packages/eve/extension-contracts/reports/channel/v19.json
@@ -0,0 +1,21 @@
+{
+ "kind": "eve-extension-capability-contract",
+ "capability": "channel",
+ "epoch": 19,
+ "sha256": "3d4831ccdf909bfdbbd445a683ca183ed3e6f60f2415e3acf225dde503fbb9a8",
+ "exports": [
+ "DELETE",
+ "GET",
+ "HEAD",
+ "OPTIONS",
+ "PATCH",
+ "POST",
+ "PUT",
+ "WS",
+ "createWebSocketUpgradeServer",
+ "defineChannel",
+ "disableRoute",
+ "isChannel",
+ "isDisabledRouteSentinel"
+ ]
+}
diff --git a/packages/eve/extension-contracts/reports/connection/v15.json b/packages/eve/extension-contracts/reports/connection/v15.json
new file mode 100644
index 000000000..b849b9774
--- /dev/null
+++ b/packages/eve/extension-contracts/reports/connection/v15.json
@@ -0,0 +1,16 @@
+{
+ "kind": "eve-extension-capability-contract",
+ "capability": "connection",
+ "epoch": 15,
+ "sha256": "7f59cf73b5fa26972d87c2af982091062aca3b14ce58f245715c41318c272267",
+ "exports": [
+ "ConnectionAuthorizationFailedError",
+ "ConnectionAuthorizationRequiredError",
+ "defineDynamic",
+ "defineInteractiveAuthorization",
+ "defineMcpClientConnection",
+ "defineOpenAPIConnection",
+ "isConnectionAuthorizationFailedError",
+ "isConnectionAuthorizationRequiredError"
+ ]
+}
diff --git a/packages/eve/extension-contracts/reports/dynamicInstructions/v18.json b/packages/eve/extension-contracts/reports/dynamicInstructions/v18.json
new file mode 100644
index 000000000..0cb3520c6
--- /dev/null
+++ b/packages/eve/extension-contracts/reports/dynamicInstructions/v18.json
@@ -0,0 +1,7 @@
+{
+ "kind": "eve-extension-capability-contract",
+ "capability": "dynamicInstructions",
+ "epoch": 18,
+ "sha256": "ec99bb09f2b7240390ac0b7c240582d313c58d19be6730eea2695f50ee3f47f1",
+ "exports": ["defineDynamic"]
+}
diff --git a/packages/eve/extension-contracts/reports/dynamicSkill/v17.json b/packages/eve/extension-contracts/reports/dynamicSkill/v17.json
new file mode 100644
index 000000000..41e0c3ced
--- /dev/null
+++ b/packages/eve/extension-contracts/reports/dynamicSkill/v17.json
@@ -0,0 +1,7 @@
+{
+ "kind": "eve-extension-capability-contract",
+ "capability": "dynamicSkill",
+ "epoch": 17,
+ "sha256": "9f26290b764e0a8201d034e42956eecdb66a62a6f5627c5b00a5643302d8db20",
+ "exports": ["defineDynamic"]
+}
diff --git a/packages/eve/extension-contracts/reports/dynamicTool/v30.json b/packages/eve/extension-contracts/reports/dynamicTool/v30.json
new file mode 100644
index 000000000..56cfbad0e
--- /dev/null
+++ b/packages/eve/extension-contracts/reports/dynamicTool/v30.json
@@ -0,0 +1,13 @@
+{
+ "kind": "eve-extension-capability-contract",
+ "capability": "dynamicTool",
+ "epoch": 30,
+ "sha256": "9476710608440e275e8f6b6e33401f5a02814c2d01e79afe31f9b7b1528d2b77",
+ "exports": [
+ "DynamicToolEntry",
+ "DynamicToolEvents",
+ "DynamicToolResult",
+ "DynamicToolSet",
+ "defineDynamic"
+ ]
+}
diff --git a/packages/eve/extension-contracts/reports/hook/v22.json b/packages/eve/extension-contracts/reports/hook/v22.json
new file mode 100644
index 000000000..a3b55dd28
--- /dev/null
+++ b/packages/eve/extension-contracts/reports/hook/v22.json
@@ -0,0 +1,7 @@
+{
+ "kind": "eve-extension-capability-contract",
+ "capability": "hook",
+ "epoch": 22,
+ "sha256": "74f51a7a091be36a8540d90b908eb1f66c95ffdf48c41405151b5a26dbf2e314",
+ "exports": ["defineHook"]
+}
diff --git a/packages/eve/extension-contracts/reports/schedule/v11.json b/packages/eve/extension-contracts/reports/schedule/v11.json
new file mode 100644
index 000000000..3f438c575
--- /dev/null
+++ b/packages/eve/extension-contracts/reports/schedule/v11.json
@@ -0,0 +1,14 @@
+{
+ "kind": "eve-extension-capability-contract",
+ "capability": "schedule",
+ "epoch": 11,
+ "sha256": "b951f0c4b66bd7eb73c710dd5beb5317aa38df05062bd6fee477524dee49324c",
+ "exports": [
+ "ScheduleDefinition",
+ "ScheduleHandlerArgs",
+ "ScheduleRunHandler",
+ "ScheduleToFn",
+ "TypedReceiveTarget",
+ "defineSchedule"
+ ]
+}
diff --git a/packages/eve/extension-contracts/reports/subagent/v10.json b/packages/eve/extension-contracts/reports/subagent/v10.json
new file mode 100644
index 000000000..94a8a480b
--- /dev/null
+++ b/packages/eve/extension-contracts/reports/subagent/v10.json
@@ -0,0 +1,20 @@
+{
+ "kind": "eve-extension-capability-contract",
+ "capability": "subagent",
+ "epoch": 10,
+ "sha256": "d65009aa0fb1d7d5d1b5c84724116228a437d63aeabb042665a1d4d837df01ed",
+ "exports": [
+ "AgentCompactionDefinition",
+ "AgentDefinition",
+ "AgentModelDefinition",
+ "AgentStaticModelDefinition",
+ "DefinedAgent",
+ "DynamicLocalSubagentDefinition",
+ "DynamicSubagentDefinition",
+ "RemoteAgentDefinition",
+ "RemoteAgentDefinitionInput",
+ "defineAgent",
+ "defineDynamic",
+ "defineRemoteAgent"
+ ]
+}
diff --git a/packages/eve/extension-contracts/reports/tool/v31.json b/packages/eve/extension-contracts/reports/tool/v31.json
new file mode 100644
index 000000000..f52b1ae14
--- /dev/null
+++ b/packages/eve/extension-contracts/reports/tool/v31.json
@@ -0,0 +1,20 @@
+{
+ "kind": "eve-extension-capability-contract",
+ "capability": "tool",
+ "epoch": 31,
+ "sha256": "a858928de700d14269e77dc451f5f71262f105efa9b3f0755b9bad8ed67ecfb6",
+ "exports": [
+ "defaultWebSearch",
+ "defineTool",
+ "defineWorkflowTool",
+ "disableTool",
+ "experimental_workflow",
+ "isDisabledToolSentinel",
+ "isExperimentalWorkflowToolDefinition",
+ "isWebSearchToolDefinition",
+ "toolOutput",
+ "toolOutputPart",
+ "toolResultFrom",
+ "webSearch"
+ ]
+}
diff --git a/packages/eve/src/compiler/compile-from-memory.ts b/packages/eve/src/compiler/compile-from-memory.ts
index 6f617cbd2..574634389 100644
--- a/packages/eve/src/compiler/compile-from-memory.ts
+++ b/packages/eve/src/compiler/compile-from-memory.ts
@@ -43,6 +43,7 @@ export interface CompileFromMemoryToolInput {
readonly inputSchema?: JsonObject | null;
readonly outputSchema?: JsonObject;
readonly execute?: ToolDefinition["execute"];
+ readonly label?: ToolDefinition["label"];
readonly approval?: ToolDefinition["approval"];
readonly toModelOutput?: ToolDefinition["toModelOutput"];
}
@@ -117,6 +118,7 @@ export async function compileFromMemory(
function createMemoryToolDefinition(input: CompileFromMemoryToolInput): ToolDefinition {
return defineTool({
+ label: input.label,
approval: input.approval,
description: input.description ?? `${input.name} test tool.`,
execute:
diff --git a/packages/eve/src/compiler/extension-compatibility.ts b/packages/eve/src/compiler/extension-compatibility.ts
index 3d73e1c0c..b708b2cdb 100644
--- a/packages/eve/src/compiler/extension-compatibility.ts
+++ b/packages/eve/src/compiler/extension-compatibility.ts
@@ -22,8 +22,8 @@ interface ExtensionCapabilityContract {
const EXTENSION_CAPABILITY_CONTRACTS = {
extension: { current: 1, supported: [1], dropped: {} },
tool: {
- current: 30,
- supported: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 28, 29, 30],
+ current: 31,
+ supported: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 28, 29, 30, 31],
dropped: {
14: "TaskExec.delegated was removed; migrate to workflow-backed background tools",
15: "TaskExec replaces stageEffect with send",
@@ -42,8 +42,10 @@ const EXTENSION_CAPABILITY_CONTRACTS = {
},
},
dynamicTool: {
- current: 29,
- supported: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 28, 29],
+ current: 30,
+ supported: [
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 28, 29, 30,
+ ],
dropped: {
21: "Message and reasoning append events now expose deltas instead of cumulative snapshots.",
23: "TaskExec.delegated was removed; migrate to workflow-backed background tools",
@@ -54,22 +56,22 @@ const EXTENSION_CAPABILITY_CONTRACTS = {
},
},
channel: {
- current: 18,
- supported: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18],
+ current: 19,
+ supported: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19],
dropped: {
12: "Message and reasoning append events now expose deltas instead of cumulative snapshots.",
},
},
schedule: {
- current: 10,
- supported: [1, 2, 3, 4, 6, 7, 8, 9, 10],
+ current: 11,
+ supported: [1, 2, 3, 4, 6, 7, 8, 9, 10, 11],
dropped: {
5: "Message and reasoning append events now expose deltas instead of cumulative snapshots.",
},
},
subagent: {
- current: 9,
- supported: [3, 4, 6, 7, 8, 9],
+ current: 10,
+ supported: [3, 4, 6, 7, 8, 9, 10],
dropped: {
1: "Persistent subagent sessions are now the default and the experimental opt-in was removed",
2: "Persistent subagent sessions are now the default and the experimental opt-in was removed",
@@ -77,16 +79,16 @@ const EXTENSION_CAPABILITY_CONTRACTS = {
},
},
connection: {
- current: 14,
- supported: [1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 13, 14],
+ current: 15,
+ supported: [1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 13, 14, 15],
dropped: {
9: "Dynamic connection resolvers no longer receive conversation or channel continuation data",
10: "Message and reasoning append events now expose deltas instead of cumulative snapshots.",
},
},
hook: {
- current: 21,
- supported: [10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21],
+ current: 22,
+ supported: [10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22],
dropped: {
1: "Model identity moved from session.started runtime metadata to step.started call attribution.",
2: "Model identity moved from session.started runtime metadata to step.started call attribution.",
@@ -102,16 +104,16 @@ const EXTENSION_CAPABILITY_CONTRACTS = {
},
skill: { current: 1, supported: [1], dropped: {} },
dynamicSkill: {
- current: 16,
- supported: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16],
+ current: 17,
+ supported: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17],
dropped: {
13: "Message and reasoning append events now expose deltas instead of cumulative snapshots.",
},
},
instructions: { current: 2, supported: [1, 2], dropped: {} },
dynamicInstructions: {
- current: 17,
- supported: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17],
+ current: 18,
+ supported: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18],
dropped: {
14: "Message and reasoning append events now expose deltas instead of cumulative snapshots.",
},
diff --git a/packages/eve/src/context/build-dynamic-tools.ts b/packages/eve/src/context/build-dynamic-tools.ts
index 5fdc8c6de..db5305c29 100644
--- a/packages/eve/src/context/build-dynamic-tools.ts
+++ b/packages/eve/src/context/build-dynamic-tools.ts
@@ -24,6 +24,7 @@ import {
callDurableDynamicCallback,
lookupDurableDynamicCallback,
type DurableDynamicCallbackPhase,
+ type DurableDynamicCallbackReference,
type DynamicToolCallbackOwner,
} from "#tools/durable-callbacks.js";
import { toInputSchema, toOutputSchema } from "#tools/schema.js";
@@ -104,13 +105,17 @@ export function replayDynamicTools(
: lookupDurableDynamicCallback(owner, "approvalKey");
const executeReference = entry.callbacks.execute;
const execute = lookupDurableDynamicCallback(owner, "execute");
- const toModelOutputReference = entry.callbacks.toModelOutput;
- const toModelOutput =
- toModelOutputReference === undefined
- ? undefined
- : lookupDurableDynamicCallback(owner, "toModelOutput");
+ const labelStart = bindDynamicCallback(entry, owner, "labelStart", entry.callbacks.label?.start);
+ const toModelOutput = bindDynamicCallback(
+ entry,
+ owner,
+ "toModelOutput",
+ entry.callbacks.toModelOutput,
+ );
- return {
+ const replayed: {
+ -readonly [K in keyof HarnessToolDefinition]: HarnessToolDefinition[K];
+ } = {
description: entry.description,
execute:
entry.execution === "background"
@@ -169,24 +174,29 @@ export function replayDynamicTools(
},
}),
outputSchema: toOutputSchema(entry.outputSchema),
- ...(toModelOutputReference === undefined
- ? {}
- : {
- toModelOutput: (output: unknown) => {
- if (toModelOutput === undefined) {
- throw missingCallbackError(entry, "toModelOutput");
- }
- return callDurableDynamicCallback(
- toModelOutput!,
- toModelOutputReference.closure,
- output,
- );
- },
- }),
};
+ if (labelStart !== undefined) {
+ replayed.label = { start: (input: unknown) => labelStart(input) as string };
+ }
+ if (toModelOutput !== undefined) replayed.toModelOutput = toModelOutput;
+ return replayed;
});
}
+function bindDynamicCallback(
+ entry: CurrentDynamicToolMetadata,
+ owner: DynamicToolCallbackOwner,
+ phase: DurableDynamicCallbackPhase,
+ reference: DurableDynamicCallbackReference | undefined,
+): ((...args: unknown[]) => unknown) | undefined {
+ if (reference === undefined) return undefined;
+ const callback = lookupDurableDynamicCallback(owner, phase);
+ return (...args) => {
+ if (callback === undefined) throw missingCallbackError(entry, phase);
+ return callDurableDynamicCallback(callback, reference.closure, ...args);
+ };
+}
+
function requireCurrentDynamicToolMetadata(
metadata: readonly PersistedDynamicToolMetadata[],
): readonly CurrentDynamicToolMetadata[] {
diff --git a/packages/eve/src/context/dynamic-tool-lifecycle.test.ts b/packages/eve/src/context/dynamic-tool-lifecycle.test.ts
index c39360a6b..20c4b6d4f 100644
--- a/packages/eve/src/context/dynamic-tool-lifecycle.test.ts
+++ b/packages/eve/src/context/dynamic-tool-lifecycle.test.ts
@@ -1536,6 +1536,41 @@ describe("programmatic dynamic tools (no bundler transform)", () => {
expect(approvalFn).toHaveBeenCalledExactlyOnceWith(approvalCtx);
});
+ it("replays a label start callback", () => {
+ const ctx = createCtx();
+ const owner = {
+ sessionId: ctx.require(SessionIdKey),
+ scope: "turn" as const,
+ resolverSlug: "legacy",
+ entryKey: "legacy:deploy",
+ };
+ registerTestCallback("deploy", "execute", () => ({ ok: true }), owner);
+ registerTestCallback(
+ "deploy",
+ "labelStart",
+ (_closure, input) => `Deploy to ${String((input as { environment: unknown }).environment)}`,
+ owner,
+ );
+ ctx.set(TurnDynamicToolMetadataKey, [
+ {
+ callbacks: {
+ label: { start: { closure: {} } },
+ execute: { closure: {} },
+ },
+ description: "Deploy.",
+ entryKey: "legacy:deploy",
+ inputSchema: { type: "object" },
+ name: "deploy",
+ resolverSlug: "legacy",
+ },
+ ]);
+
+ expect(buildDynamicTools(ctx)[0]?.label?.start?.({ environment: "preview" })).toBe(
+ "Deploy to preview",
+ );
+ clearDurableDynamicCallbacks(owner.sessionId);
+ });
+
it("replays phase-specific turn metadata", async () => {
const ctx = createCtx();
const approval = vi.fn(() => "user-approval" as const);
diff --git a/packages/eve/src/context/dynamic-tool-lifecycle.ts b/packages/eve/src/context/dynamic-tool-lifecycle.ts
index b6f12d16d..8afb9a7c9 100644
--- a/packages/eve/src/context/dynamic-tool-lifecycle.ts
+++ b/packages/eve/src/context/dynamic-tool-lifecycle.ts
@@ -187,6 +187,7 @@ export function validateDurableDynamicToolCallbacks(
const unknownPhases = Object.keys(raw).filter(
(key) =>
key !== "execute" &&
+ key !== "label" &&
key !== "approvalKey" &&
key !== "approvalRequest" &&
key !== "approvalResponse" &&
@@ -198,6 +199,7 @@ export function validateDurableDynamicToolCallbacks(
);
}
+ const hasLabelStart = entry.label?.start !== undefined;
const hasApproval = entry.approval !== undefined;
const hasApprovalResponse =
entry.approval !== undefined &&
@@ -210,6 +212,13 @@ export function validateDurableDynamicToolCallbacks(
stamped: raw.execute,
required: true,
})!;
+ const labelStart = validateReference({
+ name,
+ owner,
+ phase: "labelStart",
+ stamped: raw.label?.start,
+ required: hasLabelStart,
+ });
const approvalKey = validateReference({
name,
owner,
@@ -241,11 +250,13 @@ export function validateDurableDynamicToolCallbacks(
const callbacks: {
execute: DurableDynamicCallbackReference;
+ label?: { start?: DurableDynamicCallbackReference };
approvalKey?: DurableDynamicCallbackReference;
approvalRequest?: DurableDynamicCallbackReference;
approvalResponse?: DurableDynamicCallbackReference;
toModelOutput?: DurableDynamicCallbackReference;
} = { execute };
+ if (labelStart !== undefined) callbacks.label = { start: labelStart };
if (approvalKey !== undefined) callbacks.approvalKey = approvalKey;
if (approvalRequest !== undefined) callbacks.approvalRequest = approvalRequest;
if (approvalResponse !== undefined) callbacks.approvalResponse = approvalResponse;
diff --git a/packages/eve/src/execution/activity-events.test.ts b/packages/eve/src/execution/activity-events.test.ts
index 33405bdad..310fd18e8 100644
--- a/packages/eve/src/execution/activity-events.test.ts
+++ b/packages/eve/src/execution/activity-events.test.ts
@@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";
import { projectActivityEvents } from "#execution/activity-events.js";
import { deriveChildActivityWorkId } from "#execution/activity-work-id.js";
-import { MAX_ACTIVITY_TEXT_LENGTH } from "#execution/activity-text.js";
+import { MAX_ACTIVITY_TEXT_LENGTH } from "#shared/presentation-text.js";
const lineage = {
id: "work:root:turn",
@@ -27,6 +27,7 @@ describe("projectActivityEvents", () => {
},
{ callId: "skill-1", input: { skill: "private" }, kind: "load-skill" },
],
+ presentation: { "tool-1": { label: "Search issues" } },
sequence: 0,
stepIndex: 0,
turnId: "turn",
@@ -45,6 +46,11 @@ describe("projectActivityEvents", () => {
}),
kind: "action.started",
}),
+ expect.objectContaining({
+ actionId: "action:work:root:turn:tool-1",
+ kind: "action.label.updated",
+ label: "Search issues",
+ }),
expect.objectContaining({
action: expect.objectContaining({
id: "action:work:root:turn:skill-1",
diff --git a/packages/eve/src/execution/activity-events.ts b/packages/eve/src/execution/activity-events.ts
index 78be56c8d..9415c1b55 100644
--- a/packages/eve/src/execution/activity-events.ts
+++ b/packages/eve/src/execution/activity-events.ts
@@ -1,4 +1,4 @@
-import { normalizeActivityText } from "#execution/activity-text.js";
+import { normalizePresentationText } from "#shared/presentation-text.js";
import { deriveChildActivityWorkId } from "#execution/activity-work-id.js";
import type { ActivityEventV1, ActivityWorkIdentityV1 } from "#protocol/activity.js";
import type { UnstampedMessageStreamEvent } from "#protocol/message.js";
@@ -14,8 +14,9 @@ export function projectActivityEvents(input: {
if (action.kind === "subagent-call" || action.kind === "remote-agent-call") return [];
const kind = action.kind === "load-skill" ? ("skill" as const) : ("tool" as const);
const rawName = action.kind === "load-skill" ? "load_skill" : action.toolName;
- const name = normalizeActivityText(rawName) || (kind === "skill" ? "Skill" : "Tool");
+ const name = normalizePresentationText(rawName) || (kind === "skill" ? "Skill" : "Tool");
const id = actionId(lineage.id, action.callId);
+ const label = activityLabel(event.data.presentation?.[action.callId]?.label);
return [
{
action: {
@@ -30,6 +31,16 @@ export function projectActivityEvents(input: {
kind: "action.started" as const,
startedAt: input.at,
},
+ ...(label === undefined
+ ? []
+ : [
+ {
+ actionId: id,
+ eventId: `${id}:label`,
+ kind: "action.label.updated" as const,
+ label,
+ },
+ ]),
];
});
}
@@ -210,8 +221,9 @@ export function projectActivityEvents(input: {
return [];
}
-function activityLabel(value: string): string | undefined {
- const normalized = normalizeActivityText(value);
+function activityLabel(value: string | undefined): string | undefined {
+ if (value === undefined) return undefined;
+ const normalized = normalizePresentationText(value);
return normalized === "" ? undefined : normalized;
}
diff --git a/packages/eve/src/execution/node-step.test.ts b/packages/eve/src/execution/node-step.test.ts
index 71110730e..d51996c31 100644
--- a/packages/eve/src/execution/node-step.test.ts
+++ b/packages/eve/src/execution/node-step.test.ts
@@ -163,6 +163,9 @@ function createTestNode(
async function createNodeWithSourceOwnedTools(input: {
readonly names: readonly string[];
+ readonly owner?:
+ | { readonly kind: "application" }
+ | { readonly feature: string; readonly kind: "framework" };
readonly turnTools?: StaticRuntimeTurnAgent["tools"];
}): Promise<ResolvedRuntimeAgentNode> {
const toolRegistry = await createRuntimeToolRegistry({
@@ -173,7 +176,7 @@ async function createNodeWithSourceOwnedTools(input: {
inputSchema: name === AGENT_TOOL_NAME ? SUBAGENT_TOOL_INPUT_SCHEMA : null,
logicalPath: `tools/${name}.ts`,
name,
- owner: { feature: "test", kind: "framework" },
+ owner: input.owner ?? { feature: "test", kind: "framework" },
sourceId: `framework:tools/${name}.ts`,
sourceKind: "module",
})),
@@ -214,6 +217,22 @@ function createNoopRuntime(): Runtime {
}
describe("createNodeHarnessTools", () => {
+ it("adds the framework label start callback to provider-managed web search", async () => {
+ const node = await createNodeWithSourceOwnedTools({ names: ["web_search"] });
+ const label = createNodeHarnessTools({ node }).get("web_search")?.label?.start;
+
+ expect(label?.({ query: "Slack plan blocks" })).toBe("Search Slack plan blocks");
+ });
+
+ it("does not add the framework label to an authored web_search override", async () => {
+ const node = await createNodeWithSourceOwnedTools({
+ names: ["web_search"],
+ owner: { kind: "application" },
+ });
+
+ expect(createNodeHarnessTools({ node }).get("web_search")?.label?.start).toBeUndefined();
+ });
+
it("keeps the compiled framework question tool client-side", async () => {
const node = await createNodeWithSourceOwnedTools({ names: ["ask_question"] });
diff --git a/packages/eve/src/execution/node-step.ts b/packages/eve/src/execution/node-step.ts
index 3b4a62703..766e8cabc 100644
--- a/packages/eve/src/execution/node-step.ts
+++ b/packages/eve/src/execution/node-step.ts
@@ -31,6 +31,10 @@ import {
createPreparedWorkflowToolHarnessDefinition,
createWorkflowToolHarnessDefinition,
} from "#execution/tools/workflow/background.js";
+import {
+ resolveWebSearchActivityLabel,
+ WEB_SEARCH_TOOL_NAME,
+} from "#harness/provider-tool-schemas.js";
const log = createLogger("execution.node-step");
@@ -274,6 +278,11 @@ function createRegisteredHarnessToolDefinition(input: {
def.owner.kind === "framework" && def.name === ASK_QUESTION_TOOL_NAME;
const definition: HarnessToolDefinition = {
+ label:
+ def.label ??
+ (def.owner.kind === "framework" && def.name === WEB_SEARCH_TOOL_NAME
+ ? { start: resolveWebSearchActivityLabel }
+ : undefined),
approvalKey: def.approvalKey,
behavior: input.behavior,
description: def.description,
diff --git a/packages/eve/src/execution/session-activity-projection.ts b/packages/eve/src/execution/session-activity-projection.ts
index b5f6dc389..7bc0e98d4 100644
--- a/packages/eve/src/execution/session-activity-projection.ts
+++ b/packages/eve/src/execution/session-activity-projection.ts
@@ -52,7 +52,11 @@ export function projectSessionActivity(input: {
});
}
events.push(
- ...projectActivityEvents({ at: input.event.meta.at, event: input.event, lineage: work }),
+ ...projectActivityEvents({
+ at: input.event.meta.at,
+ event: input.event,
+ lineage: work,
+ }),
);
return events;
}
diff --git a/packages/eve/src/execution/session-activity.test.ts b/packages/eve/src/execution/session-activity.test.ts
index c5da7fcab..56f0d3aca 100644
--- a/packages/eve/src/execution/session-activity.test.ts
+++ b/packages/eve/src/execution/session-activity.test.ts
@@ -30,6 +30,38 @@ describe("activity protocol and reducer", () => {
});
});
+ it("applies additive action labels without changing the action start shape", () => {
+ const batch = parseActivityBatchV1({
+ events: [
+ {
+ action: {
+ id: "action",
+ kind: "tool",
+ name: "search",
+ parentWorkId: work.id,
+ rootTurnId: "turn",
+ stepIndex: 0,
+ },
+ eventId: "action:start",
+ kind: "action.started",
+ startedAt: "now",
+ },
+ {
+ actionId: "action",
+ eventId: "action:label",
+ kind: "action.label.updated",
+ label: "Search issues",
+ },
+ ],
+ version: 1,
+ });
+
+ expect(batch).toBeDefined();
+ expect(reduceActivityBatch(createActivitySnapshot(), batch!).actions.action?.label).toBe(
+ "Search issues",
+ );
+ });
+
it("rejects malformed known events", () => {
expect(
parseActivityBatchV1({
diff --git a/packages/eve/src/execution/session-activity.ts b/packages/eve/src/execution/session-activity.ts
index 30a91cd1e..5ce67561e 100644
--- a/packages/eve/src/execution/session-activity.ts
+++ b/packages/eve/src/execution/session-activity.ts
@@ -1,4 +1,4 @@
-import { normalizeActivityText } from "#execution/activity-text.js";
+import { normalizePresentationText } from "#shared/presentation-text.js";
import {
type PendingActivitySettlementV1,
type ActivityActionPhase,
@@ -66,6 +66,8 @@ function reduceEvent(snapshot: ActivitySnapshotV1, event: ActivityEventV1): Acti
return startAction(snapshot, event);
case "action.settled":
return settleAction(snapshot, event);
+ case "action.label.updated":
+ return updateActionLabel(snapshot, event);
case "blocker.started":
return startBlocker(snapshot, event);
case "blocker.settled":
@@ -90,7 +92,7 @@ function startWork(
: "running");
const work: ActivityWorkStateV1 = {
...event.work,
- name: event.work.name === undefined ? undefined : normalizeActivityText(event.work.name),
+ name: event.work.name === undefined ? undefined : normalizePresentationText(event.work.name),
phase: phase as ActivityWorkPhase,
settledAt: pending?.settledAt ?? (phase === "cancelled" ? parent?.settledAt : undefined),
startedAt: event.startedAt,
@@ -137,7 +139,7 @@ function startAction(
...snapshot,
actions: replaceBounded(snapshot.actions, event.action.id, {
...event.action,
- name: normalizeActivityText(event.action.name),
+ name: normalizePresentationText(event.action.name),
phase: phase as ActivityActionPhase,
settledAt: pending?.settledAt ?? (phase === "cancelled" ? parent?.settledAt : undefined),
startedAt: event.startedAt,
@@ -149,6 +151,20 @@ function startAction(
};
}
+function updateActionLabel(
+ snapshot: ActivitySnapshotV1,
+ event: Extract<ActivityEventV1, { readonly kind: "action.label.updated" }>,
+): ActivitySnapshotV1 {
+ const current = snapshot.actions[event.actionId];
+ if (current === undefined) return snapshot;
+ const label = normalizePresentationText(event.label);
+ if (current.label === label) return snapshot;
+ return {
+ ...snapshot,
+ actions: replaceBounded(snapshot.actions, event.actionId, { ...current, label }),
+ };
+}
+
function settleAction(
snapshot: ActivitySnapshotV1,
event: Extract<ActivityEventV1, { readonly kind: "action.settled" }>,
@@ -181,7 +197,9 @@ function startBlocker(
blockers: replaceBounded(snapshot.blockers, event.blocker.id, {
...event.blocker,
label:
- event.blocker.label === undefined ? undefined : normalizeActivityText(event.blocker.label),
+ event.blocker.label === undefined
+ ? undefined
+ : normalizePresentationText(event.blocker.label),
phase: phase as ActivityBlockerPhase,
settledAt: pending?.settledAt ?? (phase === "cancelled" ? parent?.settledAt : undefined),
startedAt: event.startedAt,
diff --git a/packages/eve/src/execution/workflow-steps.ts b/packages/eve/src/execution/workflow-steps.ts
index 57a1fe0ce..865d0c57f 100644
--- a/packages/eve/src/execution/workflow-steps.ts
+++ b/packages/eve/src/execution/workflow-steps.ts
@@ -54,7 +54,7 @@ import { activeTurnId } from "#harness/active-turn-id.js";
import { coalesceTurnInputs } from "#harness/messages.js";
import { getWorkflowTaskCallIds, isWorkflowTaskInterrupt } from "#harness/workflow-task-state.js";
import { getPendingWorkflowInterrupt } from "#harness/workflow-interrupt-state.js";
-import type { HarnessSession, StepInput, StepResult } from "#harness/types.js";
+import type { HandleEventFn, HarnessSession, StepInput, StepResult } from "#harness/types.js";
import { getTurnUsageState, takeSessionUsageDelta, toUsage } from "#harness/turn-tag-state.js";
import type { DurableStepResult } from "#execution/next-driver-action.js";
import { derivePendingState } from "#execution/pending-turn-state.js";
@@ -390,11 +390,7 @@ export async function turnStep(rawInput: TurnStepInput): Promise<DurableStepResu
await writer.write(encodeMessageStreamEvent(stamped));
return stamped;
};
-
- const handleEvent = async (
- event: UnstampedMessageStreamEvent,
- messages?: readonly import("ai").ModelMessage[],
- ): Promise<void> => {
+ const handleEvent: HandleEventFn = async (event, messages): Promise<void> => {
// A remote task's parent owns its HITL. Forward blocking events over
// the task callback and keep them out of the child's local channel;
// otherwise two TUIs can present and answer the same request.
diff --git a/packages/eve/src/harness/action-presentation.ts b/packages/eve/src/harness/action-presentation.ts
new file mode 100644
index 000000000..7d5d9aae5
--- /dev/null
+++ b/packages/eve/src/harness/action-presentation.ts
@@ -0,0 +1,39 @@
+import type { ToolSet, TypedToolCall } from "ai";
+
+import type { ActionPresentationByCallId } from "#protocol/message.js";
+import { createRuntimeActionRequestFromToolCall } from "#harness/coordination.js";
+import type { HarnessToolMap } from "#harness/types.js";
+import type { RuntimeActionRequest } from "#shared/action-types.js";
+import { normalizePresentationText } from "#shared/presentation-text.js";
+import { parseJsonObject } from "#shared/json.js";
+
+export interface RuntimeActionRequestProjection {
+ readonly action: RuntimeActionRequest;
+ readonly presentationLabel?: string;
+}
+
+export function createPresentedRuntimeActionRequestFromToolCall(input: {
+ readonly toolCall: TypedToolCall<ToolSet>;
+ readonly tools: HarnessToolMap;
+}): RuntimeActionRequestProjection {
+ const action = createRuntimeActionRequestFromToolCall(input);
+ const start = input.tools.get(input.toolCall.toolName)?.label?.start;
+ if (start === undefined) return { action };
+ try {
+ const label = normalizePresentationText(start(parseJsonObject(action.input)));
+ return label === "" ? { action } : { action, presentationLabel: label };
+ } catch {
+ return { action };
+ }
+}
+
+export function collectActionPresentation(
+ actions: readonly RuntimeActionRequestProjection[],
+): ActionPresentationByCallId | undefined {
+ const presentation = Object.fromEntries(
+ actions.flatMap(({ action, presentationLabel }) =>
+ presentationLabel === undefined ? [] : [[action.callId, { label: presentationLabel }]],
+ ),
+ );
+ return Object.keys(presentation).length === 0 ? undefined : presentation;
+}
diff --git a/packages/eve/src/harness/coordination.test.ts b/packages/eve/src/harness/coordination.test.ts
index e52931d4f..11b9b04e9 100644
--- a/packages/eve/src/harness/coordination.test.ts
+++ b/packages/eve/src/harness/coordination.test.ts
@@ -4,6 +4,7 @@ import {
} from "#subagents/handles/query.js";
import { describe, expect, it } from "vitest";
+import { createPresentedRuntimeActionRequestFromToolCall } from "#harness/action-presentation.js";
import {
createCoordinationRequestFromToolCall,
createRuntimeActionRequestFromToolCall,
@@ -67,6 +68,109 @@ describe("createRuntimeActionRequestFromToolCall", () => {
});
});
+ it("uses the tool-authored label start callback without exposing it in event data", () => {
+ const action = createPresentedRuntimeActionRequestFromToolCall({
+ toolCall: {
+ input: { environment: "production", secret: "hidden" },
+ toolCallId: "call-deploy",
+ toolName: "deploy",
+ type: "tool-call",
+ },
+ tools: new Map([
+ [
+ "deploy",
+ {
+ label: {
+ start: (input) =>
+ `Deploy to ${String((input as { environment: unknown }).environment)}`,
+ },
+ description: "Deploy.",
+ inputSchema: jsonSchema({ type: "object" }),
+ name: "deploy",
+ },
+ ],
+ ]),
+ });
+
+ expect(action).toEqual({
+ action: {
+ callId: "call-deploy",
+ input: { environment: "production", secret: "hidden" },
+ kind: "tool-call",
+ toolName: "deploy",
+ },
+ presentationLabel: "Deploy to production",
+ });
+ });
+
+ it("does not let the label start callback callback mutate the action input", () => {
+ const result = createPresentedRuntimeActionRequestFromToolCall({
+ toolCall: {
+ input: { nested: { value: "original" } },
+ toolCallId: "call-mutate",
+ toolName: "mutate",
+ type: "tool-call",
+ },
+ tools: new Map([
+ [
+ "mutate",
+ {
+ label: {
+ start: (input) => {
+ const mutable = input as { nested: { value: string }; self?: unknown };
+ mutable.nested.value = "changed";
+ mutable.self = mutable;
+ throw new Error("presentation failed");
+ },
+ },
+ description: "Mutate.",
+ inputSchema: jsonSchema({ type: "object" }),
+ name: "mutate",
+ },
+ ],
+ ]),
+ });
+
+ expect(result).toEqual({
+ action: {
+ callId: "call-mutate",
+ input: { nested: { value: "original" } },
+ kind: "tool-call",
+ toolName: "mutate",
+ },
+ });
+ });
+
+ it("ignores an label start callback callback that fails", () => {
+ expect(
+ createPresentedRuntimeActionRequestFromToolCall({
+ toolCall: {
+ input: {},
+ toolCallId: "call-deploy",
+ toolName: "deploy",
+ type: "tool-call",
+ },
+ tools: new Map([
+ [
+ "deploy",
+ {
+ label: {
+ start: () => {
+ throw new Error("presentation failed");
+ },
+ },
+ description: "Deploy.",
+ inputSchema: jsonSchema({ type: "object" }),
+ name: "deploy",
+ },
+ ],
+ ]),
+ }),
+ ).toEqual({
+ action: { callId: "call-deploy", input: {}, kind: "tool-call", toolName: "deploy" },
+ });
+ });
+
it("keeps an authored load_skill override as an ordinary tool action", () => {
expect(
createRuntimeActionRequestFromToolCall({
diff --git a/packages/eve/src/harness/coordination.ts b/packages/eve/src/harness/coordination.ts
index e9c731317..a7dc0c697 100644
--- a/packages/eve/src/harness/coordination.ts
+++ b/packages/eve/src/harness/coordination.ts
@@ -424,27 +424,18 @@ export function createRuntimeActionRequestFromToolCall(input: {
readonly tools: HarnessToolMap;
}): RuntimeActionRequest {
const definition = input.tools.get(input.toolCall.toolName);
-
- if (definition?.frameworkAction === "load-skill") {
- return {
- callId: input.toolCall.toolCallId,
- input: resolveToolCallInputObject(input.toolCall.input, {
- callId: input.toolCall.toolCallId,
- toolName: input.toolCall.toolName,
- }),
- kind: "load-skill",
- };
- }
-
- return {
+ const toolInput = resolveToolCallInputObject(input.toolCall.input, {
callId: input.toolCall.toolCallId,
- input: resolveToolCallInputObject(input.toolCall.input, {
- callId: input.toolCall.toolCallId,
- toolName: input.toolCall.toolName,
- }),
- kind: "tool-call",
toolName: input.toolCall.toolName,
- };
+ });
+ return definition?.frameworkAction === "load-skill"
+ ? { callId: input.toolCall.toolCallId, input: toolInput, kind: "load-skill" }
+ : {
+ callId: input.toolCall.toolCallId,
+ input: toolInput,
+ kind: "tool-call",
+ toolName: input.toolCall.toolName,
+ };
}
/** Projects one deferred harness tool call into task/control coordination. */
diff --git a/packages/eve/src/harness/emission.test.ts b/packages/eve/src/harness/emission.test.ts
index 488e3e734..b78dc06fe 100644
--- a/packages/eve/src/harness/emission.test.ts
+++ b/packages/eve/src/harness/emission.test.ts
@@ -9,6 +9,7 @@ import {
setHarnessEmissionState,
} from "#harness/emission.js";
import type { HarnessToolDefinition } from "#harness/execute-tool.js";
+import { resolveWebSearchActivityLabel } from "#harness/provider-tool-schemas.js";
import {
getTurnClientContextState,
setTurnClientContextState,
@@ -434,6 +435,46 @@ describe("emitStreamContent action requests", () => {
}
});
+ it("emits tool labels for provider-executed calls", async () => {
+ const emitted: Parameters<HarnessEmitFn>[0][] = [];
+ const emit: HarnessEmitFn = async (event) => {
+ emitted.push(event);
+ };
+
+ await emitStreamContent(
+ emit,
+ EMISSION_STATE,
+ streamOf([
+ {
+ input: { action: { queries: ["eve framework"] } },
+ providerExecuted: true,
+ toolCallId: "search-1",
+ toolName: "web_search",
+ type: "tool-call",
+ },
+ { finishReason: "stop", type: "finish-step" },
+ ] as TextStreamPart<ToolSet>[]),
+ {
+ excludedActionToolNames: new Set(),
+ tools: new Map([
+ [
+ "web_search",
+ {
+ label: { start: resolveWebSearchActivityLabel },
+ description: "Search the web.",
+ inputSchema: jsonSchema({ type: "object" }),
+ name: "web_search",
+ },
+ ],
+ ]),
+ },
+ );
+
+ expect(emitted.find((event) => event.type === "actions.requested")?.data.presentation).toEqual({
+ "search-1": { label: "Search eve framework" },
+ });
+ });
+
it("emits a provider action batch before any provider result arrives", async () => {
const events: Parameters<HarnessEmitFn>[0][] = [];
const emit: HarnessEmitFn = async (event) => {
diff --git a/packages/eve/src/harness/emission.ts b/packages/eve/src/harness/emission.ts
index 2cdb30fff..67c787688 100644
--- a/packages/eve/src/harness/emission.ts
+++ b/packages/eve/src/harness/emission.ts
@@ -43,13 +43,17 @@ import {
createRuntimeToolResultFromToolError,
createToolResultMessagePartFromToolError,
} from "#harness/action-result-helpers.js";
-import { createRuntimeActionRequestFromToolCall } from "#harness/coordination.js";
import {
createInvalidToolCallInputError,
isInvalidToolCall,
resolveProviderToolCallRequest,
} from "#harness/tool-call-input-errors.js";
-import type { RuntimeActionRequest, RuntimeToolResultActionResult } from "#shared/action-types.js";
+import type { RuntimeToolResultActionResult } from "#shared/action-types.js";
+import {
+ collectActionPresentation,
+ createPresentedRuntimeActionRequestFromToolCall,
+ type RuntimeActionRequestProjection,
+} from "#harness/action-presentation.js";
import { createProviderStreamActionBatch } from "#harness/stream-actions.js";
import { normalizeModelStreamError } from "#harness/model-call-error.js";
import { createOrderedStreamEmitter } from "#harness/ordered-stream-emitter.js";
@@ -57,6 +61,7 @@ import { interruptStreamOnFailure } from "#harness/interruptible-stream.js";
import { isInlineAuthorizationToolResult } from "#harness/inline-tool-authorization.js";
import type { HarnessEmissionState } from "#harness/emission-state.js";
import type { HarnessEmitFn, HarnessToolMap, StepInput } from "#harness/types.js";
+import { normalizeAssistantStepFinishReason } from "#harness/finish-reason.js";
export {
getHarnessEmissionState,
@@ -237,29 +242,6 @@ export async function emitTurnEpilogue(
};
}
-// ---------------------------------------------------------------------------
-// Shared helpers
-// ---------------------------------------------------------------------------
-
-/**
- * Maps an AI SDK finish reason string to the eve-owned
- * {@link AssistantStepFinishReason} union. Unknown values become `"other"`.
- */
-export function normalizeAssistantStepFinishReason(
- value: string | undefined,
-): AssistantStepFinishReason {
- switch (value) {
- case "content-filter":
- case "error":
- case "length":
- case "stop":
- case "tool-calls":
- return value;
- default:
- return "other";
- }
-}
-
// ---------------------------------------------------------------------------
// Stream content emission
// ---------------------------------------------------------------------------
@@ -387,7 +369,8 @@ async function consumeStreamContent(
}),
);
- const emitActionRequest = async (action: RuntimeActionRequest): Promise<void> => {
+ const emitActionRequest = async (projection: RuntimeActionRequestProjection): Promise<void> => {
+ const { action } = projection;
if (emittedActionCallIds.has(action.callId)) {
return;
}
@@ -400,6 +383,7 @@ async function consumeStreamContent(
await emitFn(
createActionsRequestedEvent({
actions: [action],
+ presentation: collectActionPresentation([projection]),
sequence: state.sequence,
stepIndex: state.stepIndex,
turnId: state.turnId,
@@ -425,7 +409,7 @@ async function consumeStreamContent(
await flushCurrentMessage();
}
- const resolved = resolveProviderToolCallRequest(toolCall);
+ const resolved = resolveProviderToolCallRequest(toolCall, options?.tools ?? new Map());
if (resolved.toolError !== undefined) {
invalidInputToolCallIds.add(toolCall.toolCallId);
await emitActionResult(createRuntimeToolResultFromToolError(resolved.toolError));
@@ -488,7 +472,7 @@ async function consumeStreamContent(
try {
await emitActionRequest(
- createRuntimeActionRequestFromToolCall({
+ createPresentedRuntimeActionRequestFromToolCall({
toolCall,
tools: options.tools,
}),
diff --git a/packages/eve/src/harness/execute-tool.ts b/packages/eve/src/harness/execute-tool.ts
index a7be02829..721cbe51f 100644
--- a/packages/eve/src/harness/execute-tool.ts
+++ b/packages/eve/src/harness/execute-tool.ts
@@ -1,7 +1,7 @@
import type { FlexibleSchema } from "ai";
import type { Approval } from "#approval/definition.js";
-import type { ToolExecuteOptions } from "#tools/definition.js";
+import type { InternalToolLabelDefinition, ToolExecuteOptions } from "#tools/definition.js";
import type { TaskExec } from "#tools/task.js";
import type { JsonValue } from "#shared/json.js";
import type { PreparedToolBehavior } from "#tools/behavior.js";
@@ -20,6 +20,7 @@ export type HarnessRuntimeActionDefinition = { readonly kind: "task-control" };
* Unified harness-owned tool definition.
*/
export interface HarnessToolDefinition {
+ readonly label?: InternalToolLabelDefinition;
readonly approvalKey?: (toolInput: Readonly<Record<string, unknown>>) => string;
readonly behavior?: PreparedToolBehavior;
readonly description: string;
diff --git a/packages/eve/src/harness/finish-reason.ts b/packages/eve/src/harness/finish-reason.ts
new file mode 100644
index 000000000..cccc8b92c
--- /dev/null
+++ b/packages/eve/src/harness/finish-reason.ts
@@ -0,0 +1,17 @@
+import type { AssistantStepFinishReason } from "#protocol/message.js";
+
+/** Maps an AI SDK finish reason to the eve-owned union. */
+export function normalizeAssistantStepFinishReason(
+ value: string | undefined,
+): AssistantStepFinishReason {
+ switch (value) {
+ case "content-filter":
+ case "error":
+ case "length":
+ case "stop":
+ case "tool-calls":
+ return value;
+ default:
+ return "other";
+ }
+}
diff --git a/packages/eve/src/harness/provider-tool-schemas.ts b/packages/eve/src/harness/provider-tool-schemas.ts
index 5df7848a5..b8d671b3e 100644
--- a/packages/eve/src/harness/provider-tool-schemas.ts
+++ b/packages/eve/src/harness/provider-tool-schemas.ts
@@ -1,7 +1,24 @@
import type { JsonObject } from "#shared/json.js";
+import { toolLabel } from "#tools/tool-label.js";
export const WEB_SEARCH_TOOL_NAME = "web_search";
+export function resolveWebSearchActivityLabel(input: unknown): string {
+ if (input === null || typeof input !== "object") return "Search";
+ const record = input as Record<string, unknown>;
+ const action = record.action;
+ const providerAction =
+ action !== null && typeof action === "object" ? (action as Record<string, unknown>) : undefined;
+ const queries = providerAction?.queries;
+ const providerDetail = Array.isArray(queries)
+ ? queries.find((query) => typeof query === "string")
+ : (providerAction?.query ?? providerAction?.url ?? providerAction?.pattern);
+ return toolLabel(
+ "Search",
+ record.query ?? record.objective ?? record.search_query ?? record.searchQuery ?? providerDetail,
+ );
+}
+
/**
* Output schema for OpenAI's provider-managed `webSearch` tool.
*/
diff --git a/packages/eve/src/harness/step-hooks.ts b/packages/eve/src/harness/step-hooks.ts
index e1af89d15..246d4729f 100644
--- a/packages/eve/src/harness/step-hooks.ts
+++ b/packages/eve/src/harness/step-hooks.ts
@@ -22,7 +22,8 @@ import {
createRuntimeToolResultFromStepResult,
} from "#harness/action-result-helpers.js";
import type { HarnessEmissionState } from "#harness/emission.js";
-import { emitStepStarted, normalizeAssistantStepFinishReason } from "#harness/emission.js";
+import { emitStepStarted } from "#harness/emission.js";
+import { normalizeAssistantStepFinishReason } from "#harness/finish-reason.js";
import { extractToolApprovalInputRequests } from "#harness/input-extraction.js";
import {
type AnthropicCacheMarker,
@@ -30,7 +31,11 @@ import {
mergeGatewayAutoCaching,
type PromptCachePath,
} from "#harness/prompt-cache.js";
-import { createRuntimeActionRequestFromToolCall } from "#harness/coordination.js";
+import { mergeProviderSafetyIdentifier } from "#harness/provider-safety.js";
+import {
+ collectActionPresentation,
+ createPresentedRuntimeActionRequestFromToolCall,
+} from "#harness/action-presentation.js";
import { isInvalidToolCall } from "#harness/tool-call-input-errors.js";
import type { RuntimeToolResultActionResult } from "#shared/action-types.js";
import {
@@ -43,7 +48,6 @@ import { contextStorage } from "#context/container.js";
import { isAuthorizationSignal, isPendingAuthorizationToolOutput } from "#harness/authorization.js";
import { readToolInterrupt } from "#harness/tool-interrupts.js";
import { AuthKey } from "#context/keys.js";
-import { mergeProviderSafetyIdentifier } from "#harness/provider-safety.js";
// ---------------------------------------------------------------------------
// Step result type
@@ -270,7 +274,7 @@ export async function emitStepActions(
!options.emittedActionCallIds?.has(toolCall.toolCallId),
)
.map((toolCall) =>
- createRuntimeActionRequestFromToolCall({
+ createPresentedRuntimeActionRequestFromToolCall({
toolCall,
tools: options.tools,
}),
@@ -279,7 +283,8 @@ export async function emitStepActions(
if (actions.length > 0) {
await emitFn(
createActionsRequestedEvent({
- actions,
+ actions: actions.map(({ action }) => action),
+ presentation: collectActionPresentation(actions),
sequence: state.sequence,
stepIndex: state.stepIndex,
turnId: state.turnId,
diff --git a/packages/eve/src/harness/stream-actions.ts b/packages/eve/src/harness/stream-actions.ts
index 1cb76e984..81fa5ce19 100644
--- a/packages/eve/src/harness/stream-actions.ts
+++ b/packages/eve/src/harness/stream-actions.ts
@@ -1,5 +1,8 @@
import { createActionsRequestedEvent } from "#protocol/message.js";
-import type { RuntimeToolCallActionRequest } from "#shared/action-types.js";
+import {
+ collectActionPresentation,
+ type RuntimeActionRequestProjection,
+} from "#harness/action-presentation.js";
import type { HarnessEmitFn } from "#harness/types.js";
interface ActionEventCoordinates {
@@ -11,7 +14,7 @@ interface ActionEventCoordinates {
interface ProviderStreamActionBatch {
cancel(): Promise<void>;
flush(): Promise<void>;
- observe(action: RuntimeToolCallActionRequest): void;
+ observe(action: RuntimeActionRequestProjection): void;
}
/** Batches provider-managed calls that arrive in one streamed model response. */
@@ -19,7 +22,7 @@ export function createProviderStreamActionBatch(input: {
readonly emitFn: HarnessEmitFn;
readonly state: ActionEventCoordinates;
}): ProviderStreamActionBatch {
- const pendingActions = new Map<string, RuntimeToolCallActionRequest>();
+ const pendingActions = new Map<string, RuntimeActionRequestProjection>();
let actionFlush: Promise<void> = Promise.resolve();
let actionFlushError: unknown;
let actionFlushTimer: ReturnType<typeof setTimeout> | undefined;
@@ -33,11 +36,12 @@ export function createProviderStreamActionBatch(input: {
}
if (pendingActions.size === 0) return;
- const actions = [...pendingActions.values()];
+ const projections = [...pendingActions.values()];
pendingActions.clear();
await input.emitFn(
createActionsRequestedEvent({
- actions,
+ actions: projections.map(({ action }) => action),
+ presentation: collectActionPresentation(projections),
sequence: input.state.sequence,
stepIndex: input.state.stepIndex,
turnId: input.state.turnId,
@@ -86,7 +90,7 @@ export function createProviderStreamActionBatch(input: {
},
observe(action) {
if (cancelled) return;
- pendingActions.set(action.callId, action);
+ pendingActions.set(action.action.callId, action);
scheduleFlush();
},
async flush() {
diff --git a/packages/eve/src/harness/tool-call-input-errors.ts b/packages/eve/src/harness/tool-call-input-errors.ts
index f099372c3..58f646056 100644
--- a/packages/eve/src/harness/tool-call-input-errors.ts
+++ b/packages/eve/src/harness/tool-call-input-errors.ts
@@ -1,7 +1,11 @@
import type { ToolSet, TypedToolCall, TypedToolError } from "ai";
-import type { RuntimeToolCallActionRequest } from "#shared/action-types.js";
+import {
+ createPresentedRuntimeActionRequestFromToolCall,
+ type RuntimeActionRequestProjection,
+} from "#harness/action-presentation.js";
import { resolveToolCallInputObject } from "#harness/coordination.js";
+import type { HarnessToolMap } from "#harness/types.js";
/**
* Returns true when the AI SDK marked the tool call `invalid` (typically
@@ -65,24 +69,26 @@ export function createInvalidToolCallInputError(input: {
* Provider-executed calls skip the AI SDK's input validation, so malformed
* JSON argument text reaches the harness only here.
*/
-export function resolveProviderToolCallRequest(toolCall: {
- readonly input?: unknown;
- readonly toolCallId: string;
- readonly toolName: string;
-}):
- | { readonly request: RuntimeToolCallActionRequest; readonly toolError?: undefined }
+export function resolveProviderToolCallRequest(
+ toolCall: {
+ readonly input?: unknown;
+ readonly toolCallId: string;
+ readonly toolName: string;
+ },
+ tools: HarnessToolMap,
+):
+ | { readonly request: RuntimeActionRequestProjection; readonly toolError?: undefined }
| { readonly request?: undefined; readonly toolError: TypedToolError<ToolSet> } {
try {
return {
- request: {
- callId: toolCall.toolCallId,
- input: resolveToolCallInputObject(toolCall.input, {
- callId: toolCall.toolCallId,
- toolName: toolCall.toolName,
- }),
- kind: "tool-call",
- toolName: toolCall.toolName,
- },
+ request: createPresentedRuntimeActionRequestFromToolCall({
+ toolCall: {
+ ...toolCall,
+ providerExecuted: true,
+ type: "tool-call",
+ } as TypedToolCall<ToolSet>,
+ tools,
+ }),
};
} catch (error) {
if (!(error instanceof TypeError)) {
diff --git a/packages/eve/src/harness/workflow-lifecycle.ts b/packages/eve/src/harness/workflow-lifecycle.ts
index 01fba3519..2923c798f 100644
--- a/packages/eve/src/harness/workflow-lifecycle.ts
+++ b/packages/eve/src/harness/workflow-lifecycle.ts
@@ -2,13 +2,12 @@ import type { ToolSet, TypedToolCall } from "ai";
import { createRuntimeToolResultFromValue } from "#harness/action-result-helpers.js";
import type { HarnessEmissionState } from "#harness/emission.js";
-import { createRuntimeActionRequestFromToolCall } from "#harness/coordination.js";
-import type { HarnessToolMap } from "#harness/types.js";
import {
- createActionResultEvent,
- createActionsRequestedEvent,
- type UnstampedMessageStreamEvent,
-} from "#protocol/message.js";
+ collectActionPresentation,
+ createPresentedRuntimeActionRequestFromToolCall,
+} from "#harness/action-presentation.js";
+import type { HarnessEmitFn, HarnessToolMap } from "#harness/types.js";
+import { createActionResultEvent, createActionsRequestedEvent } from "#protocol/message.js";
import type { WorkflowSandboxInterrupt } from "#shared/workflow-sandbox.js";
import {
getWorkflowSandboxInterrupt,
@@ -41,7 +40,7 @@ export function createWorkflowLifecycle(input: {
};
}
-type EmitWorkflowLifecycleEvent = (event: UnstampedMessageStreamEvent) => Promise<void>;
+type EmitWorkflowLifecycleEvent = HarnessEmitFn;
/** Projects newly parked workflow calls onto eve's existing action stream. */
export async function emitWorkflowActionsRequested(input: {
@@ -58,9 +57,14 @@ export async function emitWorkflowActionsRequested(input: {
type: "tool-call",
} as TypedToolCall<ToolSet>;
+ const projection = createPresentedRuntimeActionRequestFromToolCall({
+ toolCall,
+ tools: input.tools,
+ });
await input.emit(
createActionsRequestedEvent({
- actions: [createRuntimeActionRequestFromToolCall({ toolCall, tools: input.tools })],
+ actions: [projection.action],
+ presentation: collectActionPresentation([projection]),
sequence: input.emissionState.sequence,
stepIndex: input.emissionState.stepIndex,
turnId: input.emissionState.turnId,
diff --git a/packages/eve/src/instrumentation/native-events.test.ts b/packages/eve/src/instrumentation/native-events.test.ts
index 2750cf927..d317c83f0 100644
--- a/packages/eve/src/instrumentation/native-events.test.ts
+++ b/packages/eve/src/instrumentation/native-events.test.ts
@@ -134,6 +134,22 @@ describe("createInstrumentationHandleEvent", () => {
]);
});
+ it("forwards the source event to the durable handler", async () => {
+ const source = createSessionStartedEvent();
+ let forwarded: unknown;
+ const handleEvent = createInstrumentationHandleEvent({
+ handleEvent: async (event) => {
+ forwarded = event;
+ },
+ hooks: { capturesContent: false, publish: async () => {} },
+ sessionId: "session-1",
+ })!;
+
+ await handleEvent(source);
+
+ expect(forwarded).toBe(source);
+ });
+
it("does not change execution mode when hooks have no durable handler", () => {
expect(
createInstrumentationHandleEvent({
diff --git a/packages/eve/src/internal/authored-definition/schema-backed.test.ts b/packages/eve/src/internal/authored-definition/schema-backed.test.ts
index 26b60f422..a32c17856 100644
--- a/packages/eve/src/internal/authored-definition/schema-backed.test.ts
+++ b/packages/eve/src/internal/authored-definition/schema-backed.test.ts
@@ -134,6 +134,39 @@ describe("normalizeToolDefinition", () => {
expect(() => normalizeToolDefinition(null, FAILURE_MESSAGE)).toThrow(FAILURE_MESSAGE);
});
+ it("accepts and types authored tool labels", () => {
+ const tool = defineTool({
+ label: {
+ start(input) {
+ const city: string = input.city;
+ // @ts-expect-error label start callback input is schema-typed.
+ const missing = input.missing;
+ void missing;
+ return `Fetch ${city}`;
+ },
+ },
+ description: "Fetch weather.",
+ inputSchema: z.object({ city: z.string() }),
+ execute: ({ city }) => city,
+ });
+
+ expect(normalizeToolDefinition(tool, FAILURE_MESSAGE).kind).toBe("tool");
+ });
+
+ it("rejects malformed label definitions", () => {
+ expect(() =>
+ normalizeToolDefinition(
+ {
+ label: { start: "Fetch weather" },
+ description: "Fetch weather.",
+ execute: () => null,
+ inputSchema: { type: "object" },
+ },
+ FAILURE_MESSAGE,
+ ),
+ ).toThrow(FAILURE_MESSAGE);
+ });
+
it("accepts authored tools that declare a `toModelOutput` function", () => {
const tool = defineTool({
description: "Echo.",
diff --git a/packages/eve/src/internal/authored-definition/schema-backed.ts b/packages/eve/src/internal/authored-definition/schema-backed.ts
index 225cbc132..4b125125f 100644
--- a/packages/eve/src/internal/authored-definition/schema-backed.ts
+++ b/packages/eve/src/internal/authored-definition/schema-backed.ts
@@ -118,6 +118,7 @@ export function normalizeToolDefinition(value: unknown, message: string): Normal
expectOnlyKnownKeys(
record,
[
+ "label",
"auth",
"description",
"execute",
@@ -177,6 +178,12 @@ export function normalizeToolDefinition(value: unknown, message: string): Normal
* references are captured later by `resolve-agent.ts` when it materializes
* the module export and attaches them to the ResolvedToolDefinition.
*/
+ if (record.label !== undefined) {
+ const label = expectObjectRecord(record.label, message);
+ expectOnlyKnownKeys(label, ["start"], message);
+ expectFunction(label.start, message);
+ }
+
if (record.approval !== undefined) {
normalizeApproval(record.approval, message);
}
diff --git a/packages/eve/src/internal/testing/app-harness.ts b/packages/eve/src/internal/testing/app-harness.ts
index 1e0b0495a..c39a4ea74 100644
--- a/packages/eve/src/internal/testing/app-harness.ts
+++ b/packages/eve/src/internal/testing/app-harness.ts
@@ -185,6 +185,7 @@ export async function createTestRuntime(descriptor: TestAppDescriptor = {}): Pro
Object.assign(compileInput, {
tools: descriptor.tools.map((tool) => ({
name: tool.name,
+ label: tool.label?.start === undefined ? undefined : { start: tool.label.start },
description: tool.description,
execute: tool.execute,
inputSchema: serializeInputSchema(tool.inputSchema),
diff --git a/packages/eve/src/internal/testing/mocks/mock-tool.ts b/packages/eve/src/internal/testing/mocks/mock-tool.ts
index 993c600ce..f271b37f8 100644
--- a/packages/eve/src/internal/testing/mocks/mock-tool.ts
+++ b/packages/eve/src/internal/testing/mocks/mock-tool.ts
@@ -13,6 +13,8 @@ import { toInputSchema } from "#tools/schema.js";
* and an `execute` function. Everything else is overrideable.
*/
export interface MockToolInput {
+ /** Presentation callbacks derived from tool lifecycle values. */
+ readonly label?: ResolvedToolDefinition["label"];
/** Tool name exposed to the model. */
readonly name: string;
/** Human-readable description surfaced in the prompt. */
@@ -48,6 +50,7 @@ export interface MockToolInput {
export function mockTool(input: MockToolInput): ResolvedToolDefinition {
const logicalPath = input.logicalPath ?? `tools/${sanitizeLogicalPathSegment(input.name)}.ts`;
const definition: ResolvedToolDefinition = {
+ label: input.label,
description: input.description ?? `${input.name} mock tool.`,
inputSchema: toInputSchema(input.inputSchema ?? null),
logicalPath,
diff --git a/packages/eve/src/internal/workflow-bundle/dynamic-tool-transform.test.ts b/packages/eve/src/internal/workflow-bundle/dynamic-tool-transform.test.ts
index 616327fd1..222b9867f 100644
--- a/packages/eve/src/internal/workflow-bundle/dynamic-tool-transform.test.ts
+++ b/packages/eve/src/internal/workflow-bundle/dynamic-tool-transform.test.ts
@@ -52,6 +52,7 @@ async function transformAndEval(
stampDurableDynamicToolCallbacks(
entry,
collectDurableDynamicToolCallbacks({
+ label: entry.label as { start?: never } | undefined,
approval: entry.approval as never,
approvalKey: entry.approvalKey as never,
execute: entry.execute as never,
@@ -77,7 +78,10 @@ async function transformAndEval(
};
}
-type StampedCallbacks = Record<string, { callback: Function; closure: Record<string, unknown> }>;
+type StampedCallback = { callback: Function; closure: Record<string, unknown> };
+type StampedCallbacks = Record<string, StampedCallback> & {
+ label?: { start?: StampedCallback };
+};
function durableCallbacks(tool: unknown): StampedCallbacks {
return (tool as Record<symbol, StampedCallbacks>)[
@@ -104,6 +108,7 @@ import { defineDynamic, defineTool } from "eve/tools";
export default defineDynamic({
events: {
"session.started": async () => {
+ const labelPrefix = "Deploy";
const executePrefix = "execute";
const requestReason = "confirm";
const allowedResponder = "user-123";
@@ -112,6 +117,11 @@ export default defineDynamic({
guarded: defineTool({
description: "Guarded",
inputSchema: { type: "object" },
+ label: {
+ start(input) {
+ return labelPrefix + " " + input.value;
+ },
+ },
approval: {
request(ctx) {
return ctx.toolInput.force ? { type: "user-approval", reason: requestReason } : "not-applicable";
@@ -142,18 +152,25 @@ export default defineDynamic({
expect(Object.keys(callbacks)).toEqual([
"execute",
+ "label",
"approvalRequest",
"approvalResponse",
"toModelOutput",
]);
expect(callbacks.execute!.closure).toEqual({ executePrefix: "execute" });
+ expect(callbacks.label?.start?.closure).toEqual({ labelPrefix: "Deploy" });
expect(callbacks.approvalRequest!.closure).toEqual({ requestReason: "confirm" });
expect(callbacks.approvalResponse!.closure).toEqual({ allowedResponder: "user-123" });
expect(callbacks.toModelOutput!.closure).toEqual({ projectionPrefix: "visible" });
- expect(new Set(Object.values(callbacks).map((callback) => callback!.callback)).size).toBe(4);
- for (const callback of Object.values(callbacks)) {
- expect(callback!.callback).toBeTypeOf("function");
- }
+ const callbackValues = [
+ callbacks.execute,
+ callbacks.label?.start,
+ callbacks.approvalRequest,
+ callbacks.approvalResponse,
+ callbacks.toModelOutput,
+ ];
+ expect(new Set(callbackValues.map((callback) => callback!.callback)).size).toBe(5);
+ for (const callback of callbackValues) expect(callback!.callback).toBeTypeOf("function");
});
it("preserves top-level function-form approval properties", async () => {
diff --git a/packages/eve/src/internal/workflow-bundle/dynamic-tool-transform.ts b/packages/eve/src/internal/workflow-bundle/dynamic-tool-transform.ts
index 077f3038a..998e1b873 100644
--- a/packages/eve/src/internal/workflow-bundle/dynamic-tool-transform.ts
+++ b/packages/eve/src/internal/workflow-bundle/dynamic-tool-transform.ts
@@ -14,6 +14,7 @@ import {
} from "#internal/workflow-bundle/dynamic-tool-ast-references.js";
type CallbackPhase =
+ | "labelStart"
| "approvalKey"
| "approvalRequest"
| "approvalResponse"
@@ -21,8 +22,10 @@ type CallbackPhase =
| "toModelOutput";
type CallbackPropertyName =
| "approvalKey"
+ | "label"
| "approval"
| "execute"
+ | "start"
| "request"
| "response"
| "toModelOutput";
@@ -182,6 +185,18 @@ function collectToolCallbacks(
if (!isWorkflowExecute(execute, context)) {
collectCallbackProperty(source, execute, "execute", "execute", results, nestedScopes);
}
+ const label = findProperty(tool, "label");
+ const labelValue = label?.value as AstNode | undefined;
+ if (labelValue?.type === "ObjectExpression") {
+ collectCallbackProperty(
+ source,
+ findProperty(labelValue, "start"),
+ "labelStart",
+ "start",
+ results,
+ nestedScopes,
+ );
+ }
collectCallbackProperty(
source,
findProperty(tool, "toModelOutput"),
diff --git a/packages/eve/src/protocol/activity.ts b/packages/eve/src/protocol/activity.ts
index 69f8ef654..5ae105dc4 100644
--- a/packages/eve/src/protocol/activity.ts
+++ b/packages/eve/src/protocol/activity.ts
@@ -42,6 +42,7 @@ export interface ActivityActionIdentityV1 {
}
export interface ActivityActionStateV1 extends ActivityActionIdentityV1 {
+ readonly label?: string;
readonly phase: ActivityActionPhase;
readonly settledAt?: string;
readonly startedAt: string;
@@ -89,6 +90,12 @@ export type ActivityEventV1 =
readonly outcome: Exclude<ActivityActionPhase, "running">;
readonly settledAt: string;
}
+ | {
+ readonly actionId: string;
+ readonly eventId: string;
+ readonly kind: "action.label.updated";
+ readonly label: string;
+ }
| {
readonly blocker: ActivityBlockerIdentityV1;
readonly eventId: string;
@@ -234,6 +241,21 @@ function parseKnownEvent(value: Record<string, unknown>): ActivityEventV1 | null
settledAt: value.settledAt,
};
}
+ case "action.label.updated": {
+ if (!hasOnlyKeys(value, ["actionId", "eventId", "kind", "label"])) return undefined;
+ if (
+ !isIdentity(value.actionId) ||
+ !isIdentity(value.eventId) ||
+ !isBoundedString(value.label)
+ )
+ return undefined;
+ return {
+ actionId: value.actionId,
+ eventId: value.eventId,
+ kind: "action.label.updated",
+ label: value.label,
+ };
+ }
case "blocker.started": {
if (!hasOnlyKeys(value, ["blocker", "eventId", "kind", "startedAt"])) return undefined;
const blocker = parseBlockerIdentity(value.blocker);
diff --git a/packages/eve/src/protocol/message.ts b/packages/eve/src/protocol/message.ts
index 2de65998f..be8fd1f9f 100644
--- a/packages/eve/src/protocol/message.ts
+++ b/packages/eve/src/protocol/message.ts
@@ -224,9 +224,16 @@ export type MessageReceivedPart =
* action lifecycles by call ID rather than assume one event contains every call
* from an assistant step.
*/
+export interface ActionPresentation {
+ readonly label?: string;
+}
+
+export type ActionPresentationByCallId = Readonly<Record<string, ActionPresentation>>;
+
export interface ActionsRequestedStreamEvent {
data: {
actions: readonly RuntimeActionRequest[];
+ presentation?: ActionPresentationByCallId;
sequence: number;
stepIndex: number;
turnId: string;
@@ -310,6 +317,7 @@ export interface InputResolvedStreamEvent {
export interface ActionResultStreamEvent {
data: {
error?: ActionResultError;
+ presentation?: ActionPresentationByCallId;
result: RuntimeActionResult;
sequence: number;
stepIndex: number;
@@ -325,6 +333,7 @@ export interface ActionResultStreamEvent {
*/
export interface ActionPartialStreamEvent {
data: {
+ presentation?: ActionPresentationByCallId;
result: RuntimeToolResultActionResult;
sequence: number;
stepIndex: number;
@@ -1085,6 +1094,7 @@ function basenameOf(path: string): string {
*/
export function createActionsRequestedEvent(input: {
readonly actions: readonly RuntimeActionRequest[];
+ readonly presentation?: ActionPresentationByCallId;
readonly sequence: number;
readonly stepIndex: number;
readonly turnId: string;
@@ -1092,6 +1102,7 @@ export function createActionsRequestedEvent(input: {
return {
data: {
actions: input.actions,
+ ...optionalPresentation(input.presentation),
sequence: input.sequence,
stepIndex: input.stepIndex,
turnId: input.turnId,
@@ -1100,6 +1111,12 @@ export function createActionsRequestedEvent(input: {
};
}
+function optionalPresentation(presentation: ActionPresentationByCallId | undefined): {
+ readonly presentation?: ActionPresentationByCallId;
+} {
+ return presentation === undefined ? {} : { presentation };
+}
+
/** Creates an `action.input.appended` event for streamed tool input text. */
export function createActionInputAppendedEvent(input: {
readonly callId: string;
@@ -1267,6 +1284,7 @@ export function createInputResolvedEvent(input: {
* derived from the synthesized denial output.
*/
export function createActionResultEvent(input: {
+ readonly presentation?: ActionPresentationByCallId;
readonly rejected?: boolean;
readonly result: RuntimeActionResult;
readonly sequence: number;
@@ -1281,6 +1299,7 @@ export function createActionResultEvent(input: {
return {
data: {
error: outcome.error,
+ ...optionalPresentation(input.presentation),
result: input.result,
sequence: input.sequence,
status: outcome.status,
@@ -1293,6 +1312,7 @@ export function createActionResultEvent(input: {
/** Creates an `action.partial` event for one preliminary tool-result snapshot. */
export function createActionPartialEvent(input: {
+ readonly presentation?: ActionPresentationByCallId;
readonly result: RuntimeToolResultActionResult;
readonly sequence: number;
readonly stepIndex: number;
@@ -1300,6 +1320,7 @@ export function createActionPartialEvent(input: {
}): ActionPartialStreamEvent {
return {
data: {
+ ...optionalPresentation(input.presentation),
result: input.result,
sequence: input.sequence,
stepIndex: input.stepIndex,
diff --git a/packages/eve/src/public/channels/slack/activity-plan.test.ts b/packages/eve/src/public/channels/slack/activity-plan.test.ts
index 6c2888f77..c1d979f58 100644
--- a/packages/eve/src/public/channels/slack/activity-plan.test.ts
+++ b/packages/eve/src/public/channels/slack/activity-plan.test.ts
@@ -66,6 +66,25 @@ describe("Slack activity plan", () => {
{ eventId: "root", kind: "work.started", startedAt: "1", work: root },
{ eventId: "verifier", kind: "work.started", startedAt: "2", work: verifier },
{ eventId: "stage", kind: "work.started", startedAt: "3", work: stage },
+ {
+ action: {
+ id: "verify-action",
+ kind: "tool",
+ name: "verify",
+ parentWorkId: verifier.id,
+ rootTurnId: "turn",
+ stepIndex: 0,
+ },
+ eventId: "verify-action",
+ kind: "action.started",
+ startedAt: "3",
+ },
+ {
+ actionId: "verify-action",
+ eventId: "verify-action-label",
+ kind: "action.label.updated",
+ label: "Verify release",
+ },
],
});
const state = await renderer.render({
@@ -139,6 +158,7 @@ describe("Slack activity plan", () => {
"chat.update",
]);
expect(requests[1]!.body.get("chunks")).toContain("• verify_stage\\n");
+ expect(requests[1]!.body.get("chunks")).toContain("• Verify release\\n");
expect(requests[2]!.body.get("chunks")).toContain('"id":"reviewer"');
expect(requests[2]!.body.get("chunks")).toContain("• review_stage\\n");
expect(requests[3]!.body.get("chunks")).toContain("✓ verify_stage\\n");
diff --git a/packages/eve/src/public/channels/slack/activity-plan.ts b/packages/eve/src/public/channels/slack/activity-plan.ts
index d9646902b..a4e1750b7 100644
--- a/packages/eve/src/public/channels/slack/activity-plan.ts
+++ b/packages/eve/src/public/channels/slack/activity-plan.ts
@@ -152,7 +152,13 @@ function project(snapshot: ActivitySnapshotV1, rootTurnId: string): View {
}
for (const action of Object.values(snapshot.actions).filter((a) => a.rootTurnId === rootTurnId)) {
const p = owner(action.parentWorkId);
- if (p) entities.push({ id: action.id, name: action.name, phase: action.phase, parent: p.id });
+ if (p)
+ entities.push({
+ id: action.id,
+ name: action.label ?? action.name,
+ phase: action.phase,
+ parent: p.id,
+ });
}
for (const blocker of Object.values(snapshot.blockers).filter(
(b) => b.rootTurnId === rootTurnId,
diff --git a/packages/eve/src/public/channels/slack/activity-progress.test.ts b/packages/eve/src/public/channels/slack/activity-progress.test.ts
index 6d7d87341..c4e1465db 100644
--- a/packages/eve/src/public/channels/slack/activity-progress.test.ts
+++ b/packages/eve/src/public/channels/slack/activity-progress.test.ts
@@ -6,6 +6,7 @@ import {
buildSlackActivityRenderers,
experimental_slackActivityTree,
experimental_slackActivityStatus,
+ selectSlackActivityStatus,
} from "#public/channels/slack/activity.js";
const root = {
@@ -81,6 +82,23 @@ describe("Slack activity activity", () => {
);
});
+ it("uses action labels in the activity tree and status", () => {
+ const labeled = reduceActivityBatch(snapshot(), {
+ events: [
+ {
+ actionId: `${grandchild.id}:search`,
+ eventId: "search-label",
+ kind: "action.label.updated",
+ label: "Search Slack docs",
+ },
+ ],
+ version: 1,
+ });
+
+ expect(activityMessages(labeled).get("turn")).toContain("Search Slack docs");
+ expect(selectSlackActivityStatus(labeled)).toBe("Search Slack docs");
+ });
+
it("renders a background task instead of its duplicate initiating tool action", () => {
const task = {
callId: "call-background",
diff --git a/packages/eve/src/public/channels/slack/activity.ts b/packages/eve/src/public/channels/slack/activity.ts
index 3b8b047a4..f8c19b4c0 100644
--- a/packages/eve/src/public/channels/slack/activity.ts
+++ b/packages/eve/src/public/channels/slack/activity.ts
@@ -482,7 +482,7 @@ function renderWorkTree(
);
else if ("action" in descendant)
append(
- `${childPrefix}${branch}${phaseIcon(descendant.action.phase)} ${escapeSlackText(descendant.action.name)}`,
+ `${childPrefix}${branch}${phaseIcon(descendant.action.phase)} ${escapeSlackText(descendant.action.label ?? descendant.action.name)}`,
);
else visit(descendant.child, childPrefix, branch);
});
@@ -527,7 +527,7 @@ export function selectSlackActivityStatus(snapshot: ActivitySnapshotV1): string
const action = newestAction(
Object.values(snapshot.actions).filter((candidate) => candidate.phase === "running"),
);
- if (action !== undefined) return truncateTypingStatus(action.name);
+ if (action !== undefined) return truncateTypingStatus(action.label ?? action.name);
const delegated = newestWork(active.filter((work) => work.kind !== "root-turn"));
if (delegated !== undefined) return truncateTypingStatus(delegated.name ?? "Working with agent");
return "Working…";
diff --git a/packages/eve/src/public/definitions/exact.test.ts b/packages/eve/src/public/definitions/exact.test.ts
index d0fa1d8ef..8b768712b 100644
--- a/packages/eve/src/public/definitions/exact.test.ts
+++ b/packages/eve/src/public/definitions/exact.test.ts
@@ -80,6 +80,7 @@ describe("definition helper exact inputs", () => {
it("preserves ordinary async tool executor return types", () => {
const ordinaryTool = defineTool({
+ label: { start: (input) => `React with ${input.reaction}` },
description: "React to a message.",
inputSchema: z.object({ reaction: z.string() }),
async execute(input) {
diff --git a/packages/eve/src/public/tools/index.ts b/packages/eve/src/public/tools/index.ts
index 28278440b..5527d7025 100644
--- a/packages/eve/src/public/tools/index.ts
+++ b/packages/eve/src/public/tools/index.ts
@@ -10,6 +10,7 @@ export {
isDisabledToolSentinel,
type TaskExec,
type TaskReceipt,
+ type ToolLabelDefinition,
type ToolAuthOptions,
type ToolAuthProvider,
type ToolDefinition,
diff --git a/packages/eve/src/runtime/resolve-tool.test.ts b/packages/eve/src/runtime/resolve-tool.test.ts
index b75357d1e..08e073e47 100644
--- a/packages/eve/src/runtime/resolve-tool.test.ts
+++ b/packages/eve/src/runtime/resolve-tool.test.ts
@@ -1,7 +1,54 @@
import { describe, expect, it } from "vitest";
-import { defineTool } from "#tools/definition.js";
+
+import type { CompiledToolDefinition } from "#compiler/manifest.js";
+import { ROOT_COMPILED_AGENT_NODE_ID } from "#compiler/manifest.js";
+import type { CompiledModuleMap } from "#compiler/module-map.js";
import { normalizeToolDefinition } from "#internal/authored-definition/schema-backed.js";
import { resolveToolDefinition } from "#runtime/resolve-tool.js";
+import { defineTool } from "#tools/definition.js";
+
+const definition: CompiledToolDefinition = {
+ description: "Deploy a project.",
+ exportName: undefined,
+ hasExecute: true,
+ hasModelOutputProjection: false,
+ inputSchema: { type: "object" },
+ logicalPath: "tools/deploy.ts",
+ name: "deploy",
+ requiresApproval: false,
+ sourceId: "tools/deploy.ts",
+ sourceKind: "module",
+};
+
+function moduleMap(value: unknown): CompiledModuleMap {
+ return {
+ nodes: {
+ [ROOT_COMPILED_AGENT_NODE_ID]: {
+ modules: { [definition.sourceId]: { default: value } },
+ },
+ },
+ } as CompiledModuleMap;
+}
+
+describe("resolveToolDefinition", () => {
+ it("reattaches the authored label start callback callback", async () => {
+ const resolved = await resolveToolDefinition(
+ definition,
+ moduleMap({
+ label: {
+ start: (input: { environment: string }) => `Deploy to ${input.environment}`,
+ },
+ description: definition.description,
+ execute: () => null,
+ inputSchema: { type: "object" },
+ }),
+ undefined,
+ { kind: "application" },
+ );
+
+ expect(resolved.label?.start?.({ environment: "production" })).toBe("Deploy to production");
+ });
+});
describe("authored tool approval keys", () => {
it("validates and reattaches the scoped key callback", async () => {
diff --git a/packages/eve/src/runtime/resolve-tool.ts b/packages/eve/src/runtime/resolve-tool.ts
index b080b7827..2aef5e3ef 100644
--- a/packages/eve/src/runtime/resolve-tool.ts
+++ b/packages/eve/src/runtime/resolve-tool.ts
@@ -111,7 +111,11 @@ export async function resolveToolDefinition(
* result without clobbering required fields with `undefined`.
*/
type OptionalResolvedFields = {
- -readonly [K in "approval" | "approvalKey" | "toModelOutput"]?: ResolvedToolDefinition[K];
+ -readonly [K in
+ | "label"
+ | "approval"
+ | "approvalKey"
+ | "toModelOutput"]?: ResolvedToolDefinition[K];
};
/**
@@ -125,6 +129,19 @@ function extractOptionalHooks(
): OptionalResolvedFields {
const optional: OptionalResolvedFields = {};
+ if (record.label !== undefined) {
+ const label = expectObjectRecord(
+ record.label,
+ describe(definition, "to provide a valid label definition"),
+ );
+ optional.label = {
+ start: expectFunction(
+ label.start,
+ describe(definition, "to provide a label start callback function"),
+ ) as NonNullable<ResolvedToolDefinition["label"]>["start"],
+ };
+ }
+
if (record.approval !== undefined) {
optional.approval = normalizeApproval(
record.approval,
diff --git a/packages/eve/src/runtime/types.ts b/packages/eve/src/runtime/types.ts
index f83c67f48..a0b45d684 100644
--- a/packages/eve/src/runtime/types.ts
+++ b/packages/eve/src/runtime/types.ts
@@ -172,6 +172,8 @@ export type ResolvedToolDefinition = Readonly<
* rehydrated before entering this runtime-owned definition.
*/
readonly inputSchema: ToolSchema | null;
+ /** Presentation projected from tool lifecycle values. */
+ readonly label?: import("#tools/definition.js").InternalToolLabelDefinition;
/**
* Optional validated runtime output schema.
*/
diff --git a/packages/eve/src/execution/activity-text.ts b/packages/eve/src/shared/presentation-text.ts
similarity index 84%
rename from packages/eve/src/execution/activity-text.ts
rename to packages/eve/src/shared/presentation-text.ts
index b1a8c21e8..9c879ac07 100644
--- a/packages/eve/src/execution/activity-text.ts
+++ b/packages/eve/src/shared/presentation-text.ts
@@ -1,7 +1,7 @@
export const MAX_ACTIVITY_TEXT_LENGTH = 500;
/** Normalizes bounded untrusted presentation text before it reaches a renderer. */
-export function normalizeActivityText(text: string): string {
+export function normalizePresentationText(text: string): string {
return (
text
// Control bytes are untrusted presentation data, not meaningful activity text.
diff --git a/packages/eve/src/tools/definition.ts b/packages/eve/src/tools/definition.ts
index fd2d2335d..233b758d3 100644
--- a/packages/eve/src/tools/definition.ts
+++ b/packages/eve/src/tools/definition.ts
@@ -40,6 +40,15 @@ interface ToolDefinitionBase {
readonly execution?: ToolExecution;
}
+export interface ToolLabelDefinition<TInput = unknown> {
+ /** Returns the presentation-safe label for one action invocation. */
+ start(input: Readonly<TInput>): string;
+}
+
+export interface InternalToolLabelDefinition {
+ readonly start?: (input: unknown) => string;
+}
+
/**
* Internal/compiled tool definition shape. Carries `name` because the
* compiler stamps a path-derived identifier onto every tool entry.
@@ -48,6 +57,7 @@ interface ToolDefinitionBase {
* carry `name`; identity comes from the file path.
*/
export interface InternalToolDefinition extends ToolDefinitionBase {
+ label?: InternalToolLabelDefinition;
name: string;
inputSchema: JsonObject | null;
outputSchema?: JsonObject;
@@ -70,6 +80,7 @@ export interface PublicToolDefinition<
TInput = unknown,
TOutput = unknown,
> extends ToolDefinitionBase {
+ label?: ToolLabelDefinition<TInput>;
inputSchema: PublicToolInputSchema<TInput>;
/**
* Optional schema describing the value returned by the tool executor.
@@ -256,6 +267,7 @@ export function defineTool<
inputSchema: TSchema;
outputSchema?: PublicToolDefinition<unknown, TaskReceipt>["outputSchema"];
execute(input: StandardSchemaV1.InferOutput<TSchema>, ctx: ToolContext, task: TaskExec): TReturn;
+ label?: BackgroundToolDefinition<StandardSchemaV1.InferOutput<TSchema>, unknown>["label"];
approval?: BackgroundToolDefinition<StandardSchemaV1.InferOutput<TSchema>, unknown>["approval"];
approvalKey?: BackgroundToolDefinition<
StandardSchemaV1.InferOutput<TSchema>,
@@ -282,6 +294,7 @@ export function defineTool<
inputSchema: TInputSchema;
outputSchema: TOutputSchema;
execute(input: StandardSchemaV1.InferOutput<TInputSchema>, ctx: ToolContext): TReturn;
+ label?: ToolDefinition<StandardSchemaV1.InferOutput<TInputSchema>, unknown>["label"];
approval?: ToolDefinition<StandardSchemaV1.InferOutput<TInputSchema>, unknown>["approval"];
approvalKey?: ToolDefinition<StandardSchemaV1.InferOutput<TInputSchema>, unknown>["approvalKey"];
toModelOutput?: ToolDefinition<
@@ -301,6 +314,7 @@ export function defineTool<
inputSchema: TSchema;
outputSchema?: JsonObject;
execute(input: StandardSchemaV1.InferOutput<TSchema>, ctx: ToolContext): TReturn;
+ label?: ToolDefinition<StandardSchemaV1.InferOutput<TSchema>, unknown>["label"];
approval?: ToolDefinition<StandardSchemaV1.InferOutput<TSchema>, unknown>["approval"];
approvalKey?: ToolDefinition<StandardSchemaV1.InferOutput<TSchema>, unknown>["approvalKey"];
toModelOutput?: ToolDefinition<unknown, ToolOutputFromExecuteReturn<TReturn>>["toModelOutput"];
@@ -320,6 +334,7 @@ export function defineTool<
inputSchema: JsonObject;
outputSchema: TOutputSchema;
execute(input: Record<string, unknown>, ctx: ToolContext): TReturn;
+ label?: ToolDefinition<Record<string, unknown>, unknown>["label"];
approval?: ToolDefinition<Record<string, unknown>, unknown>["approval"];
approvalKey?: ToolDefinition<Record<string, unknown>, unknown>["approvalKey"];
toModelOutput?: ToolDefinition<
@@ -336,6 +351,7 @@ export function defineTool<TReturn>(definition: {
inputSchema: JsonObject;
outputSchema?: JsonObject;
execute(input: Record<string, unknown>, ctx: ToolContext): TReturn;
+ label?: ToolDefinition<Record<string, unknown>, unknown>["label"];
approval?: ToolDefinition<Record<string, unknown>, unknown>["approval"];
approvalKey?: ToolDefinition<Record<string, unknown>, unknown>["approvalKey"];
toModelOutput?: ToolDefinition<unknown, ToolOutputFromExecuteReturn<TReturn>>["toModelOutput"];
@@ -357,6 +373,7 @@ export function stampToolDefinition<
T extends {
readonly description: string;
readonly execute: (...args: never[]) => unknown;
+ readonly label?: ToolLabelDefinition;
readonly approval?: Approval<never>;
readonly approvalKey?: (...args: never[]) => unknown;
readonly toModelOutput?: (...args: never[]) => unknown;
@@ -372,6 +389,7 @@ export function stampToolDefinition<
stampDurableDynamicToolCallbacks(
definition,
collectDurableDynamicToolCallbacks({
+ label: definition.label,
approval: definition.approval,
approvalKey: definition.approvalKey,
execute: definition.execute,
diff --git a/packages/eve/src/tools/durable-callbacks.ts b/packages/eve/src/tools/durable-callbacks.ts
index f270c209a..2c5d9a792 100644
--- a/packages/eve/src/tools/durable-callbacks.ts
+++ b/packages/eve/src/tools/durable-callbacks.ts
@@ -3,6 +3,7 @@ import { resolveApprovalPolicy } from "#approval/definition.js";
import type { JsonObject } from "#shared/json.js";
export type DurableDynamicCallbackPhase =
+ | "labelStart"
| "approvalKey"
| "approvalRequest"
| "approvalResponse"
@@ -24,6 +25,9 @@ export interface DurableDynamicCallbackReference {
export interface DurableDynamicToolCallbacks {
readonly execute: DurableDynamicCallbackReference;
+ readonly label?: {
+ readonly start?: DurableDynamicCallbackReference;
+ };
readonly approvalKey?: DurableDynamicCallbackReference;
readonly approvalRequest?: DurableDynamicCallbackReference;
readonly approvalResponse?: DurableDynamicCallbackReference;
@@ -38,6 +42,9 @@ export interface StampedDurableDynamicCallback {
export type LiveDurableDynamicToolCallbacks = Partial<{
execute: StampedDurableDynamicCallback;
+ label: {
+ readonly start?: StampedDurableDynamicCallback;
+ };
approvalKey: StampedDurableDynamicCallback;
approvalRequest: StampedDurableDynamicCallback;
approvalResponse: StampedDurableDynamicCallback;
@@ -179,11 +186,15 @@ export function stampDurableDynamicToolCallbacks(
}
export function collectDurableDynamicToolCallbacks(input: {
+ readonly label?: {
+ readonly start?: (...args: never[]) => unknown;
+ };
readonly approval?: Approval<never>;
readonly approvalKey?: (...args: never[]) => unknown;
readonly execute: (...args: never[]) => unknown;
readonly toModelOutput?: (...args: never[]) => unknown;
}): LiveDurableDynamicToolCallbacks {
+ const labelStart = readDurableDynamicCallback(input.label?.start);
const approvalRequest =
input.approval === undefined
? undefined
@@ -198,6 +209,7 @@ export function collectDurableDynamicToolCallbacks(input: {
const toModelOutput = readDurableDynamicCallback(input.toModelOutput);
const callbacks: LiveDurableDynamicToolCallbacks = {};
if (execute !== undefined) callbacks.execute = execute;
+ if (labelStart !== undefined) callbacks.label = { start: labelStart };
if (approvalKey !== undefined) callbacks.approvalKey = approvalKey;
if (approvalRequest !== undefined) callbacks.approvalRequest = approvalRequest;
if (approvalResponse !== undefined) callbacks.approvalResponse = approvalResponse;
diff --git a/packages/eve/src/tools/dynamic.ts b/packages/eve/src/tools/dynamic.ts
index 9bdfec7fd..8356a0023 100644
--- a/packages/eve/src/tools/dynamic.ts
+++ b/packages/eve/src/tools/dynamic.ts
@@ -3,6 +3,7 @@ import type { DynamicResolveContext, DynamicToolEventName } from "#dynamic/defin
import type {
PublicToolInputSchema,
PublicToolOutputSchema,
+ ToolLabelDefinition,
ToolContext,
} from "#tools/definition.js";
import type { TaskExec } from "#tools/task.js";
@@ -22,6 +23,7 @@ import type { ToolModelOutput } from "#tools/model-output.js";
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export interface DynamicToolEntry<TInput = Record<string, unknown>, TOutput = any> {
+ readonly label?: ToolLabelDefinition<TInput>;
readonly description: string;
readonly inputSchema: PublicToolInputSchema<TInput>;
readonly outputSchema?: PublicToolOutputSchema<TOutput>;
diff --git a/packages/eve/src/tools/provided/bash.ts b/packages/eve/src/tools/provided/bash.ts
index f82251646..2de339173 100644
--- a/packages/eve/src/tools/provided/bash.ts
+++ b/packages/eve/src/tools/provided/bash.ts
@@ -1,6 +1,7 @@
import { z } from "#compiled/zod/index.js";
import { executeBashOnSandbox, type BashInput } from "#execution/sandbox/bash.js";
+import { toolLabel } from "#tools/tool-label.js";
import { defineTool, type ToolDefinition } from "#tools/definition.js";
/**
@@ -32,6 +33,7 @@ export type BashToolOutput = z.infer<typeof BASH_OUTPUT_SCHEMA>;
* top-level import here does not force those backends to initialize eagerly.
*/
export const bash: ToolDefinition<BashToolInput, BashToolOutput> = defineTool({
+ label: { start: (input) => toolLabel("Run", input.command) },
description: "Execute a shell command in the shared workspace environment.",
async execute(input, ctx) {
return await executeBashOnSandbox(await ctx.getSandbox(), input as BashInput);
diff --git a/packages/eve/src/tools/provided/glob.ts b/packages/eve/src/tools/provided/glob.ts
index 864cdbb32..5af588e69 100644
--- a/packages/eve/src/tools/provided/glob.ts
+++ b/packages/eve/src/tools/provided/glob.ts
@@ -1,6 +1,7 @@
import { z } from "#compiled/zod/index.js";
import { type GlobInput, executeGlobOnSandbox } from "#execution/sandbox/glob-tool.js";
+import { toolLabel } from "#tools/tool-label.js";
import { defineTool, type ToolDefinition } from "#tools/definition.js";
/**
@@ -43,6 +44,7 @@ export type GlobToolOutput = z.infer<typeof GLOB_OUTPUT_SCHEMA>;
* Framework-owned executor that delegates to the default sandbox.
*/
export const glob: ToolDefinition<GlobToolInput, GlobToolOutput> = defineTool({
+ label: { start: (input) => toolLabel("Find", input.pattern) },
description: [
"Fast file pattern matching tool that works with any codebase size.",
"",
diff --git a/packages/eve/src/tools/provided/grep.ts b/packages/eve/src/tools/provided/grep.ts
index be7a923ff..e2193d555 100644
--- a/packages/eve/src/tools/provided/grep.ts
+++ b/packages/eve/src/tools/provided/grep.ts
@@ -1,6 +1,7 @@
import { z } from "#compiled/zod/index.js";
import { type GrepInput, executeGrepOnSandbox } from "#execution/sandbox/grep-tool.js";
+import { toolLabel } from "#tools/tool-label.js";
import { defineTool, type ToolDefinition } from "#tools/definition.js";
/**
@@ -64,6 +65,7 @@ export type GrepToolOutput = z.infer<typeof GREP_OUTPUT_SCHEMA>;
* Framework-owned executor that delegates to the default sandbox.
*/
export const grep: ToolDefinition<GrepToolInput, GrepToolOutput> = defineTool({
+ label: { start: (input) => toolLabel("Search", input.pattern) },
description: [
"Fast content search tool that works with any codebase size.",
"",
diff --git a/packages/eve/src/tools/provided/load-skill.ts b/packages/eve/src/tools/provided/load-skill.ts
index a8c0c4c70..80ba6d9b5 100644
--- a/packages/eve/src/tools/provided/load-skill.ts
+++ b/packages/eve/src/tools/provided/load-skill.ts
@@ -3,11 +3,19 @@ import {
SKILL_INPUT_SCHEMA,
SKILL_OUTPUT_SCHEMA,
} from "#execution/tools/load-skill.js";
+import { toolLabel } from "#tools/tool-label.js";
import { defineTool } from "#tools/definition.js";
import { attachToolBehavior } from "#tools/behavior.js";
export const loadSkill = attachToolBehavior(
defineTool({
+ label: {
+ start: (input) =>
+ toolLabel(
+ "Load",
+ typeof input === "object" && input !== null ? Reflect.get(input, "skill") : undefined,
+ ),
+ },
description: [
"Load the full instructions for one available skill by name or id.",
"Use this tool when the request clearly matches a listed skill description or when the user explicitly asks for that skill.",
@@ -18,10 +26,7 @@ export const loadSkill = attachToolBehavior(
inputSchema: SKILL_INPUT_SCHEMA,
outputSchema: SKILL_OUTPUT_SCHEMA,
}),
- {
- availability: [],
- presentation: "load-skill",
- },
+ { availability: [], presentation: "load-skill" },
);
export default loadSkill;
diff --git a/packages/eve/src/tools/provided/read-file.ts b/packages/eve/src/tools/provided/read-file.ts
index 4fb624cdb..00f956e73 100644
--- a/packages/eve/src/tools/provided/read-file.ts
+++ b/packages/eve/src/tools/provided/read-file.ts
@@ -1,6 +1,7 @@
import { z } from "#compiled/zod/index.js";
import { type ReadFileInput, executeReadFileOnSandbox } from "#execution/sandbox/read-file.js";
+import { toolLabel } from "#tools/tool-label.js";
import { defineTool, type ToolDefinition } from "#tools/definition.js";
/**
@@ -42,6 +43,7 @@ export type ReadFileToolOutput = z.infer<typeof READ_FILE_OUTPUT_SCHEMA>;
* Framework-owned executor that delegates to the default sandbox.
*/
export const readFile: ToolDefinition<ReadFileToolInput, ReadFileToolOutput> = defineTool({
+ label: { start: (input) => toolLabel("Read", input.filePath) },
description: [
"Read a file from the local filesystem. If the path does not exist, an error is returned.",
"",
diff --git a/packages/eve/src/tools/provided/web-fetch.ts b/packages/eve/src/tools/provided/web-fetch.ts
index 32dc0f609..dd08d7196 100644
--- a/packages/eve/src/tools/provided/web-fetch.ts
+++ b/packages/eve/src/tools/provided/web-fetch.ts
@@ -1,6 +1,7 @@
import { z } from "#compiled/zod/index.js";
import { type WebFetchInput, executeWebFetchTool } from "#execution/web-fetch/execute.js";
+import { toolLabel } from "#tools/tool-label.js";
import { defineTool, type ToolDefinition } from "#tools/definition.js";
export const WEB_FETCH_INPUT_SCHEMA = z.strictObject({
@@ -25,6 +26,7 @@ export type WebFetchToolInput = z.infer<typeof WEB_FETCH_INPUT_SCHEMA>;
export type WebFetchToolOutput = z.infer<typeof WEB_FETCH_OUTPUT_SCHEMA>;
export const webFetch: ToolDefinition<WebFetchToolInput, WebFetchToolOutput> = defineTool({
+ label: { start: (input) => toolLabel("Fetch", input.url) },
description: [
"Fetch a webpage and return its content in the requested format. Use this to retrieve and analyze content from URLs.",
"",
diff --git a/packages/eve/src/tools/provided/write-file.ts b/packages/eve/src/tools/provided/write-file.ts
index 1f4426be1..146b69e0f 100644
--- a/packages/eve/src/tools/provided/write-file.ts
+++ b/packages/eve/src/tools/provided/write-file.ts
@@ -1,6 +1,7 @@
import { z } from "#compiled/zod/index.js";
import { type WriteFileInput, executeWriteFileOnSandbox } from "#execution/sandbox/write-file.js";
+import { toolLabel } from "#tools/tool-label.js";
import { defineTool, type ToolDefinition } from "#tools/definition.js";
/**
@@ -28,6 +29,7 @@ export type WriteFileToolOutput = z.infer<typeof WRITE_FILE_OUTPUT_SCHEMA>;
* Framework-owned executor that delegates to the default sandbox.
*/
export const writeFile: ToolDefinition<WriteFileToolInput, WriteFileToolOutput> = defineTool({
+ label: { start: (input) => toolLabel("Write", input.filePath) },
description: [
"Writes a file to the local filesystem.",
"",
diff --git a/packages/eve/src/tools/tool-label.test.ts b/packages/eve/src/tools/tool-label.test.ts
new file mode 100644
index 000000000..9aa8a2e5f
--- /dev/null
+++ b/packages/eve/src/tools/tool-label.test.ts
@@ -0,0 +1,42 @@
+import { describe, expect, it } from "vitest";
+
+import { bash } from "#tools/provided/bash.js";
+import { glob } from "#tools/provided/glob.js";
+import { grep } from "#tools/provided/grep.js";
+import { loadSkill } from "#tools/provided/load-skill.js";
+import { readFile } from "#tools/provided/read-file.js";
+import { webFetch } from "#tools/provided/web-fetch.js";
+import { resolveWebSearchActivityLabel } from "#harness/provider-tool-schemas.js";
+import { writeFile } from "#tools/provided/write-file.js";
+
+describe("provided tool labels", () => {
+ it("labels every tool previously formatted by Slack", () => {
+ expect(bash.label?.start({ command: "pnpm test" })).toBe("Run pnpm test");
+ expect(glob.label?.start({ pattern: "**/*.ts" })).toBe("Find **/*.ts");
+ expect(grep.label?.start({ pattern: "slackActivityMessage" })).toBe(
+ "Search slackActivityMessage",
+ );
+ expect(loadSkill.label?.start({ skill: "technical-writing" })).toBe("Load technical-writing");
+ expect(readFile.label?.start({ filePath: "channels/slack/activity.ts" })).toBe(
+ "Read channels/slack/activity.ts",
+ );
+ expect(webFetch.label?.start({ url: "https://docs.slack.dev" })).toBe(
+ "Fetch https://docs.slack.dev",
+ );
+ expect(resolveWebSearchActivityLabel({ query: "Slack plan blocks" })).toBe(
+ "Search Slack plan blocks",
+ );
+ expect(writeFile.label?.start({ content: "", filePath: "activity.ts" })).toBe(
+ "Write activity.ts",
+ );
+ });
+
+ it("handles provider-specific web search inputs", () => {
+ expect(resolveWebSearchActivityLabel({ objective: "Find Slack docs" })).toBe(
+ "Search Find Slack docs",
+ );
+ expect(
+ resolveWebSearchActivityLabel({ action: { queries: ["Slack docs", "Block Kit"] } }),
+ ).toBe("Search Slack docs");
+ });
+});
diff --git a/packages/eve/src/tools/tool-label.ts b/packages/eve/src/tools/tool-label.ts
new file mode 100644
index 000000000..cd717f68e
--- /dev/null
+++ b/packages/eve/src/tools/tool-label.ts
@@ -0,0 +1,5 @@
+export function toolLabel(verb: string, value: unknown): string {
+ if (typeof value !== "string" && typeof value !== "number") return verb;
+ const detail = String(value).trim();
+ return detail === "" ? verb : `${verb} ${detail}`;
+}
diff --git a/packages/eve/test/scenarios/mounted-extension-installed.scenario.test.ts b/packages/eve/test/scenarios/mounted-extension-installed.scenario.test.ts
index bbfb38439..ca7b6280f 100644
--- a/packages/eve/test/scenarios/mounted-extension-installed.scenario.test.ts
+++ b/packages/eve/test/scenarios/mounted-extension-installed.scenario.test.ts
@@ -249,7 +249,7 @@ describe("mounted extension installed under node_modules", () => {
);
expect(
JSON.parse(extensionFiles[`node_modules/${PACKAGE_NAME}/dist/extension/_manifest.json`]!),
- ).toMatchObject({ requires: { channel: 18, schedule: 10, subagent: 9 } });
+ ).toMatchObject({ requires: { channel: 19, schedule: 11, subagent: 10 } });
const app = await scenarioApp({
name: "mounted-extension-installed",
installDependencies: true,