The Open Framework for Building Agents
[2/3] feat(eve)!: run approval response policies for Cancel (#3954)
Ben Pankow1a5bc56e8539
diff --git a/.changeset/hitl-cancel-response-policy.md b/.changeset/hitl-cancel-response-policy.mdnew file mode 100644index 000000000..23c11ba9a--- /dev/null+++ b/.changeset/hitl-cancel-response-policy.md@@ -0,0 +1,5 @@+---+"eve": minor+---++Approval response policies now run for Cancel as well as Approve (`response.decision` is `"approve" | "cancel"`), so a responder the policy rejects can no longer cancel someone else's request; a policy that only restricts approval should return `{ status: "allowed" }` for `cancel`. The responder moved from `responder` to `response.principal`, alongside `request.principal`.diff --git a/docs/patterns/multi-tenant-approvals.md b/docs/patterns/multi-tenant-approvals.mdindex caa29cac6..9193ab19f 100644--- a/docs/patterns/multi-tenant-approvals.md+++ b/docs/patterns/multi-tenant-approvals.md@@ -190,6 +190,6 @@ An approval durably pauses the session and a later request resumes it. Your HTTP- `POST /eve/v1/session/:sessionId`, including `inputResponses`;- `GET /eve/v1/session/:sessionId/stream`.-Built-in approval confirms that a human with access to the session approved the call. It is not a four-eyes workflow that proves a different person or role approved it. For that requirement, create an application-owned approval request, notify eligible approvers through a channel, and have policy return allow only after that request records an authorized decision.+Built-in approval confirms that a human with access to the session approved the call. To restrict who may respond, add an [approval response policy](/docs/human-in-the-loop#authorizing-approval-responses): it receives who responded as `response.principal` and who asked for the call as `request.principal`, and runs for both Approve and Cancel. For a four-eyes workflow, where a different person or role must approve, branch on `response.decision`: allow `cancel` so the requester can still withdraw the call, and for `approve` reject a `response.principal` that matches `request.principal` and check the responder's role.The complete eve integration is one async adapter reused by tools and both connection protocols. The tenant's rule storage and governance model remain application concerns.diff --git a/docs/tools/human-in-the-loop.md b/docs/tools/human-in-the-loop.mdindex 97058ea6a..be7d2c857 100644--- a/docs/tools/human-in-the-loop.md+++ b/docs/tools/human-in-the-loop.md@@ -82,7 +82,7 @@ Gating a side effect on approval is also how you make non-idempotent work safe a### Authorizing approval responses-You may also define an approval response policy that decides whether the authenticated person who selects **Approve** may approve that specific call:+You may also define an approval response policy that decides whether the authenticated person who selects **Approve** or **Cancel** may settle that specific call:```ts title="agent/tools/refund_charge.ts"import { defineTool } from "eve/tools";@@ -94,11 +94,11 @@ export default defineTool({inputSchema: z.object({ chargeId: z.string() }),approval: {request: always(),- response: ({ responder, request, response, session, auth }) => {+ response: ({ request, response, session, auth }) => {// The Slack channel authenticates the responder and includes the workspace and user IDs.// Larger apps can look up approver membership here instead.const approvers = ["slack:T012AB3CD:U045EF6GH", "slack:T012AB3CD:U078JK9LM"];- const canApprove = approvers.includes(responder.principalId);+ const canApprove = approvers.includes(response.principal.principalId);return canApprove? { status: "allowed" }@@ -113,15 +113,14 @@ export default defineTool({The `response` policy receives:-- `responder`: the authenticated principal that submitted the response, including its `principalId`, `principalType`, `authenticator`, and `attributes`. Your route or channel supplies this identity.- `request`: the stable `requestId`, `callId`, `toolName`, and typed `toolInput` for the call being approved, plus `principal`: the authenticated principal whose turn requested the call, or `null` when that caller was unauthenticated or anonymous. eve captures `request.principal` when the approval is requested, so it stays the same while other people continue the session.-- `response`: the submitted decision. Response policies run for approval, so its current value is `{ decision: "approve" }`.+- `response`: the submitted `decision`, `"approve"` or `"cancel"`, plus `principal`: the authenticated principal that submitted it, including its `principalId`, `principalType`, `authenticator`, and `attributes`. Your route or channel supplies this identity. The policy runs for both decisions, so a responder it rejects can neither approve nor cancel the call.- `session`: read-only session identity and lineage: `id`, `initiator`, `parent`, and `turn`.- `auth`: narrow `getToken(provider, options?)` and `requireAuth(provider, options?)` capabilities bound to the responder. Use these when authorization depends on a provider identity or permission; an interactive provider flow parks durably and then retries the policy.-Return `{ status: "allowed" }` to accept the approval. Return `{ status: "rejected", reason }` to leave the shared request pending so another eligible responder can approve it.+Return `{ status: "allowed" }` to accept the decision. Return `{ status: "rejected", reason }` to leave the shared request pending so another eligible responder can settle it. When a policy only cares who approves, return `{ status: "allowed" }` for `cancel` so anyone can still dismiss the request.-`session.initiator` is the person who started the session, and `request.principal` is the person who asked for this call. In a shared thread they can differ. Compare the full identity of `responder` with `request.principal` to let only the requester approve the call:+`session.initiator` is the person who started the session, and `request.principal` is the person who asked for this call. In a shared thread they can differ. Compare the full identity of `response.principal` with `request.principal` to let only the requester settle the call:```ts title="agent/tools/publish_release.ts"import { defineTool } from "eve/tools";@@ -144,13 +143,10 @@ export default defineTool({approval: {request: always(),// `request.principal` is null for an unauthenticated or anonymous caller, so no one matches it.- response: ({ request, responder }) =>- request.principal !== null && samePrincipal(responder, request.principal)+ response: ({ request, response }) =>+ request.principal !== null && samePrincipal(response.principal, request.principal)? { status: "allowed" }- : {- status: "rejected",- reason: "Only the person who asked for this release can approve it.",- },+ : { status: "rejected", reason: "Only the person who asked for this release can respond." },},async execute(input) {return publish(input);diff --git a/e2e/fixtures/agent-tools-hitl/agent/tools/authorized-change.ts b/e2e/fixtures/agent-tools-hitl/agent/tools/authorized-change.tsindex 2de3b3cbe..6e5de6c67 100644--- a/e2e/fixtures/agent-tools-hitl/agent/tools/authorized-change.ts+++ b/e2e/fixtures/agent-tools-hitl/agent/tools/authorized-change.ts@@ -10,10 +10,17 @@ export default defineTool({inputSchema: z.object({}),approval: {request: always(),- response: ({ responder }) =>- responder.principalId === "e2e-approval-responder"+ response: ({ request, response }) => {+ // The person who asked for the change may withdraw it; only the fixture approver approves it.+ if (response.decision === "cancel") {+ return response.principal.principalId === request.principal?.principalId+ ? { status: "allowed" }+ : { status: "rejected", reason: "Only the requester can cancel this change." };+ }+ return response.principal.principalId === "e2e-approval-responder"? { status: "allowed" }- : { status: "rejected", reason: "Wrong responder." },+ : { status: "rejected", reason: "Wrong responder." };+ },},async execute() {executions.update((count) => count + 1);diff --git a/e2e/fixtures/agent-tools-hitl/agent/tools/authorized-gate.ts b/e2e/fixtures/agent-tools-hitl/agent/tools/authorized-gate.tsindex 2efc23913..933f6782a 100644--- a/e2e/fixtures/agent-tools-hitl/agent/tools/authorized-gate.ts+++ b/e2e/fixtures/agent-tools-hitl/agent/tools/authorized-gate.ts@@ -7,8 +7,8 @@ export default defineTool({inputSchema: z.object({ marker: z.string() }),approval: {request: always(),- response: ({ response, responder }) =>- response.decision === "approve" && responder.principalId === "e2e-approval-responder"+ response: ({ response }) =>+ response.decision === "approve" && response.principal.principalId === "e2e-approval-responder"? ({ status: "allowed" } as const): ({ status: "rejected", reason: "Unexpected eval responder." } as const),},diff --git a/e2e/fixtures/agent-tools-hitl/agent/tools/oauth-authorized-gate.ts b/e2e/fixtures/agent-tools-hitl/agent/tools/oauth-authorized-gate.tsindex e7ddd1e4d..53e6238c5 100644--- a/e2e/fixtures/agent-tools-hitl/agent/tools/oauth-authorized-gate.ts+++ b/e2e/fixtures/agent-tools-hitl/agent/tools/oauth-authorized-gate.ts@@ -38,9 +38,11 @@ export default defineTool({inputSchema: z.object({ marker: z.string() }),approval: {request: always(),- async response({ auth, responder }) {+ async response({ auth, response }) {+ // Anyone may cancel; only an approval needs the responder's OAuth identity.+ if (response.decision === "cancel") return { status: "allowed" };const credential = await auth.getToken(fakeOAuth, { authKey: "fixture-oauth" });- return credential.providerSubject === responder.principalId+ return credential.providerSubject === response.principal.principalId? { status: "allowed" }: { status: "rejected", reason: "Fixture OAuth identity mismatch." };},diff --git a/e2e/fixtures/agent-tools-hitl/agent/tools/responder-gate.ts b/e2e/fixtures/agent-tools-hitl/agent/tools/responder-gate.tsindex 3f54546e8..207b65ed6 100644--- a/e2e/fixtures/agent-tools-hitl/agent/tools/responder-gate.ts+++ b/e2e/fixtures/agent-tools-hitl/agent/tools/responder-gate.ts@@ -7,8 +7,8 @@ export default defineTool({inputSchema: z.object({ marker: z.string() }),approval: {request: always(),- response: ({ responder }) =>- responder.principalId === "e2e-approval-responder"+ response: ({ response }) =>+ response.principal.principalId === "e2e-approval-responder"? { status: "allowed" }: { status: "rejected", reason: "This responder is not authorized." },},diff --git a/e2e/fixtures/agent-tools-hitl/evals/hitl/approval-requester-cancel.eval.ts b/e2e/fixtures/agent-tools-hitl/evals/hitl/approval-requester-cancel.eval.tsnew file mode 100644index 000000000..b4e850a46--- /dev/null+++ b/e2e/fixtures/agent-tools-hitl/evals/hitl/approval-requester-cancel.eval.ts@@ -0,0 +1,44 @@+import { defineEval } from "eve/evals";++const ALICE = { "x-eve-fixture-user": "alice", "x-eve-fixture-model": "continuation" };+const BOB = { "x-eve-fixture-user": "bob", "x-eve-fixture-model": "continuation" };+const TOOL = "authorized-change";++/**+ * Alice prepares a change that needs approval. The approval's response policy+ * lets only the person who requested it cancel it. Bob's Cancel is rejected+ * and the request stays pending; Alice's Cancel then settles it.+ */+export default defineEval({+ description: "An approval response policy sees the request's requester and authorizes Cancel.",+ tags: ["hitl", "authorization", "approval"],+ timeoutMs: 60_000,+ async test(t) {+ const session = await t.session({ headers: ALICE });+ const parked = await session.send("Prepare an authorized change.", { headers: ALICE });+ const { requestId } = parked.session.requireInputRequest({ toolName: TOOL });++ const refused = await session.respond([{ optionId: "cancel", requestId }], { headers: BOB });+ refused.event("approval.candidate", {+ count: 1,+ data: {+ outcome: "rejected",+ reason: "Only the requester can cancel this change.",+ requestId,+ responderPrincipalId: "bob",+ },+ });+ refused.notEvent("approval.settled");+ refused.notEvent("input.resolved");++ const cancelled = await session.respond([{ optionId: "cancel", requestId }], {+ headers: ALICE,+ });+ cancelled.event("approval.settled", {+ count: 1,+ data: { outcome: "cancelled", requestId, responderPrincipalId: "alice" },+ });+ cancelled.calledTool(TOOL, { status: "completed", count: 0 });+ t.succeeded();+ },+});diff --git a/packages/eve/extension-contracts/compatibility/connection/v30.ts b/packages/eve/extension-contracts/compatibility/connection/v30.tsdeleted file mode 100644index b0e8aca27..000000000--- a/packages/eve/extension-contracts/compatibility/connection/v30.ts+++ /dev/null@@ -1,15 +0,0 @@-import { defineMcpClientConnection } from "#public/connections/index.js";-import { always } from "#public/tools/approval/index.js";--// Epoch 30 approval requests had no `requester`; it is additive.-export default defineMcpClientConnection({- description: "Search the support knowledge base.",- url: "https://support.example.com/mcp",- approval: {- request: always(),- response: ({ request, responder }) =>- request.toolName.startsWith("search") || responder.principalId === "approver"- ? { status: "allowed" }- : { status: "rejected", reason: "Only the approver can run this tool." },- },-});diff --git a/packages/eve/extension-contracts/compatibility/dynamicTool/v58.ts b/packages/eve/extension-contracts/compatibility/dynamicTool/v58.tsdeleted file mode 100644index 611cca7f9..000000000--- a/packages/eve/extension-contracts/compatibility/dynamicTool/v58.ts+++ /dev/null@@ -1,22 +0,0 @@-import { defineDynamic, defineTool } from "#public/tools/index.js";-import { always } from "#public/tools/approval/index.js";--// Epoch 58 approval requests had no `requester`; it is additive.-export default defineDynamic({- events: {- "turn.started": () => ({- refund: defineTool({- description: "Refund a charge after an approver allows it.",- inputSchema: { type: "object", properties: {} },- approval: {- request: always(),- response: ({ responder }) =>- responder.principalId === "approver"- ? { status: "allowed" }- : { status: "rejected", reason: "Only the approver can refund charges." },- },- execute: () => ({ refunded: true }),- }),- }),- },-});diff --git a/packages/eve/extension-contracts/compatibility/tool/v61.ts b/packages/eve/extension-contracts/compatibility/tool/v61.tsdeleted file mode 100644index 6d4c747ef..000000000--- a/packages/eve/extension-contracts/compatibility/tool/v61.ts+++ /dev/null@@ -1,18 +0,0 @@-import { z } from "zod";-import { defineTool } from "#public/tools/index.js";-import { always } from "#public/tools/approval/index.js";--// Epoch 61 approval requests had no `requester`. Compiled epoch 61 response-// policies still read `responder` and `request`; `requester` is additive.-export default defineTool({- description: "Refund a charge after an approver allows it.",- inputSchema: z.object({ chargeId: z.string() }),- approval: {- request: always(),- response: ({ request, responder }) =>- request.toolName === "refund" && responder.principalId === "approver"- ? { status: "allowed" }- : { status: "rejected", reason: "Only the approver can refund charges." },- },- execute: ({ chargeId }) => ({ chargeId, refunded: true }),-});diff --git a/packages/eve/extension-contracts/reports/connection/v32.json b/packages/eve/extension-contracts/reports/connection/v32.jsonnew file mode 100644index 000000000..230565b98--- /dev/null+++ b/packages/eve/extension-contracts/reports/connection/v32.json@@ -0,0 +1,16 @@+{+ "kind": "eve-extension-capability-contract",+ "capability": "connection",+ "epoch": 32,+ "sha256": "5e9ce83b4643046bbf23cf624c1c926735551e8924ddf33f29249ba81b9da1d7",+ "exports": [+ "ConnectionAuthorizationFailedError",+ "ConnectionAuthorizationRequiredError",+ "defineDynamic",+ "defineInteractiveAuthorization",+ "defineMcpClientConnection",+ "defineOpenAPIConnection",+ "isConnectionAuthorizationFailedError",+ "isConnectionAuthorizationRequiredError"+ ]+}diff --git a/packages/eve/extension-contracts/reports/dynamicTool/v60.json b/packages/eve/extension-contracts/reports/dynamicTool/v60.jsonnew file mode 100644index 000000000..1e61d0cd8--- /dev/null+++ b/packages/eve/extension-contracts/reports/dynamicTool/v60.json@@ -0,0 +1,16 @@+{+ "kind": "eve-extension-capability-contract",+ "capability": "dynamicTool",+ "epoch": 60,+ "sha256": "271a12b6fc4f6c6ef04af72fa0014a92a67a837da4c537d1d210b25dbdfbae20",+ "exports": [+ "DynamicToolEntry",+ "DynamicToolEvents",+ "DynamicToolResult",+ "DynamicToolSet",+ "auto",+ "defineDurableCallback",+ "defineDurableSchema",+ "defineDynamic"+ ]+}diff --git a/packages/eve/extension-contracts/reports/tool/v63.json b/packages/eve/extension-contracts/reports/tool/v63.jsonnew file mode 100644index 000000000..6dd6fa7a9--- /dev/null+++ b/packages/eve/extension-contracts/reports/tool/v63.json@@ -0,0 +1,28 @@+{+ "kind": "eve-extension-capability-contract",+ "capability": "tool",+ "epoch": 63,+ "sha256": "88fcbd946dba58274957226b245a74497df8cf68018c35ccc50447d9e4200a76",+ "exports": [+ "AgentRouterInput",+ "AgentRouterTool",+ "WorkflowStepToolContext",+ "WorkflowTool",+ "WorkflowToolDefinition",+ "WorkflowToolInput",+ "WorkflowToolOptions",+ "agentRouter",+ "defaultWebSearch",+ "defineTool",+ "defineWorkflowTool",+ "disableTool",+ "evaluate",+ "isDisabledToolSentinel",+ "isWebSearchToolDefinition",+ "toolOutput",+ "toolOutputPart",+ "toolResultFrom",+ "webSearch",+ "workflow"+ ]+}diff --git a/packages/eve/src/approval/definition.test.ts b/packages/eve/src/approval/definition.test.tsindex a10cd47c7..843a76c18 100644--- a/packages/eve/src/approval/definition.test.ts+++ b/packages/eve/src/approval/definition.test.ts@@ -31,8 +31,7 @@ describe("approval definitions", () => {requireAuth: (...args: any[]) => never;};request: { callId: string; principal: unknown; requestId: string; toolName: string };- response: { decision: "approve" };- responder: { principalId: string };+ response: { decision: "approve" | "cancel"; principal: { principalId: string } };session: { id: string; initiator: unknown; turn: unknown };}>();expectTypeOf<ApprovalResponseContext["auth"]>().not.toHaveProperty("getSandbox");diff --git a/packages/eve/src/approval/definition.ts b/packages/eve/src/approval/definition.tsindex 7bf02cef0..2525ff5dd 100644--- a/packages/eve/src/approval/definition.ts+++ b/packages/eve/src/approval/definition.ts@@ -68,9 +68,14 @@ export interface ApprovalResponseAuth {requireAuth(provider: ToolAuthProvider, options?: ToolAuthOptions): never;}-/** Submitted decision passed to an approval response policy. */+/** Submitted response passed to an approval response policy. */export interface ApprovalResponse {- readonly decision: "approve";+ readonly decision: "approve" | "cancel";+ /**+ * Who submitted the response: the authenticated principal, including its+ * `principalId`, `principalType`, `authenticator`, and `attributes`.+ */+ readonly principal: SessionAuthContext;}/** Context passed to an approval response policy. */@@ -78,16 +83,18 @@ export interface ApprovalResponseContext<TInput = Record<string, unknown>> {readonly auth: ApprovalResponseAuth;readonly request: ApprovalRequest<TInput>;readonly response: ApprovalResponse;- readonly responder: SessionAuthContext;readonly session: ApprovalResponseSession;}-/** Response policy decision. Rejection keeps the shared request pending. */+/**+ * Response policy decision. Rejection keeps the shared request pending, so+ * another responder can still settle it.+ */export type ApprovalResponseDecision =| { readonly status: "allowed" }| { readonly reason: string; readonly status: "rejected" };-/** Decides whether an authenticated responder may approve one request. */+/** Decides whether an authenticated responder may approve or cancel one request. */export type ApprovalResponsePolicy<TInput = Record<string, unknown>> = (ctx: ApprovalResponseContext<TInput>,) => ApprovalResponseDecision | Promise<ApprovalResponseDecision>;diff --git a/packages/eve/src/compiler/extension-compatibility.ts b/packages/eve/src/compiler/extension-compatibility.tsindex c54f93e22..1d3d6cacf 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: 62,- supported: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 29, 30, 31, 32, 34, 35, 54, 55, 61, 62],+ current: 63,+ supported: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 29, 30, 31, 32, 34, 35, 54, 55, 63],dropped: {14: "TaskExec.delegated was removed; migrate to workflow-backed background tools",15: "TaskExec replaces stageEffect with send",@@ -64,13 +64,15 @@ const EXTENSION_CAPABILITY_CONTRACTS = {58: "Workflow tools no longer accept execution or return background task receipts; every call blocks until it settles.",59: "Workflow tools no longer accept execution or return background task receipts, and every call blocks until it settles. ctx.ask() no longer accepts dismissible and reports a withdrawn request as cancelled, workflow tool contexts carry interruptSignal, and ctx.agent(name) returns a session handle whose send() delivers a message and whose result() resolves the turn; ctx.agent(name, { message, agentId }) and AgentInput were removed. A ctx.ask() question parks the open turn with turn.waiting instead of ending it.",60: "Workflow tools define exactly one of execute(input, ctx), task(input, ctx), or serve(receive, ctx): a task() call returns a receipt and runs as a task, a serve() call reaches a resumable task through receive() and its model input gains taskId, and stream events gained task.started and task.settled. Agent tools are serve() tools with taskId in place of agentId, and the subagent.* stream events were removed. ctx.interruptSignal and WorkflowTaskContext were removed: a steering message aborts the abortSignal of an execute call the turn waits on.",+ 61: "Approval response policies now run for Cancel as well as Approve; a policy written for Approve only could reject every Cancel.",+ 62: "Approval response policies now run for Cancel as well as Approve; a policy written for Approve only could reject every Cancel.",},},dynamicTool: {- current: 59,+ current: 60,supported: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 31, 32, 33, 52, 54,- 58, 59,+ 60,],dropped: {21: "Message and reasoning append events now expose deltas instead of cumulative snapshots.",@@ -104,6 +106,8 @@ const EXTENSION_CAPABILITY_CONTRACTS = {55: "Run mode was removed; sessions always park and ConversationContext no longer carries mode.",56: 'Background task execution was removed: subagent results no longer carry backgroundTask and message.completed always carries text. input.resolved reports outcome "cancelled" when a workflow tool withdraws a ctx.ask() request, and stream events gained agent.started, published when a workflow run opens a ctx.agent session, and turn.waiting, which parks the open turn instead of emitting turn.completed and session.waiting.',57: "Stream events gained task.started and task.settled, and input.requested, authorization events, and agent.started carry the taskId of the task they come from. The subagent.called, subagent.completed, subagent.started, and subagent.event stream events were removed; agent calls report task.started, task.settled, and agent.started.",+ 58: "Approval response policies now run for Cancel as well as Approve; a policy written for Approve only could reject every Cancel.",+ 59: "Approval response policies now run for Cancel as well as Approve; a policy written for Approve only could reject every Cancel.",},},channel: {@@ -152,10 +156,8 @@ const EXTENSION_CAPABILITY_CONTRACTS = {},},connection: {- current: 31,- supported: [- 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 26, 30, 31,- ],+ current: 32,+ supported: [1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 26, 32],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.",@@ -164,6 +166,8 @@ const EXTENSION_CAPABILITY_CONTRACTS = {27: "Run mode was removed; sessions always park and ConversationContext no longer carries mode.",28: 'Background task execution was removed: subagent results no longer carry backgroundTask and message.completed always carries text. input.resolved reports outcome "cancelled" when a workflow tool withdraws a ctx.ask() request, and stream events gained agent.started, published when a workflow run opens a ctx.agent session, and turn.waiting, which parks the open turn instead of emitting turn.completed and session.waiting.',29: "Stream events gained task.started and task.settled, and input.requested, authorization events, and agent.started carry the taskId of the task they come from. The subagent.called, subagent.completed, subagent.started, and subagent.event stream events were removed; agent calls report task.started, task.settled, and agent.started.",+ 30: "Approval response policies now run for Cancel as well as Approve; a policy written for Approve only could reject every Cancel.",+ 31: "Approval response policies now run for Cancel as well as Approve; a policy written for Approve only could reject every Cancel.",},},hook: {diff --git a/packages/eve/src/execution/session/turn-connection-approval.integration.test.ts b/packages/eve/src/execution/session/turn-connection-approval.integration.test.tsindex e4741a4c5..092560b02 100644--- a/packages/eve/src/execution/session/turn-connection-approval.integration.test.ts+++ b/packages/eve/src/execution/session/turn-connection-approval.integration.test.ts@@ -98,7 +98,7 @@ function setup(variation?: "destination" | "name" | "request-only",) {const response = vi.fn((context: ApprovalResponseContext) => {- expect(context.responder.principalId).toBe("bob");+ expect(context.response.principal.principalId).toBe("bob");expect(context.session.initiator?.principalId).toBe("alice");return reject? { status: "rejected" as const, reason: "Only the notes owner can approve." }diff --git a/packages/eve/src/harness/approval-candidates.test.ts b/packages/eve/src/harness/approval-candidates.test.tsindex 6edb8d782..7d1b2c340 100644--- a/packages/eve/src/harness/approval-candidates.test.ts+++ b/packages/eve/src/harness/approval-candidates.test.ts@@ -31,6 +31,7 @@ function create(input: {return createApprovalCandidate({candidateIdPrefix: input.candidateId,createdAt: 100,+ decision: "approve",expiresAt: 700,requestId: input.requestId ?? "request-1",responder: responder(input.principalId),@@ -47,6 +48,7 @@ describe("approval candidate state", () => {{candidateId: "candidate-1",createdAt: 100,+ decision: "approve",expiresAt: 700,requestId: "request-1",responder: {@@ -158,6 +160,7 @@ describe("approval candidate state", () => {const next = createApprovalCandidate({candidateIdPrefix: "candidate-2",createdAt: 800,+ decision: "approve",expiresAt: 1_400,requestId: "request-1",responder: responder("U2"),@@ -177,6 +180,7 @@ describe("approval candidate state", () => {const second = createApprovalCandidate({candidateIdPrefix: "candidate-2",createdAt: 100,+ decision: "approve",expiresAt: 900,requestId: "request-1",responder: responder("U2"),@@ -276,4 +280,22 @@ describe("approval candidate state", () => {expect.objectContaining({ candidateId: "candidate-2", requestId: "request-2" }),]);});++ it("reads a candidate persisted without a decision as an Approve", () => {+ const { decision: _decision, ...persisted } = getApprovalAuditState(+ create({ candidateId: "candidate-1", principalId: "U1" }).state,+ ).activeCandidates[0]!;+ const state: SessionStateMap = {+ "eve.runtime.hitl.approvalState": {+ activeCandidates: { "candidate-1": persisted },+ candidateHistory: [],+ nextCandidateSequence: 1,+ settlements: {},+ },+ };++ expect(getApprovalAuditState(state).activeCandidates[0]?.decision).toBe("approve");+ const settled = settleAllowedCandidate({ candidateId: "candidate-1", settledAt: 200, state });+ expect(getApprovalAuditState(settled.state).settlements[0]?.outcome).toBe("allowed");+ });});diff --git a/packages/eve/src/harness/approval-candidates.ts b/packages/eve/src/harness/approval-candidates.tsindex 6af62e42d..e0dcdef8a 100644--- a/packages/eve/src/harness/approval-candidates.ts+++ b/packages/eve/src/harness/approval-candidates.ts@@ -13,8 +13,12 @@ type ApprovalCandidateStatus =| "timed-out"| "stale";+/** What a responder submitted: a candidate settles its request this way once allowed. */+export type ApprovalCandidateDecision = "approve" | "cancel";+interface ApprovalCandidateAuditRecord {readonly candidateId: string;+ readonly decision: ApprovalCandidateDecision;readonly requestId: string;readonly responder: ApprovalResponderIdentity;readonly status: ApprovalCandidateStatus;@@ -43,6 +47,7 @@ export interface ApprovalSettlementAuditRecord {export interface ActiveApprovalCandidate {readonly candidateId: string;+ readonly decision: ApprovalCandidateDecision;readonly requestId: string;readonly responder: SessionAuthContext;readonly status: "pending" | "authorization-required";@@ -64,10 +69,11 @@ interface ApprovalStateTransition {readonly state: SessionStateMap | undefined;}-/** Creates or deduplicates one responder's Allow candidate for a pending request. */+/** Creates or deduplicates one responder's candidate decision for a pending request. */export function createApprovalCandidate(input: {readonly candidateIdPrefix: string;readonly createdAt: number;+ readonly decision: ApprovalCandidateDecision;readonly expiresAt: number;readonly requestId: string;readonly responder: SessionAuthContext;@@ -83,7 +89,9 @@ export function createApprovalCandidate(input: {const responder = input.responder;const duplicate = Object.values(approvalState.activeCandidates).find((candidate) =>- candidate.requestId === input.requestId && sameResponder(candidate.responder, responder),+ candidate.requestId === input.requestId &&+ candidate.decision === input.decision &&+ sameResponder(candidate.responder, responder),);if (duplicate !== undefined) {return { changed: false, state: expiredState };@@ -107,6 +115,7 @@ export function createApprovalCandidate(input: {const candidate: ActiveApprovalCandidate = {candidateId,createdAt: input.createdAt,+ decision: input.decision,expiresAt: input.expiresAt,requestId: input.requestId,responder,@@ -242,7 +251,10 @@ export function expireApprovalCandidates(input: {return state;}-/** Atomically settles an allowed candidate; every losing candidate becomes stale. */+/**+ * Atomically settles a request with an allowed candidate's decision; every+ * losing candidate becomes stale.+ */export function settleAllowedCandidate(input: {readonly candidateId: string;readonly settledAt: number;@@ -264,7 +276,7 @@ export function settleAllowedCandidate(input: {return settleRequest({actor: projectResponder(candidate.responder),candidateId: candidate.candidateId,- outcome: "allowed",+ outcome: candidate.decision === "cancel" ? "cancelled" : "allowed",requestId: candidate.requestId,settledAt: input.settledAt,state: expiredState,@@ -397,6 +409,22 @@ function sameResponder();}+/**+ * A candidate is an Approve unless it records Cancel: candidates persisted+ * before Cancel was authorized carry no decision, and their responder pressed+ * Approve.+ */+function readActiveCandidates(+ candidates: Readonly<Record<string, ActiveApprovalCandidate>>,+): Readonly<Record<string, ActiveApprovalCandidate>> {+ return Object.fromEntries(+ Object.entries(candidates).map(([candidateId, candidate]) => [+ candidateId,+ { ...candidate, decision: candidate.decision === "cancel" ? "cancel" : "approve" },+ ]),+ );+}+function readApprovalState(state: SessionStateMap | undefined): DurableApprovalState {const value = state?.[APPROVAL_STATE_KEY];if (typeof value !== "object" || value === null) {@@ -411,7 +439,7 @@ function readApprovalState(state: SessionStateMap | undefined): DurableApprovalSreturn {activeCandidates:typeof candidate.activeCandidates === "object" && candidate.activeCandidates !== null- ? candidate.activeCandidates+ ? readActiveCandidates(candidate.activeCandidates): {},candidateHistory: Array.isArray(candidate.candidateHistory) ? candidate.candidateHistory : [],nextCandidateSequence:diff --git a/packages/eve/src/harness/approval-delivery-coordinator.test.ts b/packages/eve/src/harness/approval-delivery-coordinator.test.tsindex 6d238c7dd..418bb5449 100644--- a/packages/eve/src/harness/approval-delivery-coordinator.test.ts+++ b/packages/eve/src/harness/approval-delivery-coordinator.test.ts@@ -76,13 +76,13 @@ describe("coordinateApprovalDelivery", () => {);}- async function ingest(session = parkedSession()) {+ async function ingest(session = parkedSession(), optionId = "approve") {return coordinateApprovalDelivery({now: 100,session,stepInput: {attributedInputResponses: [- { auth: responder, response: { requestId: request.requestId, optionId: "approve" } },+ { auth: responder, response: { requestId: request.requestId, optionId } },],},tools: new Map(),@@ -103,11 +103,57 @@ describe("coordinateApprovalDelivery", () => {expect(response).toHaveBeenCalledWith(expect.objectContaining({request: expect.objectContaining({ principal: requester }),- responder,+ response: { decision: "approve", principal: responder },}),);});+ it("authorizes Cancel, leaving a rejected Cancel pending for the requester", async () => {+ const requester: SessionAuthContext = { ...responder, principalId: "bob" };+ const ingested = await ingest(parkedBy(requester), "cancel");+ expect(ingested.kind).toBe("continue-coordination");++ const onlyRequester: ApprovalResponsePolicy = ({ request, response }) =>+ response.principal.principalId === request.principal?.principalId+ ? { status: "allowed" }+ : { reason: "Only the requester can respond.", status: "rejected" };+ const response = vi.fn(onlyRequester);+ const rejected = await authorize(ingested.session, response);+ expect(response).toHaveBeenCalledWith(+ expect.objectContaining({ response: { decision: "cancel", principal: responder } }),+ );+ expect(rejected.stepInput?.inputResponses ?? []).toEqual([]);+ expect(getApprovalAuditState(rejected.session.state).settlements).toEqual([]);+ expect(getPendingInputBatches(rejected.session.state)).toHaveLength(1);++ const requesterCancel = await coordinateApprovalDelivery({+ now: 102,+ session: rejected.session,+ stepInput: {+ attributedInputResponses: [+ { auth: requester, response: { optionId: "cancel", requestId: request.requestId } },+ ],+ },+ tools: new Map(),+ });+ const settled = await authorize(requesterCancel.session, onlyRequester);+ expect(settled.stepInput?.inputResponses).toEqual([+ { optionId: "cancel", requestId: request.requestId },+ ]);+ });++ it("authorizes ACP's Deny as a Cancel", async () => {+ const ingested = await ingest(parkedSession(), "deny");+ const response = vi.fn<ApprovalResponsePolicy>(() => ({ status: "allowed" }));+ const settled = await authorize(ingested.session, response);+ expect(response).toHaveBeenCalledWith(+ expect.objectContaining({ response: { decision: "cancel", principal: responder } }),+ );+ expect(settled.stepInput?.inputResponses).toEqual([+ { optionId: "cancel", requestId: request.requestId },+ ]);+ });+it("records no requester for an anonymous caller", async () => {const anonymous: SessionAuthContext = {attributes: {},diff --git a/packages/eve/src/harness/approval-delivery-coordinator.ts b/packages/eve/src/harness/approval-delivery-coordinator.tsindex 2f3d42768..29f91815c 100644--- a/packages/eve/src/harness/approval-delivery-coordinator.ts+++ b/packages/eve/src/harness/approval-delivery-coordinator.ts@@ -16,6 +16,7 @@ import {settleAllowedCandidate,settleDirectApprovalResponse,type ActiveApprovalCandidate,+ type ApprovalCandidateDecision,type ApprovalSettlementAuditRecord,} from "#harness/approval-candidates.js";import {@@ -52,17 +53,16 @@ interface ApprovalDeliveryResult {** | State | Input | Transition |* | --- | --- | --- |- * | pending request | Approve | create responder-bound candidate |- * | pending request | Cancel | settle cancelled and stale candidates |+ * | pending request | Approve or Cancel | create responder-bound candidate |* | pending candidate | coordinator pass | run current authorizer |- * | pending candidate | allowed | settle approved and stale competitors |+ * | pending candidate | allowed | settle with its decision; competitors go stale |* | pending candidate | rejected/error/expiry | append terminal history |* | pending candidate | authorization required | persist private challenge |* | authorization required | matching callback | re-run current authorizer |* | settled request | any later response | no state change |*- * Delivery ingestion returns before authorizer work so Cancel and candidate- * creation commit before long-running policy execution. Candidate results also+ * Delivery ingestion returns before authorizer work so candidate creation+ * commits before long-running policy execution. Candidate results also* commit before lifecycle events are projected by the next stack layer.*/export async function coordinateApprovalDelivery(input: {@@ -143,13 +143,11 @@ export async function coordinateApprovalDelivery(input: {attributedResponder !== undefined? attributedResponder: (context?.get(AuthKey) ?? context?.get(SessionKey)?.auth.current ?? null);- if (- responder !== null &&- (response.optionId === "approve" || response.optionId === "cancel")- ) {+ const decision = toCandidateDecision(response.optionId);+ if (responder !== null && decision !== undefined) {const settled = settleDirectApprovalResponse({actor: responder,- outcome: response.optionId === "approve" ? "allowed" : "cancelled",+ outcome: decision === "approve" ? "allowed" : "cancelled",requestId: response.requestId,settledAt: now,state: session.state,@@ -161,28 +159,10 @@ export async function coordinateApprovalDelivery(input: {}consumed.add(response.requestId);- if (response.optionId === "cancel") {- const responder =- attributedResponder !== undefined- ? attributedResponder- : buildCallbackContext().session.auth.current;- if (responder === null) {- feedback.push(UNAUTHENTICATED_APPROVAL_FEEDBACK);- continue;- }- const settled = settleDirectApprovalResponse({- actor: responder,- outcome: "cancelled",- requestId: response.requestId,- settledAt: now,- state: session.state,- });- session = { ...session, state: settled.state };- didCommit ||= settled.changed;- continue;- }-- if (response.optionId !== "approve") continue;+ // A response policy decides Cancel as well as Approve, so a responder it+ // rejects can neither approve nor cancel someone else's request.+ const decision = toCandidateDecision(response.optionId);+ if (decision === undefined) continue;const responder =attributedResponder !== undefined? attributedResponder@@ -193,8 +173,9 @@ export async function coordinateApprovalDelivery(input: {}const created = createApprovalCandidate({- candidateIdPrefix: approvalCandidateIdPrefix(request.requestId, responder),+ candidateIdPrefix: approvalCandidateIdPrefix(request.requestId, responder, decision),createdAt: now,+ decision,expiresAt: now + APPROVAL_CANDIDATE_TTL_MS,requestId: request.requestId,responder,@@ -246,6 +227,7 @@ export async function coordinateApprovalDelivery(input: {}const processed = await authorizeCandidate({candidateId: candidate.candidateId,+ decision: candidate.decision,now,request,responder: candidate.responder,@@ -285,6 +267,7 @@ export async function coordinateApprovalDelivery(input: {async function authorizeCandidate(input: {readonly candidateId: string;+ readonly decision: ApprovalCandidateDecision;readonly now: number;readonly request: InputRequest;readonly responder: ActiveApprovalCandidate["responder"];@@ -330,8 +313,7 @@ async function authorizeCandidate(input: {toolInput: input.request.action.input,toolName: input.request.action.toolName,},- response: { decision: "approve" },- responder: input.responder,+ response: { decision: input.decision, principal: input.responder },session: {id: context.session.id,initiator: context.session.auth.initiator,@@ -410,7 +392,7 @@ function failCandidate(input: {readonly didCommit: true;readonly session: HarnessSession;} {- const reason = input.reason ?? "We couldn’t verify your approval. Please try again.";+ const reason = input.reason ?? "We couldn’t verify your response. Please try again.";return {challenges: [],didCommit: true,@@ -502,14 +484,27 @@ function deliveryResult(return { challenges, feedback, kind, session, stepInput };}-function approvalCandidateIdPrefix(requestId: string, responder: SessionAuthContext): string {+function toCandidateDecision(optionId: string | undefined): ApprovalCandidateDecision | undefined {+ if (optionId === "approve") return "approve";+ // ACP's Deny button sends "deny" where eve's own prompts send "cancel".+ if (optionId === "cancel" || optionId === "deny") return "cancel";+ return undefined;+}++function approvalCandidateIdPrefix(+ requestId: string,+ responder: SessionAuthContext,+ decision: ApprovalCandidateDecision,+): string {const principal = [responder.authenticator,responder.issuer ?? "",responder.principalType,responder.principalId,].join(":");- return `${encodeCandidateIdPart(requestId)}.${encodeCandidateIdPart(principal)}`;+ const prefix = `${encodeCandidateIdPart(requestId)}.${encodeCandidateIdPart(principal)}`;+ // Approve keeps its established id; Cancel needs its own so both can be pending.+ return decision === "approve" ? prefix : `${prefix}.${encodeCandidateIdPart(decision)}`;}function encodeCandidateIdPart(value: string): string {diff --git a/packages/eve/src/harness/tool-loop.test.ts b/packages/eve/src/harness/tool-loop.test.tsindex 23326d443..2a4d76b4c 100644--- a/packages/eve/src/harness/tool-loop.test.ts+++ b/packages/eve/src/harness/tool-loop.test.ts@@ -69,7 +69,7 @@ import {hasPendingInputBatch,appendPendingInputBatch,} from "#harness/input-requests.js";-import { getDeferredStepInput } from "#harness/pending-input-batches.js";+import { getDeferredStepInput, getPendingInputBatches } from "#harness/pending-input-batches.js";import { getPendingCoordinationBatch, pendingCoordinationCallIds } from "#harness/coordination.js";import { PendingSkillAnnouncementKey } from "#context/dynamic-skill-lifecycle.js";import { deserializeContext, serializeContext } from "#context/serialize.js";@@ -306,6 +306,65 @@ function createTestConfig(};}+function mockApprovalAlongsideWorkflowTask(): void {+ const gateToolCall = {+ input: { action: "run" },+ toolCallId: "gate-1",+ toolName: "add",+ type: "tool-call" as const,+ };+ const delegateToolCall = {+ input: { message: "probe" },+ toolCallId: "delegate-1",+ toolName: "delegate",+ type: "tool-call" as const,+ };+ setupMockAgent({+ content: [+ gateToolCall,+ { approvalId: "approval-gate", toolCallId: "gate-1", type: "tool-approval-request" },+ delegateToolCall,+ ],+ finishReason: "tool-calls",+ response: {+ messages: [+ {+ content: [+ gateToolCall,+ { approvalId: "approval-gate", toolCallId: "gate-1", type: "tool-approval-request" },+ delegateToolCall,+ ],+ role: "assistant",+ },+ ],+ },+ responseMessages: [+ {+ content: [+ {+ output: { type: "text", value: "/workspace" },+ toolCallId: "call-1",+ toolName: "bash",+ type: "tool-result",+ },+ ],+ role: "tool",+ },+ {+ content: [+ gateToolCall,+ { approvalId: "approval-gate", toolCallId: "gate-1", type: "tool-approval-request" },+ delegateToolCall,+ ],+ role: "assistant",+ },+ ],+ text: "",+ toolCalls: [gateToolCall, delegateToolCall],+ toolResults: [],+ });+}+function createDelegationToolMap(): ToolLoopHarnessConfig["tools"] {return new Map([[@@ -1444,64 +1503,29 @@ describe("createToolLoopHarness", () => {]);});- it("parks on both batches when one step carries a workflow task and an approval", async () => {- const gateToolCall = {- input: { action: "run" },- toolCallId: "gate-1",- toolName: "add",- type: "tool-call" as const,- };- const delegateToolCall = {- input: { message: "probe" },- toolCallId: "delegate-1",- toolName: "delegate",- type: "tool-call" as const,- };- setupMockAgent({- content: [- gateToolCall,- { approvalId: "approval-gate", toolCallId: "gate-1", type: "tool-approval-request" },- delegateToolCall,- ],- finishReason: "tool-calls",- response: {- messages: [- {- content: [- gateToolCall,- { approvalId: "approval-gate", toolCallId: "gate-1", type: "tool-approval-request" },- delegateToolCall,- ],- role: "assistant",- },- ],- },- responseMessages: [- {- content: [- {- output: { type: "text", value: "/workspace" },- toolCallId: "call-1",- toolName: "bash",- type: "tool-result",- },- ],- role: "tool",- },- {- content: [- gateToolCall,- { approvalId: "approval-gate", toolCallId: "gate-1", type: "tool-approval-request" },- delegateToolCall,- ],- role: "assistant",- },- ],- text: "",- toolCalls: [gateToolCall, delegateToolCall],- toolResults: [],+ it("records a response policy for an approval parked alongside a workflow task", async () => {+ mockApprovalAlongsideWorkflowTask();+ const delegation = createDelegationToolMap();+ const tools = new Map(delegation);+ tools.set("add", {+ ...delegation.get("add")!,+ approval: { request: () => "user-approval", response: () => ({ status: "allowed" }) },+ });+ const runStep = createToolLoopHarness(createTestConfig(undefined, { tools }));++ const parked = await runStep(createPendingBashApprovalSession(), {+ inputResponses: [{ optionId: "approve", requestId: "approval-1" }],});+ expect(getPendingCoordinationBatch(parked.session.state)).toBeDefined();+ expect(getPendingInputBatches(parked.session.state)).toEqual([+ expect.objectContaining({ responseAuthRequiredRequestIds: ["approval-gate"] }),+ ]);+ });++ it("parks on both batches when one step carries a workflow task and an approval", async () => {+ mockApprovalAlongsideWorkflowTask();+const { emit, events } = createEventCollector();const runStep = createToolLoopHarness(createTestConfig(emit, { tools: createDelegationToolMap() }),diff --git a/packages/eve/src/harness/tool-loop.ts b/packages/eve/src/harness/tool-loop.tsindex 0430c9296..e89fc86ce 100644--- a/packages/eve/src/harness/tool-loop.ts+++ b/packages/eve/src/harness/tool-loop.ts@@ -2664,6 +2664,7 @@ async function handleStepResult(input: {},requests: inputRequests,toolReplayIdentities: captureToolReplayIdentities(config, approvalRequests),+ responseAuthRequiredRequestIds: responsePolicyRequestIds(config, approvalRequests),responseMessages: [],session: parkedSession,});@@ -2688,10 +2689,6 @@ async function handleStepResult(input: {// --- Park on input requests -----------------------------------------------if (inputRequests.length > 0) {- const responseAuthorizationTools = buildResponseAuthorizationTools({- authoredTools: config.tools,- context: contextStorage.getStore(),- });let parkedSession = appendPendingInputBatch({event: {sequence: emissionState.sequence,@@ -2700,16 +2697,7 @@ async function handleStepResult(input: {},requests: inputRequests,toolReplayIdentities: captureToolReplayIdentities(config, approvalRequests),- responseAuthRequiredRequestIds: approvalRequests- .filter((request) => {- const approval = responseAuthorizationTools.get(request.action.toolName)?.approval;- return (- approval !== undefined &&- typeof approval !== "function" &&- approval.response !== undefined- );- })- .map((request) => request.requestId),+ responseAuthRequiredRequestIds: responsePolicyRequestIds(config, approvalRequests),responseMessages: pendingResponseMessages,session: { ...baseSession, history: parkedInputHistory },});@@ -3250,6 +3238,28 @@ function captureToolReplayIdentities(return identities.length === 0 ? undefined : Object.fromEntries(identities);}+/**+ * The approvals whose tool defines a response policy. Every park path records+ * them, so no Approve or Cancel of such an approval skips the policy.+ */+function responsePolicyRequestIds(+ config: ToolLoopHarnessConfig,+ requests: readonly InputRequest[],+): readonly string[] {+ const tools = buildResponseAuthorizationTools({+ authoredTools: config.tools,+ context: contextStorage.getStore(),+ });+ return requests+ .filter((request) => {+ const approval = tools.get(request.action.toolName)?.approval;+ return (+ approval !== undefined && typeof approval !== "function" && approval.response !== undefined+ );+ })+ .map((request) => request.requestId);+}+function resolveApprovalKeyFromTools(tools: HarnessToolMap,): (request: InputRequest) => string | undefined {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.tsindex f1bd570e9..add91f97a 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@@ -146,7 +146,7 @@ export default defineDynamic({return ctx.toolInput.force ? { type: "user-approval", reason: requestReason } : "not-applicable";},response(ctx) {- return ctx.responder.principalId === allowedResponder+ return ctx.response.principal.principalId === allowedResponder? { status: "allowed" }: { status: "rejected", reason: "wrong responder" };},diff --git a/packages/eve/src/public/channels/slack/defaults.test.ts b/packages/eve/src/public/channels/slack/defaults.test.tsindex 7c15ce01c..93ad6d27a 100644--- a/packages/eve/src/public/channels/slack/defaults.test.ts+++ b/packages/eve/src/public/channels/slack/defaults.test.ts@@ -324,7 +324,7 @@ describe("defaultEvents approval lifecycle", () => {expect(postEphemeral).toHaveBeenCalledWith("U777",- "Checking whether you can approve this action…",+ "Checking whether you can respond to this approval…",);});@@ -356,7 +356,7 @@ describe("defaultEvents approval lifecycle", () => {expect(postEphemeral).toHaveBeenCalledWith("U777",- "Checking whether you can approve this action…",+ "Checking whether you can respond to this approval…",);expect(channel.state.pendingApprovalCandidateUsers).toEqual({ "candidate-1": "U777" });});diff --git a/packages/eve/src/public/channels/slack/defaults.ts b/packages/eve/src/public/channels/slack/defaults.tsindex 735983578..fc1cd45a0 100644--- a/packages/eve/src/public/channels/slack/defaults.ts+++ b/packages/eve/src/public/channels/slack/defaults.ts@@ -365,14 +365,17 @@ export const defaultEvents: SlackChannelInternalEvents = {async "approval.candidate"(event, channel, _ctx) {const userId = channel.state.pendingApprovalCandidateUsers?.[event.candidateId];if (event.outcome === "pending" && userId !== undefined) {- await channel.thread.postEphemeral(userId, "Checking whether you can approve this action…");+ await channel.thread.postEphemeral(+ userId,+ "Checking whether you can respond to this approval…",+ );return;}if (userId === undefined) return;if (event.outcome === "rejected" || event.outcome === "failed") {await channel.thread.postEphemeral(userId,- event.reason ?? "We couldn’t verify your approval. Please try again.",+ event.reason ?? "We couldn’t verify your response. Please try again.",);}},diff --git a/packages/eve/src/public/channels/slack/slackChannel.test.ts b/packages/eve/src/public/channels/slack/slackChannel.test.tsindex 4f6607c0f..62a97b37d 100644--- a/packages/eve/src/public/channels/slack/slackChannel.test.ts+++ b/packages/eve/src/public/channels/slack/slackChannel.test.ts@@ -3868,7 +3868,7 @@ describe("slackChannel() HITL interaction pipeline", () => {expect(ephemeralBodies).toEqual([expect.objectContaining({channel: "C01",- markdown_text: "Checking whether you can approve this action…",+ markdown_text: "Checking whether you can respond to this approval…",user: "U_APPROVER",}),expect.objectContaining({