Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

[2/3] fix(eve): display tool approval prompt rather than tool name in TUI (#4228)

Ben Pankowf7b07c188e1c
diff --git a/.changeset/tui-approval-prompt.md b/.changeset/tui-approval-prompt.md
new file mode 100644
index 000000000..eec9b0c96
--- /dev/null
+++ b/.changeset/tui-approval-prompt.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+The `eve dev` TUI's approval drawer now asks the approval's own prompt, such as `Approve Deploy release?`, instead of `Approve deploy_release?` built from the raw tool name. It now matches what channels and the web client show.
diff --git a/packages/eve/src/cli/dev/tui/runner.ts b/packages/eve/src/cli/dev/tui/runner.ts
index ee5d626f2..033d50e7b 100644
--- a/packages/eve/src/cli/dev/tui/runner.ts
+++ b/packages/eve/src/cli/dev/tui/runner.ts
@@ -144,7 +144,8 @@ export type AgentTUIToolApprovalRequest = {
approvalId: string;
toolCallId: string;
toolName: string;
- title?: string;
+ /** The server's question for this approval, such as `Approve Deploy release?`. */
+ prompt: string;
input: unknown;
context?: AgentTUIInputContext;
};
@@ -1699,6 +1700,7 @@ function toAgentTUIToolApprovalRequest(
approvalId: request.requestId,
toolCallId: request.action.callId,
toolName: request.action.toolName,
+ prompt: request.prompt,
input: request.action.input,
};
if (context !== undefined) approval.context = context;
diff --git a/packages/eve/src/cli/dev/tui/terminal-renderer.test.ts b/packages/eve/src/cli/dev/tui/terminal-renderer.test.ts
index 9f40acfaa..b20091ce7 100644
--- a/packages/eve/src/cli/dev/tui/terminal-renderer.test.ts
+++ b/packages/eve/src/cli/dev/tui/terminal-renderer.test.ts
@@ -1838,6 +1838,7 @@ describe("TerminalRenderer (inline scrollback)", () => {
approvalId: "a1",
toolCallId: "c1",
toolName: "random_color",
+ prompt: "Approve random_color?",
input: {},
});
@@ -1869,6 +1870,7 @@ describe("TerminalRenderer (inline scrollback)", () => {
approvalId: "a2",
toolCallId: "c2",
toolName: "random_number",
+ prompt: "Approve random_number?",
input: {},
context: { position: { index: 2, total: 10 }, requester: "subagent(number_picker:13)" },
});
@@ -1887,6 +1889,7 @@ describe("TerminalRenderer (inline scrollback)", () => {
approvalId: "a1",
toolCallId: "c1",
toolName: "random_color",
+ prompt: "Approve random_color?",
input: {},
});
expect(screen.snapshot()).toContain("Approve random_color?");
@@ -1910,6 +1913,7 @@ describe("TerminalRenderer (inline scrollback)", () => {
approvalId: "a1",
toolCallId: "c1",
toolName: "read_file",
+ prompt: "Approve read_file?",
input: { path: "README.md" },
});
input.type("y");
@@ -1931,6 +1935,7 @@ describe("TerminalRenderer (inline scrollback)", () => {
approvalId: "a2",
toolCallId: "c2",
toolName: "write_file",
+ prompt: "Approve write_file?",
input: { path: "README.md" },
});
const approvalOutputLength = screen.rawOutput().length;
@@ -1950,6 +1955,7 @@ describe("TerminalRenderer (inline scrollback)", () => {
approvalId: "a1",
toolCallId: "c1",
toolName: "delete_files",
+ prompt: "Approve delete_files?",
input: { path: "/" },
});
@@ -1968,6 +1974,7 @@ describe("TerminalRenderer (inline scrollback)", () => {
approvalId: "a1",
toolCallId: "c1",
toolName: "delete_files",
+ prompt: "Approve delete_files?",
input: { path: "/" },
});
@@ -3857,6 +3864,7 @@ describe("TerminalRenderer conversation", () => {
approvalId: "approval_1",
toolCallId: "child_tool",
toolName: "wait_random_number",
+ prompt: "Approve wait_random_number?",
input: {},
});
expect(screen.snapshot()).toContain("Approve wait_random_number?");
diff --git a/packages/eve/src/cli/dev/tui/terminal-renderer.ts b/packages/eve/src/cli/dev/tui/terminal-renderer.ts
index 50ad0ea87..accd81fe6 100644
--- a/packages/eve/src/cli/dev/tui/terminal-renderer.ts
+++ b/packages/eve/src/cli/dev/tui/terminal-renderer.ts
@@ -1110,7 +1110,7 @@ export class TerminalRenderer implements AgentTUIRenderer {
this.#hitlDrawer = (width) =>
renderTransientDrawer(
[
- ` ${this.#theme.colors.bold(`Approve ${formatToolApprovalTitle(request)}?`)}`,
+ ` ${this.#theme.colors.bold(stripTerminalControls(request.prompt))}`,
"",
...renderQuestionChoices(
[
@@ -4455,10 +4455,6 @@ function hiddenRowsMarker(hidden: number, theme: Theme): string {
);
}
-function formatToolApprovalTitle(request: AgentTUIToolApprovalRequest): string {
- return stripTerminalControls(request.title ?? request.toolName);
-}
-
function questionSectionId(requestId: string): string {
return `question:${requestId}`;
}
diff --git a/packages/eve/src/internal/testing/channel-conformance/conformance.ts b/packages/eve/src/internal/testing/channel-conformance/conformance.ts
index c588d06a9..a7dd9efa4 100644
--- a/packages/eve/src/internal/testing/channel-conformance/conformance.ts
+++ b/packages/eve/src/internal/testing/channel-conformance/conformance.ts
@@ -36,11 +36,6 @@ interface ConformanceChannel {
const TUI_TYPED_APPROVAL =
"the approval drawer holds the keyboard; a person answers it with y or n";
-const TUI_APPROVAL_PROMPT: BrokenCell = {
- reason: "the approval drawer titles the raw tool name instead of the request's prompt",
- symptom: /Timed out waiting for the question "Approve Deploy release\?" on tui/,
-};
-
/**
* Every first-party channel's and client's place in the HITL contract, keyed by
* the directory whose `hitl-conformance.integration.test.ts` runs it. Each cell is
@@ -65,11 +60,6 @@ const hitlConformance = {
tui: [
{
driver: tuiDriver,
- broken: {
- "a tool approval shows a choice to approve and one to cancel": TUI_APPROVAL_PROMPT,
- "pressing Approve runs the gated tool": TUI_APPROVAL_PROMPT,
- "pressing Cancel stops the gated tool without running it": TUI_APPROVAL_PROMPT,
- },
unsupported: {
"a text reply of approve runs the gated tool": TUI_TYPED_APPROVAL,
"a text reply of cancel stops the gated tool without running it": TUI_TYPED_APPROVAL,
diff --git a/packages/eve/test/tui-client/tui-subagents-weather.ts b/packages/eve/test/tui-client/tui-subagents-weather.ts
index 71342e5b4..e797d8e69 100644
--- a/packages/eve/test/tui-client/tui-subagents-weather.ts
+++ b/packages/eve/test/tui-client/tui-subagents-weather.ts
@@ -80,16 +80,11 @@ run(WEATHER_SMOKE_TARGET, async (target) => {
// The task panel names the approval the child waits on, and the TUI
// parks on a y/n prompt. Match the question smoke's handshake delay so
// the server's resume hook is registered before we reply.
- await waitForCondition(
- () =>
- screen.snapshot().includes("Approve get_stock_price?") ||
- screen.snapshot().includes("Approve get stock price?"),
- {
- timeoutMs: 120_000,
- label: "approval prompt for get_stock_price",
- onTimeout: () => screen.snapshot(),
- },
- );
+ await waitForCondition(() => screen.snapshot().includes("Approve Get stock price?"), {
+ timeoutMs: 120_000,
+ label: "approval prompt for get_stock_price",
+ onTimeout: () => screen.snapshot(),
+ });
await sleep(500);
input.emit("data", Buffer.from("y"));
console.log(theme.muted("[tui-weather] approved get_stock_price"));