Add session permission support to background agents for denying questions

Implements question-denied session permission rules when creating child
sessions via background task delegation. This prevents subagents from
asking questions by passing explicit permission configuration during
session creation.

🤖 GENERATED WITH ASSISTANCE OF OhMyOpenCode
This commit is contained in:
YeonGyu-Kim
2026-03-11 16:40:30 +09:00
parent 24f4e14f07
commit 413e8b73b7
12 changed files with 233 additions and 2 deletions
@@ -0,0 +1,38 @@
import { describe, expect, test } from "bun:test"
import { createSyncSession } from "./sync-session-creator"
describe("createSyncSession", () => {
test("creates child session with question permission denied", async () => {
// given
const createCalls: Array<Record<string, unknown>> = []
const client = {
session: {
get: async () => ({ data: { directory: "/parent" } }),
create: async (input: Record<string, unknown>) => {
createCalls.push(input)
return { data: { id: "ses_child" } }
},
},
}
// when
const result = await createSyncSession(client as never, {
parentSessionID: "ses_parent",
agentToUse: "explore",
description: "test task",
defaultDirectory: "/fallback",
})
// then
expect(result).toEqual({ ok: true, sessionID: "ses_child", parentDirectory: "/parent" })
expect(createCalls).toHaveLength(1)
expect(createCalls[0]?.body).toEqual({
parentID: "ses_parent",
title: "test task (@explore subagent)",
permission: [
{ permission: "question", action: "deny", pattern: "*" },
],
})
})
})