[PR #6421] perf(skill): optimize permission checks with O(1) lookup #11894

Open
opened 2026-02-16 18:16:50 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/6421

State: open
Merged: No


Summary

Optimizes SkillTool permission checking by using a Map for O(1) lookups instead of re-running Wildcard.all() in execute.

Changes

  • Single-pass initialization using reduce to build both accessibleSkills (for description) and permissionMap (for execute)
  • O(1) permission lookup in execute instead of O(n) wildcard matching
  • Reuse accessibleSkills for error messages instead of calling Skill.all() again
  • Only call Agent.get() in the denied path (error case)

Notes

  • When no agent is provided, permissionMap is null and all skills are allowed
  • All existing tests pass
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6421 **State:** open **Merged:** No --- ## Summary Optimizes SkillTool permission checking by using a Map for O(1) lookups instead of re-running Wildcard.all() in execute. ## Changes - Single-pass initialization using `reduce` to build both `accessibleSkills` (for description) and `permissionMap` (for execute) - O(1) permission lookup in execute instead of O(n) wildcard matching - Reuse `accessibleSkills` for error messages instead of calling `Skill.all()` again - Only call `Agent.get()` in the denied path (error case) ## Notes - When no agent is provided, `permissionMap` is null and all skills are allowed - All existing tests pass
yindo added the pull-request label 2026-02-16 18:16:50 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11894