Repository navigation
fix(dev-lead): intent-based model dispatch and fix copilot write fallback #204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
4d4143f
8d4e2cc
6c63d8e
6789814
28374b4
40434c3
2612f50
43b7095
d43f88f
dc6c258
3b54da1
ec023ba
03e225f
e00479b
2b29c86
b16caed
1a99ba7
922fadf
0987378
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ set -euo pipefail | |
|
|
||
| source "$(dirname "$0")/engine.sh" | ||
|
|
||
| INTENT_TYPE="fix-issue" | ||
| ISSUE_NUMBER="${ISSUE_NUMBER:-}" | ||
| REPO="${REPO:-${GITHUB_REPOSITORY:-}}" | ||
| DEV_LEAD_DRY_RUN="${DEV_LEAD_DRY_RUN:-false}" | ||
|
|
@@ -51,7 +52,7 @@ main() { | |
| local branch="dev-lead/issue-${ISSUE_NUMBER}-$(date +%Y%m%d-%H%M)" | ||
| git checkout -b "$branch" | ||
|
|
||
| if ! run_writer_with_fallback "$prompt_file"; then | ||
| if ! run_writer_with_fallback "$prompt_file" "$(model_for_intent "$INTENT_TYPE")"; then | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in commit 8d4e2cc. |
||
| echo "::error::Engine failed to implement issue #${ISSUE_NUMBER}" | ||
| rm -f "$prompt_file" | ||
| exit 1 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ fi | |
|
|
||
| build_and_run() { | ||
| local template_name="$1" | ||
| local model="${2:-$ENGINE_ACTION_MODEL}" | ||
| local prompt_file="/tmp/dev-lead-${template_name}-prompt-$$.md" | ||
| # Export required vars then envsubst | ||
| envsubst < "${PROMPTS_DIR}/${template_name}.md" > "$prompt_file" | ||
|
|
@@ -39,7 +40,7 @@ build_and_run() { | |
| fi | ||
|
|
||
| local rc=0 | ||
| run_writer_with_fallback "$prompt_file" || rc=$? | ||
| run_writer_with_fallback "$prompt_file" "$model" || rc=$? | ||
| rm -f "$prompt_file" | ||
| return "$rc" | ||
|
Comment on lines
46
to
50
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in commit 8d4e2cc. |
||
| } | ||
|
|
@@ -199,7 +200,7 @@ case "$INTENT_TYPE" in | |
| --jq '.data.repository.pullRequest.reviewThreads.nodes | map(select(.isResolved == false))' 2>/dev/null || echo "[]") | ||
| export OPEN_THREADS_JSON | ||
| rc=0 | ||
| build_and_run "fix-reviews" || rc=$? | ||
| build_and_run "fix-reviews" "$(model_for_intent "fix-reviews")" || rc=$? | ||
| [ "$rc" -eq 2 ] && handle_rate_limit "fix-reviews" | ||
| [ "$rc" -eq 0 ] && post_reviews_terminal "fix-reviews" "applied" | ||
| exit "$rc" | ||
|
|
@@ -208,15 +209,15 @@ case "$INTENT_TYPE" in | |
| export PR_NUMBER PR_URL="https://github.com/${REPO}/pull/${PR_NUMBER}" | ||
| export REPO ACTOR="${ACTOR:-}" COMMENT_BODY="${COMMENT_BODY:-}" HEAD_SHA | ||
| rc=0 | ||
| build_and_run "fix-bot-comment" || rc=$? | ||
| build_and_run "fix-bot-comment" "$(model_for_intent "fix-bot-comment")" || rc=$? | ||
| [ "$rc" -eq 2 ] && handle_rate_limit "fix-bot-comment" | ||
| exit "$rc" | ||
| ;; | ||
| human) | ||
| export PR_NUMBER PR_URL="https://github.com/${REPO}/pull/${PR_NUMBER}" | ||
| export REPO ACTOR="${ACTOR:-}" USER_INSTRUCTION="${USER_INSTRUCTION:-}" PR_DESCRIPTION="${PR_DESCRIPTION:-}" | ||
| rc=0 | ||
| build_and_run "human" || rc=$? | ||
| build_and_run "human" "$(model_for_intent "human")" || rc=$? | ||
| [ "$rc" -eq 2 ] && handle_rate_limit "human" | ||
| exit "$rc" | ||
| ;; | ||
|
|
@@ -237,7 +238,7 @@ case "$INTENT_TYPE" in | |
| --jq '.data.repository.pullRequest.reviewThreads.nodes | map(select(.isResolved == false))' 2>/dev/null || echo "[]") | ||
| export OPEN_THREADS_JSON BASE_REF="${BASE_REF:-main}" | ||
| rc=0 | ||
| build_and_run "human-pr" || rc=$? | ||
| build_and_run "human-pr" "$(model_for_intent "human-pr")" || rc=$? | ||
| [ "$rc" -eq 2 ] && handle_rate_limit "human-pr" | ||
| [ "$rc" -eq 0 ] && post_reviews_terminal "human-pr" "applied" | ||
| exit "$rc" | ||
|
|
@@ -258,7 +259,7 @@ case "$INTENT_TYPE" in | |
| CONFLICTING_FILES=$(git merge-tree "$(git merge-base HEAD "origin/${BASE_REF}")" HEAD "origin/${BASE_REF}" 2>/dev/null | grep "^changed in both" | awk '{print $NF}' || true) | ||
| export CONFLICTING_FILES | ||
| rc=0 | ||
| build_and_run "rebase" || rc=$? | ||
| build_and_run "rebase" "$(model_for_intent "rebase")" || rc=$? | ||
| [ "$rc" -eq 2 ] && handle_rate_limit "rebase" | ||
| [ "$rc" -eq 0 ] && post_reviews_terminal "rebase" "applied" | ||
| exit "$rc" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,11 +4,16 @@ set -euo pipefail | |
| # Supports: claude, gemini, copilot | ||
| # | ||
| # Sourced by review-one-pr.sh — provides: | ||
| # run_triage <prompt_file> — no-tool tier (stdout capture) | ||
| # run_agentic <prompt_file> <model> — full-tool tier (stdout) | ||
| # run_duck <prompt_file> <model> — cross-engine adversarial (stdout) | ||
| # run_triage <prompt_file> — no-tool tier (review-one-pr.sh only) | ||
| # run_agentic <prompt_file> <model> — full-tool tier (review-one-pr.sh only) | ||
| # run_duck <prompt_file> <model> — adversarial cross-engine (review-one-pr.sh only) | ||
| # ENGINE_* env vars for model names and labels | ||
| # DUCK_ENGINE / DUCK_MODEL for rubber-duck cross-engine review | ||
| # | ||
| # Sourced by dev-lead scripts — provides: | ||
| # model_for_intent <intent> — select model tier by intent complexity | ||
| # run_writer <prompt_file> [model] — write-capable agent run | ||
| # run_writer_with_fallback <prompt_file> [model] — run with engine fallback | ||
|
|
||
| REVIEW_ENGINE="${REVIEW_ENGINE:-claude}" | ||
| export REVIEW_ENGINE | ||
|
|
@@ -445,6 +450,20 @@ parse_reset_time() { | |
| printf '%s' "${iso:-}" > /tmp/dev-lead-rate-limit-reset | ||
| } | ||
|
|
||
| # model_for_intent <intent> | ||
| # Returns the ENGINE_* model variable appropriate for the intent's complexity. | ||
| # haiku — human-pr, fix-bot-comment: lightweight checks, short-circuit if nothing to do | ||
| # sonnet — fix-reviews, fix-ci, rebase: write operations on known-scope diffs | ||
| # sonnet — fix-issue, human: full agentic feature work (deep = action = sonnet for now) | ||
| model_for_intent() { | ||
| case "${1:-}" in | ||
| human-pr|fix-bot-comment) echo "$ENGINE_TRIAGE_MODEL" ;; | ||
| fix-reviews|fix-ci|rebase) echo "$ENGINE_ACTION_MODEL" ;; | ||
| fix-issue|human) echo "$ENGINE_DEEP_MODEL" ;; | ||
| *) echo "$ENGINE_ACTION_MODEL" ;; | ||
| esac | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
|
|
||
| # run_writer <prompt_file> [model] | ||
| # Full write-access mode for applying code fixes. | ||
| # When DEV_LEAD_DRY_RUN=true: builds prompt but does NOT call engine; exits 0. | ||
|
|
@@ -483,15 +502,10 @@ run_writer() { | |
| < "$prompt_file" | tee "$_tmp" || rc=${PIPESTATUS[0]} | ||
| ;; | ||
| copilot) | ||
| # Copilot (gh copilot suggest) is text-only — falls back to Claude for write ops | ||
| echo "::warning::Copilot engine is text-only; falling back to Claude for write operations" >&2 | ||
| local saved="$REVIEW_ENGINE" | ||
| REVIEW_ENGINE="claude" timeout "$ACTION_TIMEOUT_SEC" claude --print \ | ||
| --model "$model" \ | ||
| --permission-mode acceptEdits \ | ||
| --allowed-tools "Bash,Read,Write,Edit,Grep,Glob" \ | ||
| < "$prompt_file" | tee "$_tmp" || rc=${PIPESTATUS[0]} | ||
| REVIEW_ENGINE="$saved" | ||
| # GitHub Models REST API — text-only, no Write/Edit tool access. | ||
| # The rate-limit text (HTTP 429) is echoed to stdout by copilot_chat so | ||
| # is_rate_limited() will fire and return exit 2 for engine fallback. | ||
| copilot_chat "$prompt_file" "$ACTION_TIMEOUT_SEC" | tee "$_tmp" || rc=${PIPESTATUS[0]} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in commit 8d4e2cc. The copilot case in |
||
| ;; | ||
|
Comment on lines
524
to
532
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in commit 8d4e2cc. The copilot case in
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not a good solution. Waiting for Claude to become available is not an acceptable solution. If we can't use Copilot with this architecture then we should disable it until we can design a valid approach. Should we be using GitHub Agentic Workflows? https://github.github.com/gh-aw/ |
||
| esac | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit 8d4e2cc.
model_for_intentnow returns a tier key ("triage"/"action"/"deep") instead of a concrete model string.run_writer_with_fallbackcalls_setup_engine_vars($engine)before each invocation soENGINE_*_MODELvars are correct for each provider in the fallback chain.run_writerresolves the tier against those vars, so Gemini and Copilot always receive their own compatible model IDs.