fix(session): avoid sticky prompt tool overrides (#31394)
This commit is contained in:
@@ -1198,11 +1198,8 @@ export const layer = Layer.effect(
|
||||
permissions.push({ permission: t, action: enabled ? "allow" : "deny", pattern: "*" })
|
||||
}
|
||||
if (permissions.length > 0) {
|
||||
// Merge so per-call tool rules don't clobber inherited session rules
|
||||
// (e.g. external_directory allows from the parent session).
|
||||
const merged = Permission.merge(session.permission ?? [], permissions)
|
||||
session.permission = merged
|
||||
yield* sessions.setPermission({ sessionID: session.id, permission: merged })
|
||||
session.permission = permissions
|
||||
yield* sessions.setPermission({ sessionID: session.id, permission: permissions })
|
||||
}
|
||||
|
||||
if (input.noReply === true) return message
|
||||
|
||||
@@ -125,6 +125,24 @@ export const TaskTool = Tool.define(
|
||||
const parentAgent = parent.agent
|
||||
? yield* agent.get(parent.agent).pipe(Effect.catchCause(() => Effect.succeed(undefined)))
|
||||
: undefined
|
||||
const childPermission = deriveSubagentSessionPermission({
|
||||
parentSessionPermission: parent.permission ?? [],
|
||||
parentAgent,
|
||||
subagent: next,
|
||||
})
|
||||
const childToolDenies = [
|
||||
...(next.permission.some((rule) => rule.permission === "todowrite")
|
||||
? []
|
||||
: [{ permission: "todowrite" as const, pattern: "*" as const, action: "deny" as const }]),
|
||||
...(next.permission.some((rule) => rule.permission === id)
|
||||
? []
|
||||
: [{ permission: id, pattern: "*" as const, action: "deny" as const }]),
|
||||
...(cfg.experimental?.primary_tools?.map((permission) => ({
|
||||
permission,
|
||||
pattern: "*" as const,
|
||||
action: "deny" as const,
|
||||
})) ?? []),
|
||||
]
|
||||
const nextSession =
|
||||
session ??
|
||||
(yield* sessions.create({
|
||||
@@ -132,16 +150,14 @@ export const TaskTool = Tool.define(
|
||||
title: params.description + ` (@${next.name} subagent)`,
|
||||
agent: next.name,
|
||||
permission: [
|
||||
...deriveSubagentSessionPermission({
|
||||
parentSessionPermission: parent.permission ?? [],
|
||||
parentAgent,
|
||||
subagent: next,
|
||||
}),
|
||||
...(cfg.experimental?.primary_tools?.map((item) => ({
|
||||
pattern: "*",
|
||||
action: "allow" as const,
|
||||
permission: item,
|
||||
})) ?? []),
|
||||
...childPermission,
|
||||
...childToolDenies.filter(
|
||||
(deny) =>
|
||||
!childPermission.some(
|
||||
(rule) =>
|
||||
rule.permission === deny.permission && rule.pattern === deny.pattern && rule.action === deny.action,
|
||||
),
|
||||
),
|
||||
],
|
||||
}))
|
||||
|
||||
@@ -182,11 +198,6 @@ export const TaskTool = Tool.define(
|
||||
},
|
||||
variant: next.model ? undefined : variant,
|
||||
agent: next.name,
|
||||
tools: {
|
||||
...(next.permission.some((rule) => rule.permission === "todowrite") ? {} : { todowrite: false }),
|
||||
...(next.permission.some((rule) => rule.permission === id) ? {} : { task: false }),
|
||||
...Object.fromEntries((cfg.experimental?.primary_tools ?? []).map((item) => [item, false])),
|
||||
},
|
||||
parts,
|
||||
})
|
||||
return result.parts.findLast((item) => item.type === "text")?.text ?? ""
|
||||
|
||||
Reference in New Issue
Block a user