Skip to content

fix(task): respect agent permission config for todowrite tool#19125

Merged
rekram1-node merged 12 commits intoanomalyco:devfrom
ariane-emory:fix/subagent-todo-perms
Mar 25, 2026
Merged

fix(task): respect agent permission config for todowrite tool#19125
rekram1-node merged 12 commits intoanomalyco:devfrom
ariane-emory:fix/subagent-todo-perms

Conversation

@ariane-emory
Copy link
Contributor

Issue for this PR

Closes #19101

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The todowrite tool was hardcoded as denied for all subagents, preventing users from enabling them via agent permission configuration even when explicitly allowed.

This change follows the existing pattern used for the task permission by checking if the agent has explicit allow rules for the todowrite tool before applying the default deny.

Changes:

  • Add hasTodoWritePermission check
  • Conditionally include deny rules in session creation
  • Conditionally include false values in tools object

How did you verify your code works?

Manual A/B testing, bun test, bun typecheck.

Screenshots / recordings

No UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

The todowrite and todoread tools were hardcoded as denied for all
subagents, preventing users from enabling them via agent permission
configuration even when explicitly allowed.

This change follows the existing pattern used for the task permission
by checking if the agent has explicit allow rules for todowrite/
todoread before applying the default deny.

Changes:
- Add hasTodoWritePermission and hasTodoReadPermission checks
- Conditionally include deny rules in session creation
- Conditionally include false values in tools object

Fixes anomalyco#19101
The todowrite tool was hardcoded as denied for all subagents, preventing
users from enabling it via agent permission configuration even when
explicitly allowed.

This change follows the existing pattern used for the task permission
by checking if the agent has explicit allow rules for todowrite before
applying the default deny.

Note: todoread tool was removed from this fix as it does not exist -
the todowrite tool returns the todo list in its output, serving as the
read mechanism.

Fixes anomalyco#19101
The todowrite tool was hardcoded as denied for all subagents, preventing
users from enabling it via agent permission configuration even when
explicitly allowed.

This change follows the existing pattern used for the task permission
by checking if the agent has explicit allow rules for todowrite before
applying the default deny.

Note: todoread tool was removed from this fix as it does not exist -
the todowrite tool returns the todo list in its output, serving as the
read mechanism.

Fixes anomalyco#19101
…ge conflict)

Remove todoread references - the tool doesn't exist.
@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found a potentially related PR:

PR #18202: fix(task): preserve subagent todo permissions

This PR appears to be related as it also addresses subagent todo/todowrite permissions. The current PR (#19125) builds on similar logic by respecting agent permission configuration for the todowrite tool, while PR #18202 also dealt with preserving todo permissions for subagents.

However, since these are addressing the same domain (subagent todo permissions), it would be worth checking if they conflict or if one supersedes the other.

@ariane-emory ariane-emory marked this pull request as ready for review March 25, 2026 15:28
if (!agent) throw new Error(`Unknown agent type: ${params.subagent_type} is not a valid agent type`)

const hasTaskPermission = agent.permission.some((rule) => rule.permission === "task")
const hasTodoWritePermission = agent.permission.some((rule) => rule.permission === "todowrite" && rule.action === "allow")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really want check allow here? because if the agent added ask, it should be respected, right? right now you will still deny it...

maybe keep consistent with the task check just checking if there agent is changing the permission

Copy link
Contributor Author

@ariane-emory ariane-emory Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding "ask" in a (non-interactive) subagent session would likely have undesirable results if respected.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed as per your suggestion on Discord.

@ariane-emory ariane-emory marked this pull request as draft March 25, 2026 17:01
@ariane-emory ariane-emory marked this pull request as ready for review March 25, 2026 17:02
@rekram1-node rekram1-node merged commit 66a5655 into anomalyco:dev Mar 25, 2026
13 of 16 checks passed
@ariane-emory ariane-emory deleted the fix/subagent-todo-perms branch March 25, 2026 23:03
cainiao1992 pushed a commit to cainiao1992/opencode that referenced this pull request Mar 26, 2026
Kizunad pushed a commit to Kizunad/opencode that referenced this pull request Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

todowrite/todoread cannot be enabled for subagents via agent permission config

3 participants