Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

fix(eve): pass a denied approval's note to the model (#4478)

roboeve[bot]fcbd47937387
diff --git a/.changeset/approval-denial-note.md b/.changeset/approval-denial-note.md
new file mode 100644
index 000000000..5f662d9be
--- /dev/null
+++ b/.changeset/approval-denial-note.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+A denied tool approval that carries `text` now passes that note to the model in the denial reason instead of dropping it.
diff --git a/docs/tools/human-in-the-loop.md b/docs/tools/human-in-the-loop.md
index 84b095dbd..6017f5f16 100644
--- a/docs/tools/human-in-the-loop.md
+++ b/docs/tools/human-in-the-loop.md
@@ -219,6 +219,8 @@ Approvals and questions share one protocol:
3. The run parks durably, for as long as it takes. The turn stays open: the stream emits `turn.waiting`, and after the answer the turn resumes under the same `turnId`. That `turn.waiting` carries `on: "input"`, since a person must act.
4. The client answers with `inputResponses` (structured, keyed by `requestId`) or a normal follow-up `message`. A follow-up whose text matches an option ID, option label, or numeric option index resolves automatically, including approval options such as `approve` and `cancel`.
+To tell the model why a call was denied, send `text` with the `cancel` response, for example `{ requestId, optionId: "cancel", text: "Only the three-pack." }`. The model receives the note quoted in the denial result, marked as written by the person who denied the call, who may not be the user. The note is also visible to anyone who can read the session stream, in `input.resolved`.
+
For `ctx.ask()` questions from tools and prompts proxied from subagents, a follow-up message answers the first open request, as described in [Several requests at once](#several-requests-at-once). The message must match an option, or the question must allow free text. Otherwise the message follows the session's `turnPolicy`. A steering message, the default, aborts the `ctx.abortSignal` of each `execute` workflow tool call the turn waits on, so a question such a call asked, such as `ask_question`'s, is withdrawn and resolves as `cancelled`. The model reads the message once those calls settle.
Each request includes a `kind` discriminator: `tool-approval`, `question`, or
diff --git a/packages/eve/src/harness/input-request-resolution.test.ts b/packages/eve/src/harness/input-request-resolution.test.ts
index 3b53023ad..cbee87e84 100644
--- a/packages/eve/src/harness/input-request-resolution.test.ts
+++ b/packages/eve/src/harness/input-request-resolution.test.ts
@@ -1,6 +1,34 @@
import { describe, expect, it } from "vitest";
-import { unavailableToolMessage } from "#harness/input-request-resolution.js";
+import {
+ resolveApprovalOutcome,
+ TOOL_EXECUTION_DENIED_MESSAGE,
+ unavailableToolMessage,
+} from "#harness/input-request-resolution.js";
+
+describe("resolveApprovalOutcome", () => {
+ it.each(["cancel", "deny"])("keeps the note sent with a %s as the denial reason", (optionId) => {
+ expect(
+ resolveApprovalOutcome({
+ optionId,
+ requestId: "req-1",
+ text: " only the three-pack, with a $50 minimum ",
+ }),
+ ).toEqual({
+ approved: false,
+ reason: `${TOOL_EXECUTION_DENIED_MESSAGE} The person who denied it wrote: "only the three-pack, with a $50 minimum"`,
+ status: "denied",
+ });
+ });
+
+ it.each([undefined, "", " "])("uses the bare denial when the note is %j", (text) => {
+ expect(resolveApprovalOutcome({ optionId: "cancel", requestId: "req-1", text })).toEqual({
+ approved: false,
+ reason: TOOL_EXECUTION_DENIED_MESSAGE,
+ status: "denied",
+ });
+ });
+});
describe("unavailableToolMessage", () => {
it("points at eve__search only for an agent that has it", () => {
diff --git a/packages/eve/src/harness/input-request-resolution.ts b/packages/eve/src/harness/input-request-resolution.ts
index 17e8c66e3..ec4e32f85 100644
--- a/packages/eve/src/harness/input-request-resolution.ts
+++ b/packages/eve/src/harness/input-request-resolution.ts
@@ -54,9 +54,13 @@ export function resolveApprovalOutcome(response: InputResponse | undefined): {
// ACP uses "deny" while harness-owned approval prompts use "cancel".
if (response.optionId === "cancel" || response.optionId === "deny") {
+ const note = response.text?.trim();
return {
approved: false,
- reason: TOOL_EXECUTION_DENIED_MESSAGE,
+ // The responder may be an approver other than the user, so the note is quoted, not merged.
+ reason: note
+ ? `${TOOL_EXECUTION_DENIED_MESSAGE} The person who denied it wrote: ${JSON.stringify(note)}`
+ : TOOL_EXECUTION_DENIED_MESSAGE,
status: "denied",
};
}