Skip to content

feat: wire Copilot provider Execute() to agent and add PRU multipliers#54

Draft
maxbeizer wants to merge 4 commits intomarcus:mainfrom
maxbeizer:feat/copilot-provider-execute
Draft

feat: wire Copilot provider Execute() to agent and add PRU multipliers#54
maxbeizer wants to merge 4 commits intomarcus:mainfrom
maxbeizer:feat/copilot-provider-execute

Conversation

@maxbeizer
Copy link

Summary

Connects the Copilot provider's Execute() method to the existing CopilotAgent and adds PRU (Premium Request Unit) cost awareness.

Changes

  • internal/providers/copilot.go

    • Added CopilotExecutor interface to bridge provider → agent without import cycle
    • Wired Execute() to delegate to the agent, increment request counter on each call
    • Added PRUMultiplier map with current GitHub Copilot model costs (GPT-4.1=0x free, Sonnet=1x, Opus=10x, o3-pro=50x)
    • Added EstimatePRUCost() helper for budget-aware task routing
    • Updated doc comments with PRU multiplier table
  • internal/providers/provider.go

    • Added Prompt, WorkDir, Files fields to Task
    • Added Output, ExitCode fields to Result
  • internal/providers/copilot_test.go

    • Tests for Execute with agent, Execute without agent (error), Execute with agent error
    • Tests for EstimatePRUCost() across all model tiers

Why

The Copilot provider had a fully implemented agent (internal/agents/copilot.go) but the provider's Execute() was a no-op stub. This wires them together so the orchestrator can use Copilot end-to-end.

The PRU multiplier map enables future budget-aware model selection — nightshift can pick cheap models (GPT-4.1, 0 PRUs) for simple tasks like lint-fix and reserve expensive models (Opus, 10 PRUs) for complex work like bug-finding.

Testing

All existing tests pass + 4 new tests added.

Related: Part of a series improving Copilot support. See also upcoming PRs for PRU-aware budget config and COPILOT_INTEGRATION.md.

maxbeizer and others added 2 commits March 9, 2026 15:31
- Connect providers.Copilot.Execute() to agents.CopilotAgent via
  CopilotExecutor interface (avoids import cycle)
- Add PRUMultiplier map with current GitHub Copilot model costs
  (GPT-4.1=0x, Sonnet=1x, Opus=10x, o3-pro=50x, etc.)
- Add EstimatePRUCost() helper for budget-aware task routing
- Add Task.Prompt and Result.Output/ExitCode fields to provider types
- Increment request counter on each execution for budget tracking
- Tests for Execute wiring, error handling, and PRU cost estimates

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add MonthlyLimit and CopilotPlan fields to ProviderConfig
- Add CopilotPlanLimits map: free=50, pro=300, pro_plus=1500,
  business=300, enterprise=1000 PRUs/month
- Add GetCopilotMonthlyLimit() with resolution order:
  MonthlyLimit > CopilotPlan preset > weeklyTokens*4 fallback
- Update budget.Manager to use GetCopilotMonthlyLimit() instead
  of hardcoded weeklyBudget*4 approximation
- Update doctor command to use config-driven monthly limit
- Table-driven tests for all plan presets and fallback behavior

Config example:
  [providers.copilot]
  copilot_plan = "pro"      # auto-sets 300 PRUs/month
  # or: monthly_limit = 500  # explicit override

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The old check looked for gh-copilot in 'gh extension list', but modern
gh versions have copilot built-in (not as an extension). This caused
Available() to return false even when 'gh copilot' worked fine.

Now probes 'gh copilot --version' which works for both built-in and
extension-based installs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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