Skip to content

Commit caa6e53

Browse files
committed
fix(approvals): keep pi tool names and reasons out of tool lookup
1 parent 47a19c1 commit caa6e53

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

‎packages/client-runtime/src/work-log/presentation.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ function workEntryToolName(
118118
): string | undefined {
119119
const item = entry.structuredPayload;
120120
if (item?.type === "dynamic_tool" && item.toolName) return item.toolName;
121+
// A command approval's label is the agent's free-text reason, never a tool name.
122+
if (item?.type === "approval_request" && item.requestKind === "command") return undefined;
121123
const data = asRecord(entry.toolData);
122124
if (typeof data?.server === "string" && typeof data.tool === "string") {
123125
return `${data.server}.${data.tool}`;

‎packages/provider-pi/src/server/adapter.ts‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -398,10 +398,8 @@ interface PendingPiPrompt {
398398
readonly turnItem: OrchestrationV2TurnItem;
399399
}
400400

401-
const PI_TOOL_GATE_TITLE = /^Allow (\S+)\?$/;
402-
403401
function piApprovalRequestKind(title: string): "command" | "file-change" {
404-
const toolName = PI_TOOL_GATE_TITLE.exec(title)?.[1];
402+
const toolName = /^Allow (\S+)\?$/.exec(title)?.[1];
405403
return toolName !== undefined &&
406404
(PI_FILE_CHANGE_TOOLS as ReadonlyArray<string>).includes(toolName)
407405
? "file-change"
@@ -1326,8 +1324,8 @@ export const makePiAdapterV2 = Effect.fn("makePiAdapterV2")(function* (
13261324
method === "confirm"
13271325
? {
13281326
...itemBase,
1329-
// The tool gate's "Allow bash?" restates the card; other confirms keep their question.
1330-
title: PI_TOOL_GATE_TITLE.test(title) ? null : title,
1327+
// The bash gate's prompt is the command itself; other tools need their name.
1328+
title: title === "Allow bash?" ? null : title,
13311329
type: "approval_request",
13321330
requestId,
13331331
requestKind: piApprovalRequestKind(title),

0 commit comments

Comments
 (0)