fix(agents): clear stale frontier 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:
@@ -1,4 +1,9 @@
|
||||
import type { AgentConfig } from "@opencode-ai/sdk"
|
||||
import { isGpt5_5Model } from "./types"
|
||||
import type { PermissionValue } from "../shared/permission-compat"
|
||||
|
||||
const FRONTIER_TOOL_SCHEMA_NAMES = ["grep", "glob"] as const
|
||||
type MutablePermission = Record<string, PermissionValue | Record<string, PermissionValue>>
|
||||
|
||||
function isOpus47Model(model: string): boolean {
|
||||
const modelName = model.includes("/") ? (model.split("/").pop() ?? model) : model
|
||||
@@ -10,3 +15,25 @@ export function getFrontierToolSchemaPermission(model: string): Record<string, "
|
||||
? { grep: "deny" as const, glob: "deny" as const }
|
||||
: {}
|
||||
}
|
||||
|
||||
export function applyFrontierToolSchemaPermission(
|
||||
permission: AgentConfig["permission"] | undefined,
|
||||
model: string,
|
||||
explicitPermission?: AgentConfig["permission"]
|
||||
): AgentConfig["permission"] | undefined {
|
||||
if (!permission) return permission
|
||||
|
||||
const nextPermission: MutablePermission = { ...permission }
|
||||
const explicitPermissionMap = explicitPermission as MutablePermission | undefined
|
||||
const frontierDeny = getFrontierToolSchemaPermission(model)
|
||||
if (Object.keys(frontierDeny).length > 0) {
|
||||
Object.assign(nextPermission, frontierDeny)
|
||||
return nextPermission as AgentConfig["permission"]
|
||||
}
|
||||
|
||||
for (const toolName of FRONTIER_TOOL_SCHEMA_NAMES) {
|
||||
if (explicitPermissionMap?.[toolName] === "deny") continue
|
||||
delete nextPermission[toolName]
|
||||
}
|
||||
return nextPermission as AgentConfig["permission"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user