Fix agent model fallback and title/branch tool parsing

This commit is contained in:
Mohamed Boudra
2026-01-23 10:14:46 +07:00
parent 53155ebcc9
commit f8ba0ff239
3 changed files with 11 additions and 2 deletions

View File

@@ -11,12 +11,12 @@ describe("extractAgentModel", () => {
expect(extractAgentModel(agent)).toBe("gpt-5.2-codex");
});
it("returns null when runtime model missing even if config model is set", () => {
it("returns configured model when runtime model is missing", () => {
const agent = {
model: "gpt-5.1-codex",
runtimeInfo: {},
} as Partial<Agent> as Agent;
expect(extractAgentModel(agent)).toBeNull();
expect(extractAgentModel(agent)).toBe("gpt-5.1-codex");
});
});

View File

@@ -1161,6 +1161,12 @@ const TOOL_NAME_MAP: Record<string, string> = {
Bash: "Shell",
read_file: "Read",
apply_patch: "Edit",
"agent-control.set_title": "Set title",
"agent-control.set_branch": "Set branch",
set_title: "Set title",
set_branch: "Set branch",
"mcp__agent-control__set_title": "Set title",
"mcp__agent-control__set_branch": "Set branch",
};
const ToolCallDisplaySchema = z

View File

@@ -22,6 +22,9 @@ const PrincipalParamSchema = z.union([
// Command as array (Codex sends this)
z.object({ command: z.array(z.string()).nonempty() }).transform((d) => ({ type: "command" as const, value: d.command.join(" ") })),
// Other text params
z.object({ title: z.string() }).transform((d) => ({ type: "text" as const, value: d.title })),
z.object({ name: z.string() }).transform((d) => ({ type: "text" as const, value: d.name })),
z.object({ branch: z.string() }).transform((d) => ({ type: "text" as const, value: d.branch })),
z.object({ pattern: z.string() }).transform((d) => ({ type: "text" as const, value: d.pattern })),
z.object({ query: z.string() }).transform((d) => ({ type: "text" as const, value: d.query })),
z.object({ url: z.string() }).transform((d) => ({ type: "text" as const, value: d.url })),