mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-28 19:11:03 +08:00
fix(cli): prevent subagents asking questions (#11101)
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@kilocode/cli": patch
|
||||
"kilo-code": patch
|
||||
---
|
||||
|
||||
Prevent task subagents from asking questions that users cannot answer from the parent session.
|
||||
@@ -61,7 +61,11 @@ export namespace KiloTask {
|
||||
|
||||
/** Extra permission rules appended to subagent sessions */
|
||||
export function permissions(rules: Permission.Ruleset): Permission.Ruleset {
|
||||
return [{ permission: "task", pattern: "*", action: "deny" }, ...rules]
|
||||
return [
|
||||
{ permission: "task", pattern: "*", action: "deny" },
|
||||
{ permission: "question", pattern: "*", action: "deny" },
|
||||
...rules,
|
||||
]
|
||||
}
|
||||
|
||||
export function merge(...rulesets: Permission.Ruleset[]): Permission.Ruleset {
|
||||
|
||||
@@ -247,6 +247,7 @@ export const TaskTool = Tool.define(
|
||||
variant, // kilocode_change
|
||||
agent: next.name,
|
||||
tools: {
|
||||
question: false, // kilocode_change - subagents cannot prompt the user directly
|
||||
...(canTodo ? {} : { todowrite: false }),
|
||||
...(canTask ? {} : { task: false }),
|
||||
...Object.fromEntries((cfg.experimental?.primary_tools ?? []).map((item) => [item, false])),
|
||||
|
||||
@@ -155,7 +155,7 @@ describe("Kilo task nesting", () => {
|
||||
),
|
||||
)
|
||||
|
||||
it.live("disables nested task tool even when global task permission allows it", () =>
|
||||
it.live("disables nested task and question tools even when global permissions allow them", () =>
|
||||
provideTmpdirInstance(
|
||||
() =>
|
||||
Effect.gen(function* () {
|
||||
@@ -186,6 +186,7 @@ describe("Kilo task nesting", () => {
|
||||
|
||||
const child = yield* sessions.get(result.metadata.sessionId)
|
||||
expect(seen?.tools?.task).toBe(false)
|
||||
expect(seen?.tools?.question).toBe(false)
|
||||
expect(child.permission).toEqual(
|
||||
expect.arrayContaining([
|
||||
{
|
||||
@@ -193,6 +194,11 @@ describe("Kilo task nesting", () => {
|
||||
pattern: "*",
|
||||
action: "deny",
|
||||
},
|
||||
{
|
||||
permission: "question",
|
||||
pattern: "*",
|
||||
action: "deny",
|
||||
},
|
||||
]),
|
||||
)
|
||||
}),
|
||||
@@ -200,6 +206,7 @@ describe("Kilo task nesting", () => {
|
||||
config: {
|
||||
permission: {
|
||||
task: "allow",
|
||||
question: "allow",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -484,6 +484,7 @@ describe("tool.task", () => {
|
||||
)
|
||||
// kilocode_change end
|
||||
expect(seen?.tools).toEqual({
|
||||
question: false, // kilocode_change - subagents cannot prompt the user directly
|
||||
todowrite: false,
|
||||
task: false, // kilocode_change - Kilo disallows nested subagents
|
||||
bash: false,
|
||||
|
||||
Reference in New Issue
Block a user