feat: implement issue #195 — bug(dev-lead): engine.sh defines multi-tier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) - #556
Conversation
…ier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6)
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reached
More reviews will be available in 35 minutes and 39 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (6)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces intent-based model dispatching and provider headroom checks to optimize engine selection and prevent rate-limiting issues. It adds helper functions model_for_intent and check_provider_headroom in scripts/engine.sh, updates the dev-lead scripts to pass intent types, and includes comprehensive unit tests. The review feedback highlights several robustness improvements in scripts/engine.sh, including validating that rate-limit values are numeric to prevent crashes under set -eu, avoiding the curl -sI -X POST anti-pattern, and parsing HTTP headers more reliably by handling potential whitespace variations.
Dev-Lead — review-changes (applied)Changes committed and pushed. |
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #195 by making the dev-lead “writer” path actually use the multi-tier model configuration in engine.sh, and by improving provider fallback behavior with a proactive headroom check before invoking an engine.
Changes:
- Add intent-based model selection (
model_for_intent) and plumb intent throughrun_writer_with_fallback, so different dev-lead tasks can use different tier models. - Add
check_provider_headroomand integrate it into the fallback loop to proactively skip engines near quota exhaustion. - Add new Bats unit tests covering model dispatch and provider headroom behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
scripts/engine.sh |
Adds intent→model mapping and provider headroom probing; updates run_writer_with_fallback to select tier model per intent and engine. |
scripts/dev-lead-fix-reviews.sh |
Passes INTENT_TYPE into run_writer_with_fallback so model selection matches the invoked intent. |
scripts/dev-lead-fix-issue.sh |
Passes explicit fix-issue intent into run_writer_with_fallback. |
scripts/dev-lead-fix-ci.sh |
Passes explicit fix-ci intent into run_writer_with_fallback. |
tests/dev-lead/unit/test_provider_headroom.bats |
Adds unit tests for check_provider_headroom and for headroom-driven fallback skipping. |
tests/dev-lead/unit/test_model_dispatch.bats |
Adds unit tests for model_for_intent and intent-based model selection through run_writer_with_fallback. |
Dev-Lead — review-changes (applied)Changes committed and pushed. |
Dev-Lead — waiting on PR blockers (intent: fix-reviews)PR: #556 |
|
donpetry-bot
left a comment
There was a problem hiding this comment.
Automated review — APPROVED ✓
Risk: LOW
Reviewed commit: 631695e20026a56d48c8e22f0223fc7c179f4538
Review mode: triage-approved (single reviewer)
Summary
Implements issue #195 (multi-tier model dispatch + proactive provider headroom checks). The dev-lead writer pipeline now actually uses the tiered model definitions in engine.sh — human-pr/fix-bot-comment route to haiku, fix-reviews/fix-ci/rebase to sonnet (action), fix-issue/human to deep — and a fail-open check_provider_headroom skips engines at/above 75% usage (configurable via DEV_LEAD_USAGE_THRESHOLD). The three dead-code-in-dev-lead-context functions (run_triage, run_agentic, run_duck) are now documented as review-one-pr.sh-only rather than removed, which is a reasonable scope choice. +571/-8 across 6 files, including 463 lines of new bats coverage.
Linked issue analysis
Closes #195. All acceptance criteria addressed:
- Model dispatch:
model_for_intentmatches the issue's spec exactly; all three caller scripts (dev-lead-fix-ci.sh, dev-lead-fix-issue.sh, dev-lead-fix-reviews.sh) pass an intent string through. - Failover (bugs 1 & 2): Already resolved upstream in the existing
run_writer(output is captured viateeandis_rate_limited_files; copilot path usescopilot_chat ... --yolodirectly rather than falling back to claude). - Proactive usage monitoring (bug 3):
check_provider_headroomprobes Anthropic and GitHub Models rate-limit headers, fail-opens on probe failure, and is wired in ahead of each engine attempt in the fallback loop. - Dead code:
run_triage/run_agentic/run_duckannotated as review-one-pr.sh-only (documented rather than removed — acceptable).
Findings
No blocking issues.
Minor observations (non-blocking):
- The claude headroom probe sends a real
POST /v1/messageswithmax_tokens:1, so each writer invocation burns ~1 token even on the happy path. This is consistent with the issue spec's intent ("barely consumes quota") and is bounded. - Copilot probe correctly guards against unset/placeholder tokens before making a network call — good defensive choice.
- bats coverage is thorough (16 dispatch tests + 13 headroom tests including threshold-edge and fail-open cases).
CI status
All required checks green: Lint, ShellCheck, bats, validate-fixtures, validate-agent-profiles, unit-tests, Compile agentic workflows, Agent Security Scan, CodeQL (actions + python), Secret scan (gitleaks), SonarCloud (Quality Gate passed), AgentShield, dev-lead dispatch. coderabbitai approved; gemini-code-assist and copilot-pull-request-reviewer commented without blocking. Skipped checks (dependabot, language-specific dependency audits) are expected — not applicable to this PR.
Reviewed automatically by the PR-review agent (single-reviewer mode: opus 4.7). Reply if you need a human review.
…ier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) (#556) * feat: implement issue #195 — bug(dev-lead): engine.sh defines multi-tier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) * chore: apply manual instructions [skip ci-relay] * chore: apply manual instructions [skip ci-relay] --------- Co-authored-by: donpetry-bot <281750570+donpetry-bot@users.noreply.github.com>
…ier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) (#556) * feat: implement issue #195 — bug(dev-lead): engine.sh defines multi-tier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) * chore: apply manual instructions [skip ci-relay] * chore: apply manual instructions [skip ci-relay] --------- Co-authored-by: donpetry-bot <281750570+donpetry-bot@users.noreply.github.com>
…ier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) (#556) * feat: implement issue #195 — bug(dev-lead): engine.sh defines multi-tier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) * chore: apply manual instructions [skip ci-relay] * chore: apply manual instructions [skip ci-relay] --------- Co-authored-by: donpetry-bot <281750570+donpetry-bot@users.noreply.github.com>
…ier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) (#556) * feat: implement issue #195 — bug(dev-lead): engine.sh defines multi-tier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) * chore: apply manual instructions [skip ci-relay] * chore: apply manual instructions [skip ci-relay] --------- Co-authored-by: donpetry-bot <281750570+donpetry-bot@users.noreply.github.com>
…ier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) (#556) * feat: implement issue #195 — bug(dev-lead): engine.sh defines multi-tier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) * chore: apply manual instructions [skip ci-relay] * chore: apply manual instructions [skip ci-relay] --------- Co-authored-by: donpetry-bot <281750570+donpetry-bot@users.noreply.github.com>
…ier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) (#556) * feat: implement issue #195 — bug(dev-lead): engine.sh defines multi-tier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) * chore: apply manual instructions [skip ci-relay] * chore: apply manual instructions [skip ci-relay] --------- Co-authored-by: donpetry-bot <281750570+donpetry-bot@users.noreply.github.com>
…ier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) (#556) * feat: implement issue #195 — bug(dev-lead): engine.sh defines multi-tier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) * chore: apply manual instructions [skip ci-relay] * chore: apply manual instructions [skip ci-relay] --------- Co-authored-by: donpetry-bot <281750570+donpetry-bot@users.noreply.github.com>
…ier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) (#556) * feat: implement issue #195 — bug(dev-lead): engine.sh defines multi-tier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) * chore: apply manual instructions [skip ci-relay] * chore: apply manual instructions [skip ci-relay] --------- Co-authored-by: donpetry-bot <281750570+donpetry-bot@users.noreply.github.com>
…ier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) (#556) * feat: implement issue #195 — bug(dev-lead): engine.sh defines multi-tier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) * chore: apply manual instructions [skip ci-relay] * chore: apply manual instructions [skip ci-relay] --------- Co-authored-by: donpetry-bot <281750570+donpetry-bot@users.noreply.github.com>
…ier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) (#556) * feat: implement issue #195 — bug(dev-lead): engine.sh defines multi-tier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) * chore: apply manual instructions [skip ci-relay] * chore: apply manual instructions [skip ci-relay] --------- Co-authored-by: donpetry-bot <281750570+donpetry-bot@users.noreply.github.com>
…ier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) (#556) * feat: implement issue #195 — bug(dev-lead): engine.sh defines multi-tier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) * chore: apply manual instructions [skip ci-relay] * chore: apply manual instructions [skip ci-relay] --------- Co-authored-by: donpetry-bot <281750570+donpetry-bot@users.noreply.github.com>
…ier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) (#556) * feat: implement issue #195 — bug(dev-lead): engine.sh defines multi-tier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) * chore: apply manual instructions [skip ci-relay] * chore: apply manual instructions [skip ci-relay] --------- Co-authored-by: donpetry-bot <281750570+donpetry-bot@users.noreply.github.com>
…ier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) (#556) * feat: implement issue #195 — bug(dev-lead): engine.sh defines multi-tier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) * chore: apply manual instructions [skip ci-relay] * chore: apply manual instructions [skip ci-relay] --------- Co-authored-by: donpetry-bot <281750570+donpetry-bot@users.noreply.github.com>
…ier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) (#556) * feat: implement issue #195 — bug(dev-lead): engine.sh defines multi-tier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) * chore: apply manual instructions [skip ci-relay] * chore: apply manual instructions [skip ci-relay] --------- Co-authored-by: donpetry-bot <281750570+donpetry-bot@users.noreply.github.com>
…ier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) (#556) * feat: implement issue #195 — bug(dev-lead): engine.sh defines multi-tier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) * chore: apply manual instructions [skip ci-relay] * chore: apply manual instructions [skip ci-relay] --------- Co-authored-by: donpetry-bot <281750570+donpetry-bot@users.noreply.github.com>
…ier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) (#556) * feat: implement issue #195 — bug(dev-lead): engine.sh defines multi-tier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) * chore: apply manual instructions [skip ci-relay] * chore: apply manual instructions [skip ci-relay] --------- Co-authored-by: donpetry-bot <281750570+donpetry-bot@users.noreply.github.com>
…ier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) (#556) * feat: implement issue #195 — bug(dev-lead): engine.sh defines multi-tier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) * chore: apply manual instructions [skip ci-relay] * chore: apply manual instructions [skip ci-relay] --------- Co-authored-by: donpetry-bot <281750570+donpetry-bot@users.noreply.github.com>
…ier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) (#556) * feat: implement issue #195 — bug(dev-lead): engine.sh defines multi-tier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) * chore: apply manual instructions [skip ci-relay] * chore: apply manual instructions [skip ci-relay] --------- Co-authored-by: donpetry-bot <281750570+donpetry-bot@users.noreply.github.com>
…ier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) (#556) * feat: implement issue #195 — bug(dev-lead): engine.sh defines multi-tier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) * chore: apply manual instructions [skip ci-relay] * chore: apply manual instructions [skip ci-relay] --------- Co-authored-by: donpetry-bot <281750570+donpetry-bot@users.noreply.github.com>
…ier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) (#556) * feat: implement issue #195 — bug(dev-lead): engine.sh defines multi-tier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) * chore: apply manual instructions [skip ci-relay] * chore: apply manual instructions [skip ci-relay] --------- Co-authored-by: donpetry-bot <281750570+donpetry-bot@users.noreply.github.com>
…ier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) (#556) * feat: implement issue #195 — bug(dev-lead): engine.sh defines multi-tier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) * chore: apply manual instructions [skip ci-relay] * chore: apply manual instructions [skip ci-relay] --------- Co-authored-by: donpetry-bot <281750570+donpetry-bot@users.noreply.github.com>
…ier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) (#556) * feat: implement issue #195 — bug(dev-lead): engine.sh defines multi-tier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) * chore: apply manual instructions [skip ci-relay] * chore: apply manual instructions [skip ci-relay] --------- Co-authored-by: donpetry-bot <281750570+donpetry-bot@users.noreply.github.com>
…ier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) (#556) * feat: implement issue #195 — bug(dev-lead): engine.sh defines multi-tier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) * chore: apply manual instructions [skip ci-relay] * chore: apply manual instructions [skip ci-relay] --------- Co-authored-by: donpetry-bot <281750570+donpetry-bot@users.noreply.github.com>
…ier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) (#556) * feat: implement issue #195 — bug(dev-lead): engine.sh defines multi-tier model pipeline but all tasks always invoke ENGINE_ACTION_MODEL (sonnet-4-6) * chore: apply manual instructions [skip ci-relay] * chore: apply manual instructions [skip ci-relay] --------- Co-authored-by: donpetry-bot <281750570+donpetry-bot@users.noreply.github.com>



Closes #195
Implemented by dev-lead agent. Please review.