Skip to content

fix(background-agent): fix tool permission spread order so agent restrictions are respected#1868

Open
sjawhar wants to merge 1 commit intocode-yeongyu:devfrom
sjawhar:fix/background-agent-tool-permissions
Open

fix(background-agent): fix tool permission spread order so agent restrictions are respected#1868
sjawhar wants to merge 1 commit intocode-yeongyu:devfrom
sjawhar:fix/background-agent-tool-permissions

Conversation

@sjawhar
Copy link

@sjawhar sjawhar commented Feb 15, 2026

Summary

Fixes the tool permission spread order in background task startTask and resume paths 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:

// BEFORE (buggy): defaults override restrictions
tools: {
  ...getAgentToolRestrictions(input.agent),  // e.g., explore: { call_omo_agent: false }
  task: false,
  call_omo_agent: true,   // ← stomps the restriction above
  question: false,
}

Due to JS spread semantics, later keys override earlier ones, meaning call_omo_agent: true would always win, even for agents like explore and librarian whose restrictions explicitly set call_omo_agent: false.

The correct pattern already existed in sync-prompt-sender.ts:

// CORRECT: restrictions come last and win
tools: {
  task: allowTask,
  call_omo_agent: true,
  question: false,
  ...getAgentToolRestrictions(input.agentToUse),  // restrictions override defaults
}

Changes

Implementation (src/features/background-agent/manager.ts):

  • Reordered tool permission spread in startTask — defaults first, ...getAgentToolRestrictions() last
  • Same reorder in the resume path
  • Preserved the setSessionTools IIFE wrapper

Tests (src/features/background-agent/manager.test.ts):

  • Added 2 new tests in "BackgroundManager - tool permission spread order" describe block
  • Captures tools passed to promptWithModelSuggestionRetry via mock
  • Verifies call_omo_agent, write, edit are all false for explore agent (matching EXPLORATION_AGENT_DENYLIST)

Context

Runtime logs show explore/librarian agents never actually invoked call_omo_agent despite having access (0 occurrences in 107MB of logs). This is a latent defect fix for correctness — the override contradicted the carefully defined restrictions in agent-tool-restrictions.ts and was inconsistent with the sync path.

Testing

  • 93/93 tests pass in manager.test.ts (91 existing + 2 new)
  • No regressions

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.

  • Bug Fixes
    • Reordered tool spread to apply defaults first, then ...getAgentToolRestrictions() in BackgroundManager startTask/resume and spawner startTask.
    • Added tests confirming explore agent sets call_omo_agent, task, write, and edit to false in startTask and resume.

Written for commit 025eb14. Summary will update on new commits.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

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.

@sjawhar sjawhar force-pushed the fix/background-agent-tool-permissions branch 2 times, most recently from ae7a687 to 8a21e2a Compare February 17, 2026 01:02
@github-actions
Copy link
Contributor

github-actions bot commented Feb 17, 2026

All contributors have signed the CLA. Thank you! ✅
Posted by the CLA Assistant Lite bot.

…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.
@sjawhar sjawhar force-pushed the fix/background-agent-tool-permissions branch from 8a21e2a to 025eb14 Compare February 17, 2026 04:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments