fix(background-agent): fix tool permission spread order so agent restrictions are respected#1868
Open
sjawhar wants to merge 1 commit intocode-yeongyu:devfrom
Open
Conversation
There was a problem hiding this comment.
No issues found across 2 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Auto-approved: Tests verify tool restrictions order correctly without introducing regressions; changes are small and reviewed with no issues found.
ae7a687 to
8a21e2a
Compare
Contributor
|
All contributors have signed the CLA. Thank you! ✅ |
…task launch Reorder tool permission spread so getAgentToolRestrictions() comes last, allowing agent-specific restrictions to override defaults. Fixes all 3 sites: task-starter.ts (startTask), manager.ts (startTask and resume paths). Previously, defaults like call_omo_agent:true would stomp agent restrictions (e.g., explore's call_omo_agent:false) due to JS spread semantics.
8a21e2a to
025eb14
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the tool permission spread order in background task
startTaskandresumepaths so that agent-specific restrictions take priority over defaults.Problem
In
BackgroundManager.startTask()and the resume path, tool permissions were constructed with the defaults coming AFTER the agent restrictions:Due to JS spread semantics, later keys override earlier ones, meaning
call_omo_agent: truewould always win, even for agents likeexploreandlibrarianwhose restrictions explicitly setcall_omo_agent: false.The correct pattern already existed in
sync-prompt-sender.ts:Changes
Implementation (
src/features/background-agent/manager.ts):startTask— defaults first,...getAgentToolRestrictions()lastresumepathsetSessionToolsIIFE wrapperTests (
src/features/background-agent/manager.test.ts):"BackgroundManager - tool permission spread order"describe blocktoolspassed topromptWithModelSuggestionRetryvia mockcall_omo_agent,write,editare allfalsefor explore agent (matchingEXPLORATION_AGENT_DENYLIST)Context
Runtime logs show explore/librarian agents never actually invoked
call_omo_agentdespite having access (0 occurrences in 107MB of logs). This is a latent defect fix for correctness — the override contradicted the carefully defined restrictions inagent-tool-restrictions.tsand was inconsistent with the sync path.Testing
manager.test.ts(91 existing + 2 new)Summary by cubic
Fixes tool permission order across background agent launch and resume so agent-specific restrictions override defaults. Restricted agents (e.g., explore) no longer gain call_omo_agent, write, or edit when denied.
Written for commit 025eb14. Summary will update on new commits.