fix(agents): re-apply GPT apply_patch deny after config override merge

This commit is contained in:
YeonGyu-Kim
2026-04-10 18:47:17 +09:00
parent e54f747916
commit 10371d5bde
4 changed files with 233 additions and 0 deletions
+108
View File
@@ -277,3 +277,111 @@ describe("createHephaestusAgent", () => {
expect(config.prompt).not.toContain("task_create");
});
});
import { maybeCreateHephaestusConfig } from "../builtin-agents/hephaestus-agent";
import type { AgentOverrides } from "../types";
import type { CategoryConfig } from "../../config/schema";
describe("maybeCreateHephaestusConfig GPT apply_patch guard", () => {
describe("#given GPT model with user override allowing apply_patch", () => {
test("#when config is created #then apply_patch is still denied", () => {
// given
const agentOverrides: AgentOverrides = {
hephaestus: {
model: "openai/gpt-5.4",
permission: {
apply_patch: "allow",
},
},
};
const mergedCategories: Record<string, CategoryConfig> = {};
// when
const config = maybeCreateHephaestusConfig({
disabledAgents: [],
agentOverrides,
availableModels: new Set(["openai/gpt-5.4"]),
systemDefaultModel: "openai/gpt-5.4",
isFirstRunNoCache: false,
availableAgents: [],
availableSkills: [],
availableCategories: [],
mergedCategories,
useTaskSystem: false,
});
// then
expect(config).toBeDefined();
expect(config?.model).toBe("openai/gpt-5.4");
expect(config?.permission).toHaveProperty("apply_patch", "deny");
});
});
describe("#given non-GPT model with user override allowing apply_patch", () => {
test("#when config is created #then user override is respected", () => {
// given
const agentOverrides: AgentOverrides = {
hephaestus: {
model: "anthropic/claude-opus-4-6",
permission: {
apply_patch: "allow",
},
},
};
const mergedCategories: Record<string, CategoryConfig> = {};
// when
const config = maybeCreateHephaestusConfig({
disabledAgents: [],
agentOverrides,
availableModels: new Set(["anthropic/claude-opus-4-6"]),
systemDefaultModel: "anthropic/claude-opus-4-6",
isFirstRunNoCache: false,
availableAgents: [],
availableSkills: [],
availableCategories: [],
mergedCategories,
useTaskSystem: false,
});
// then
expect(config).toBeDefined();
expect(config?.model).toBe("anthropic/claude-opus-4-6");
expect(config?.permission).toHaveProperty("apply_patch", "allow");
});
});
describe("#given generic GPT model with user override allowing apply_patch", () => {
test("#when config is created #then apply_patch is still denied", () => {
// given
const agentOverrides: AgentOverrides = {
hephaestus: {
model: "openai/gpt-4o",
permission: {
apply_patch: "allow",
},
},
};
const mergedCategories: Record<string, CategoryConfig> = {};
// when
const config = maybeCreateHephaestusConfig({
disabledAgents: [],
agentOverrides,
availableModels: new Set(["openai/gpt-4o"]),
systemDefaultModel: "openai/gpt-4o",
isFirstRunNoCache: false,
availableAgents: [],
availableSkills: [],
availableCategories: [],
mergedCategories,
useTaskSystem: false,
});
// then
expect(config).toBeDefined();
expect(config?.model).toBe("openai/gpt-4o");
expect(config?.permission).toHaveProperty("apply_patch", "deny");
});
});
});