You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
run: headless session denies are not applied to subagent or reused sessions #168
aictrl run applies its headless denies (question, plan_enter, plan_exit) only as the permission of the session it creates (cli/cmd/run.ts, sdk.session.create(... permission: rules)). #162 (for #147) makes the model request honour session-level denies, but some sessions in a headless run never get those rules:
Subagent sessions.TaskTool creates the child session (tool/task.ts, Session.create) with only the todowrite/todoread/task denies. The parent session's rules are not inherited.
Reused sessions. With --continue or --session, run reuses an existing session as is. With --fork, it forks one, and the fork does not get rules either.
Impact
Built-in subagents (general, explore) are unaffected, because the agent defaults already deny question/plan_enter/plan_exit.
A custom subagent, or a user permission config that allows question (this is merged into every agent), gets question offered and evaluated as allow/ask inside a headless run. A headless client has nobody to answer it.
A continued, resumed or forked headless session has none of the headless denies.
Proposal
Decide whether child sessions should inherit the parent session's ruleset, either all of it or only * denies, and apply that in TaskTool (e.g. PermissionNext.merge(parent.permission ?? [], taskDenies)).
In run, apply rules to reused and forked sessions too, e.g. with Session.setPermission / the SDK equivalent, merged with whatever rules the session already has.
Acceptance
A subagent spawned from a headless run session is not offered question/plan_enter/plan_exit, even when its agent allows them (regression test).
run --continue, --session and --fork sessions carry the headless denies (regression test).
Interactive sessions are unchanged.
Found in the review of #162 (finding: "Subagent sessions don't inherit parent session denies").
Both parts of this issue are addressed in #162. It is linked with Closes #168, so this issue closes when #162 merges.
Subagent sessions: fixed. TaskTool now creates the subagent session with merge(caller session rules, subagent denies). The subagent prompt also no longer passes the legacy tools map, which used to replace the session ruleset right away. So session-level rules now apply down the subagent tree, at request time (llm.ts filters the tools by agent + session rules) and at execution time. Regression test: test/tool/task.test.ts, "applies the caller session's rules to the subagent, beneath the subagent denies".
run --continue / --session / --fork: nothing remains. refactor(session): remove question and plan mode; apply session denies to requests and subagents (#147) #162 removes the question tool and plan mode (plan_enter/plan_exit, the plan agent), so run no longer creates headless deny rules, and reused or forked sessions have nothing to miss. Sessions whose history calls the removed tools still continue (regression test in test/session/prompt.test.ts). run --agent plan now fails with INVOCATION_INVALID_ARGUMENTS instead of falling back to the default agent.
Activity
byapparov commentedon Oct 17, 2026
Both parts of this issue are addressed in #162. It is linked with
Closes #168, so this issue closes when #162 merges.TaskToolnow creates the subagent session withmerge(caller session rules, subagent denies). The subagent prompt also no longer passes the legacytoolsmap, which used to replace the session ruleset right away. So session-level rules now apply down the subagent tree, at request time (llm.tsfilters the tools by agent + session rules) and at execution time. Regression test:test/tool/task.test.ts, "applies the caller session's rules to the subagent, beneath the subagent denies".run --continue/--session/--fork: nothing remains. refactor(session): remove question and plan mode; apply session denies to requests and subagents (#147) #162 removes thequestiontool and plan mode (plan_enter/plan_exit, theplanagent), sorunno longer creates headless deny rules, and reused or forked sessions have nothing to miss. Sessions whose history calls the removed tools still continue (regression test intest/session/prompt.test.ts).run --agent plannow fails withINVOCATION_INVALID_ARGUMENTSinstead of falling back to the default agent.