fix(agents): preserve explicit legacy tool denies

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-04-27 14:24:42 +09:00
parent c65f90ee09
commit ac8987a732
5 changed files with 77 additions and 3 deletions
@@ -93,7 +93,8 @@ export function maybeCreateHephaestusConfig(input: {
hephaestusConfig.permission = applyFrontierToolSchemaPermission(
hephaestusConfig.permission,
resolvedModel,
hephaestusOverride?.permission
hephaestusOverride?.permission,
(hephaestusOverride as { tools?: Record<string, boolean> } | undefined)?.tools
)
const gptDeny = getGptApplyPatchPermission(resolvedModel)
@@ -212,6 +212,41 @@ describe("maybeCreateSisyphusConfig", () => {
});
});
describe("#given non-frontier model with legacy user tools denying grep and glob", () => {
test("#when config is created #then explicit legacy denies are preserved", () => {
// given
const legacyOverride = {
model: "openai/gpt-5.4",
tools: {
grep: false,
glob: false,
},
};
const agentOverrides: AgentOverrides = {
sisyphus: legacyOverride,
};
const mergedCategories: Record<string, CategoryConfig> = {};
// when
const config = maybeCreateSisyphusConfig({
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?.permission).toHaveProperty("grep", "deny");
expect(config?.permission).toHaveProperty("glob", "deny");
});
});
describe("#given generic GPT model with user override allowing apply_patch", () => {
test("#when config is created #then apply_patch is still denied", () => {
// given
+2 -1
View File
@@ -87,7 +87,8 @@ export function maybeCreateSisyphusConfig(input: {
sisyphusConfig.permission = applyFrontierToolSchemaPermission(
sisyphusConfig.permission,
resolvedModel,
sisyphusOverride?.permission
sisyphusOverride?.permission,
(sisyphusOverride as { tools?: Record<string, boolean> } | undefined)?.tools
)
const gptDeny = getGptApplyPatchPermission(resolvedModel)
+3 -1
View File
@@ -19,7 +19,8 @@ export function getFrontierToolSchemaPermission(model: string): Record<string, "
export function applyFrontierToolSchemaPermission(
permission: AgentConfig["permission"] | undefined,
model: string,
explicitPermission?: AgentConfig["permission"]
explicitPermission?: AgentConfig["permission"],
explicitTools?: Record<string, boolean>
): AgentConfig["permission"] | undefined {
if (!permission) return permission
@@ -33,6 +34,7 @@ export function applyFrontierToolSchemaPermission(
for (const toolName of FRONTIER_TOOL_SCHEMA_NAMES) {
if (explicitPermissionMap?.[toolName] === "deny") continue
if (explicitTools?.[toolName] === false) continue
delete nextPermission[toolName]
}
return nextPermission as AgentConfig["permission"]
+35
View File
@@ -553,4 +553,39 @@ describe("maybeCreateHephaestusConfig GPT apply_patch guard", () => {
expect(config?.permission).toHaveProperty("glob", "deny");
});
});
describe("#given non-frontier model with legacy user tools denying grep and glob", () => {
test("#when config is created #then explicit legacy denies are preserved", () => {
// given
const legacyOverride = {
model: "openai/gpt-5.4",
tools: {
grep: false,
glob: false,
},
};
const agentOverrides: AgentOverrides = {
hephaestus: legacyOverride,
};
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?.permission).toHaveProperty("grep", "deny");
expect(config?.permission).toHaveProperty("glob", "deny");
});
});
});