fix: report EnterPlanMode tool calls with the switch_mode kind (#1467)

Stacked on #1457 (SDK 2.1.0).

EnterPlanMode tool calls now use `kind: "switch_mode"`, like
ExitPlanMode (agentclientprotocol/agent-client-protocol#2543). The title
is unchanged.
This commit is contained in:
Ben Brandt
2026-10-28 13:40:19 +01:00
committed by GitHub
parent f646c821f1
commit 93c1f43519
3 changed files with 21 additions and 0 deletions

View File

@@ -2448,6 +2448,18 @@ describe("toolInfoFromToolUse - ExitPlanMode", () => {
});
});
describe("toolInfoFromToolUse - EnterPlanMode", () => {
it("reports a mode switch", () => {
const info = toolInfoFromToolUse(
{ name: "EnterPlanMode", id: "toolu_enter", input: {} },
false,
);
expect(info.kind).toBe("switch_mode");
expect(info.title).toBe("EnterPlanMode");
});
});
describe("toolInfoFromToolUse - Write input aliases", () => {
it.each([
["path + file_text", { path: "/repo/a.ts", file_text: "x" }],

View File

@@ -5,6 +5,7 @@ import { EditReporter, NotebookEditReporter, WriteReporter } from "./file-edit.j
import {
AgentControlReporter,
AskUserQuestionReporter,
EnterPlanModeReporter,
ExitPlanModeReporter,
GenericReporter,
PlanToolReporter,
@@ -35,6 +36,7 @@ const reporters: Record<string, ToolReporter> = {
TaskList: new PlanToolReporter("TaskList"),
TaskGet: new PlanToolReporter("TaskGet"),
ReportFindings: new ReportFindingsReporter(),
EnterPlanMode: new EnterPlanModeReporter(),
ExitPlanMode: new ExitPlanModeReporter(),
AskUserQuestion: new AskUserQuestionReporter(),
Skill: new SkillReporter(),

View File

@@ -72,6 +72,13 @@ export class ExitPlanModeReporter implements ToolReporter {
}
}
/** EnterPlanMode switches the session to plan mode, so it has the `switch_mode` kind like ExitPlanMode. */
export class EnterPlanModeReporter implements ToolReporter {
toolUse(): ToolUseFacts {
return { title: "EnterPlanMode", kind: "switch_mode" };
}
}
/** The plan file of a result: the path of the input, else the `filePath` of the structured result. */
function resultPlanFile({ toolUse, structured, capabilities }: ToolResultContext) {
if (!capabilities.air.planFile) return undefined;