Skip to content

fix(#19): config max_projects, budget day-boundary, codex fallback flags#42

Merged
marcus merged 5 commits intomainfrom
fix/issue-19-config-budget-fallback
Feb 28, 2026
Merged

fix(#19): config max_projects, budget day-boundary, codex fallback flags#42
marcus merged 5 commits intomainfrom
fix/issue-19-config-budget-fallback

Conversation

@marcus
Copy link
Owner

@marcus marcus commented Feb 28, 2026

Fixes three bugs reported in #19.

Bug 1 — schedule.max_projects config value ignored by run command

Root cause: runRun() read the --max-projects flag value at startup (defaulting to 1), then never checked cfg.Schedule.MaxProjects after loading config.

Fix:

  • Added MaxProjects and MaxTasks fields to ScheduleConfig in config.go (schedule.max_projects, schedule.max_tasks)
  • After loading config in runRun(), apply the config value when the CLI flag was not explicitly changed:
    if !maxProjectsChanged && cfg.Schedule.MaxProjects > 0 {
        maxProjects = cfg.Schedule.MaxProjects
    }

Bug 2 — Budget calibration reports "exhausted" at day/week boundary despite 0% usage

Root cause: At a week boundary (midnight, new week starts), the calibrator queries snapshots by week_start and finds 0 rows for the new week. It then falls back to cfg.GetProviderBudget() which is 0 when the user relies on calibration rather than a hardcoded weekly_tokens. A 0-token budget causes the budget calculation to report 0 allowance → provider appears exhausted.

Fix:

  • Added loadPreviousWeeklySamples() that queries the prior week's snapshot rows
  • When current-week samples are empty, fall back to previous-week data before returning the config default
  • Refactored loadClaudeWeeklySamples / loadCodexWeeklySamples to share a common loadWeeklySamplesForWeek() implementation

Bug 3 — Codex provider crashes with exit status 2 in automatic fallback path

Root cause: newCodexAgentFromConfig() always passed WithDangerouslyBypassApprovalsAndSandbox(cfg.Providers.Codex.DangerouslyBypassApprovalsAndSandbox). Since Go's bool zero value is false, an unconfigured Codex provider got bypassPerm=false, stripping --dangerously-bypass-approvals-and-sandbox from the codex exec invocation. Codex requires this flag for non-interactive (headless) execution and exits 2 without it.

Fix:

  • Only override the agent's built-in default (true) when the config explicitly enables the flag
  • The agent already defaults bypassPerm: true; no-op if the user hasn't configured Codex explicitly

Tests

  • TestCalibrateWeekBoundaryFallsBackToPreviousWeek — calibrator uses prior-week data at week boundary
  • TestScheduleMaxProjectsFromConfig / TestScheduleMaxProjectsCLIOverridesConfig — config/CLI precedence for max_projects
  • TestCodexAgentDefaultsBypassFlag / TestCodexAgentExplicitFalseBypassDisablesFlag — bypass flag behaviour

All existing tests pass (go test ./...).

cedricfarinazzo and others added 5 commits February 20, 2026 12:34
Allow configuring AI models per provider in config.yaml:

Config:
- providers.<provider>.model: model name to use
- Supports Claude, Codex, and Copilot providers

Implementation:
- Add Model field to ProviderConfig
- Add Model field to ExecuteOptions (agents)
- Update all agents to pass --model flag
- Add WithModel/WithCodexModel/WithCopilotModel options

Usage:
  providers:
    claude:
      model: "claude-sonnet-4.5"
    codex:
      model: "gpt-5.2-codex"
    copilot:
      model: "claude-sonnet-4.6"

Models default to CLI defaults if not specified.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add a new 'Models' step to the setup wizard between Safety and Task
presets. Users can navigate providers with ↑/↓ and cycle through
available models with ←/→.

Model options:
- Claude: claude-opus-4-6, claude-sonnet-4-6, claude-haiku-4-5
- Codex: gpt-5.3-codex, gpt-5.3-codex-spark, gpt-5.2-codex, gpt-5.2,
  gpt-5.1-codex-max, gpt-5.1-codex, gpt-5.1, gpt-5-codex, gpt-5
- Copilot: full list of 17 supported --model values

Selected model is saved to cfg.Providers.<X>.Model and picked up by
the agent helpers introduced in the model-selection branch.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Replace WriteString(fmt.Sprintf(...)) with fmt.Fprintf(&buf, ...) across
  setup.go, report.go, analysis/report.go, reporting/run_report.go,
  reporting/summary.go (QF1012)
- Remove empty branch in helpers.go copilot DangerouslySkipPermissions
  check (SA9003)
- Remove unused requestCount and lastReset fields from providers.Copilot
  struct (unused)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Bug 1 — schedule.max_projects config value ignored by run command:
- Add MaxProjects/MaxTasks fields to ScheduleConfig in config.go
- In runRun(), after loading config, apply cfg.Schedule.MaxProjects when
  --max-projects was not explicitly passed on the CLI
- Same treatment for max-tasks / cfg.Schedule.MaxTasks

Bug 2 — budget calibration reports exhausted at day/week boundary:
- At week boundary (no snapshots for new week yet), calibrator returned
  config value which could be 0 when user relies on calibration
- Add loadPreviousWeeklySamples() and fall back to prior week's data
  before returning the config default
- Refactor loadClaudeWeeklySamples/loadCodexWeeklySamples to share
  loadWeeklySamplesForWeek() implementation

Bug 3 — Codex provider crashes (exit 2) as automatic fallback:
- newCodexAgentFromConfig() always passed WithDangerouslyBypassApprovals
  AndSandbox(cfg.Providers.Codex.DangerouslyBypassApprovalsAndSandbox)
- Go bool zero value is false, so unconfigured Codex got bypassPerm=false,
  stripping --dangerously-bypass-approvals-and-sandbox from exec args
- Fix: only override agent default when config value is true; agent already
  defaults bypassPerm=true for non-interactive (headless) operation

Tests: add targeted tests for all three fixes.

Fixes #19
@marcus marcus merged commit 615e2b9 into main Feb 28, 2026
2 checks passed
@marcus marcus deleted the fix/issue-19-config-budget-fallback branch February 28, 2026 21:28
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.

2 participants