Skip to content

feat: Port upstream task permission fixes (PRs #12584 and #12136) #175

@randomm

Description

@randomm

Summary

Granular task permissions (permission.task with per-agent allow/deny) are not enforced due to two bugs also present upstream. Upstream has open PRs fixing both issues. We should port them to unblock config-level agent access control.

Upstream PRs to Port

PR anomalyco#12584 — Propagate parent agent permissions to subagent child sessions

PR anomalyco#12136 — Handle permission requests from child sessions (ACP)

Context

The Bug

When a subagent (e.g., developer) calls TaskTool:

  1. TaskTool.init() at prompt.ts:329 is called without agent context
  2. initCtx.agent is undefined in task.ts:113
  3. Permission filtering is bypassed — ALL agents are accessible
  4. Config like "task": {"*": "deny", "adversarial-developer": "allow"} has no effect

Related Issues

Also Required

Reopen and fix #173TaskTool.init() must receive Agent.Info:

// prompt.ts line 329 — current (broken):
const taskTool = await TaskTool.init()

// fixed:
const taskAgent = await Agent.get(task.agent)
const taskTool = await TaskTool.init({ agent: taskAgent })

Merge Order

  1. Port PR fix: propagate parent agent permissions to subagent child sessions anomalyco/opencode#12584 (permission inheritance)
  2. Port PR fix(acp): handle permission requests from child sessions anomalyco/opencode#12136 (ACP forwarding)
  3. Fix prompt.ts line 329 (pass Agent.Info to TaskTool.init)
  4. Rebuild binary and verify

Verification

After all three fixes, test with config:

{
  "developer": {
    "permission": {
      "task": {
        "*": "deny",
        "adversarial-developer": "allow"
      }
    }
  }
}

Expected: developer can spawn @adversarial-developer but NOT @git-agent or @explore.

Risk Assessment

Both upstream PRs are surgical (2 files each, <30 lines of changes). Low conflict risk with fork's custom code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions