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:
@@ -93,7 +93,8 @@ export function maybeCreateHephaestusConfig(input: {
|
|||||||
hephaestusConfig.permission = applyFrontierToolSchemaPermission(
|
hephaestusConfig.permission = applyFrontierToolSchemaPermission(
|
||||||
hephaestusConfig.permission,
|
hephaestusConfig.permission,
|
||||||
resolvedModel,
|
resolvedModel,
|
||||||
hephaestusOverride?.permission
|
hephaestusOverride?.permission,
|
||||||
|
(hephaestusOverride as { tools?: Record<string, boolean> } | undefined)?.tools
|
||||||
)
|
)
|
||||||
|
|
||||||
const gptDeny = getGptApplyPatchPermission(resolvedModel)
|
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", () => {
|
describe("#given generic GPT model with user override allowing apply_patch", () => {
|
||||||
test("#when config is created #then apply_patch is still denied", () => {
|
test("#when config is created #then apply_patch is still denied", () => {
|
||||||
// given
|
// given
|
||||||
|
|||||||
@@ -87,7 +87,8 @@ export function maybeCreateSisyphusConfig(input: {
|
|||||||
sisyphusConfig.permission = applyFrontierToolSchemaPermission(
|
sisyphusConfig.permission = applyFrontierToolSchemaPermission(
|
||||||
sisyphusConfig.permission,
|
sisyphusConfig.permission,
|
||||||
resolvedModel,
|
resolvedModel,
|
||||||
sisyphusOverride?.permission
|
sisyphusOverride?.permission,
|
||||||
|
(sisyphusOverride as { tools?: Record<string, boolean> } | undefined)?.tools
|
||||||
)
|
)
|
||||||
|
|
||||||
const gptDeny = getGptApplyPatchPermission(resolvedModel)
|
const gptDeny = getGptApplyPatchPermission(resolvedModel)
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ export function getFrontierToolSchemaPermission(model: string): Record<string, "
|
|||||||
export function applyFrontierToolSchemaPermission(
|
export function applyFrontierToolSchemaPermission(
|
||||||
permission: AgentConfig["permission"] | undefined,
|
permission: AgentConfig["permission"] | undefined,
|
||||||
model: string,
|
model: string,
|
||||||
explicitPermission?: AgentConfig["permission"]
|
explicitPermission?: AgentConfig["permission"],
|
||||||
|
explicitTools?: Record<string, boolean>
|
||||||
): AgentConfig["permission"] | undefined {
|
): AgentConfig["permission"] | undefined {
|
||||||
if (!permission) return permission
|
if (!permission) return permission
|
||||||
|
|
||||||
@@ -33,6 +34,7 @@ export function applyFrontierToolSchemaPermission(
|
|||||||
|
|
||||||
for (const toolName of FRONTIER_TOOL_SCHEMA_NAMES) {
|
for (const toolName of FRONTIER_TOOL_SCHEMA_NAMES) {
|
||||||
if (explicitPermissionMap?.[toolName] === "deny") continue
|
if (explicitPermissionMap?.[toolName] === "deny") continue
|
||||||
|
if (explicitTools?.[toolName] === false) continue
|
||||||
delete nextPermission[toolName]
|
delete nextPermission[toolName]
|
||||||
}
|
}
|
||||||
return nextPermission as AgentConfig["permission"]
|
return nextPermission as AgentConfig["permission"]
|
||||||
|
|||||||
@@ -553,4 +553,39 @@ describe("maybeCreateHephaestusConfig GPT apply_patch guard", () => {
|
|||||||
expect(config?.permission).toHaveProperty("glob", "deny");
|
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");
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user