fix(core): limit subagent nesting depth (#37124)
Co-authored-by: Dax <mail@thdxr.com>
This commit is contained in:
parent
656f299017
commit
285d315b4e
4 changed files with 99 additions and 1 deletions
|
|
@ -101,6 +101,21 @@ export const TaskTool = Tool.define(
|
|||
)
|
||||
}
|
||||
|
||||
const parent = yield* sessions.get(ctx.sessionID)
|
||||
let current = parent
|
||||
let depth = 0
|
||||
while (current.parentID) {
|
||||
depth++
|
||||
current = yield* sessions.get(current.parentID)
|
||||
}
|
||||
if (depth >= (cfg.subagent_depth ?? 1)) {
|
||||
return yield* Effect.fail(
|
||||
new Error(
|
||||
`Subagent depth limit reached (${cfg.subagent_depth ?? 1}). Increase "subagent_depth" to allow nested subagents.`,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
if (!ctx.extra?.bypassAgentCheck) {
|
||||
yield* ctx.ask({
|
||||
permission: id,
|
||||
|
|
@ -121,7 +136,6 @@ export const TaskTool = Tool.define(
|
|||
const session = params.task_id
|
||||
? yield* sessions.get(SessionID.make(params.task_id)).pipe(Effect.catchCause(() => Effect.succeed(undefined)))
|
||||
: undefined
|
||||
const parent = yield* sessions.get(ctx.sessionID)
|
||||
const childPermission = deriveSubagentSessionPermission({
|
||||
parentSessionPermission: parent.permission ?? [],
|
||||
subagent: next,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue