Skip to content

Orchestrator bypasses provider layer, breaking Copilot budget tracking #58

@maxbeizer

Description

@maxbeizer

Problem

The orchestrator calls o.agent.Execute() directly for plan/implement/review phases (orchestrator.go L442, L502, L616). This bypasses the provider layer entirely, which means:

  • providers.Copilot.Execute() is never called
  • IncrementRequestCount() never fires
  • ~/.copilot/nightshift-usage.json is never written
  • nightshift budget --provider copilot always shows 0% used

For Claude and Codex this is less impactful because they read usage from external files (~/.claude/stats-cache.json, ~/.codex/sessions/). But Copilot has no external usage file — the provider's request counter is the only tracking mechanism.

Reproduction

nightshift task run docs-backfill --provider copilot
# completes successfully, opens PR

nightshift budget --provider copilot
# shows 0% used — should show requests consumed

Suggested fix

Route agent execution through the provider layer so providers can hook into the execution lifecycle (tracking, rate limiting, cost estimation). Something like:

// Instead of:
execResult, err := o.agent.Execute(ctx, opts)

// Route through provider:
result, err := o.provider.Execute(ctx, task)
// provider.Execute() delegates to agent internally and handles tracking

This would also enable future features like per-provider rate limiting or cost-based model selection.

Context

Found while testing Copilot provider improvements (PRs #54, #55, #56). The provider Execute() method correctly increments the counter, but the orchestrator never calls it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions