-
Notifications
You must be signed in to change notification settings - Fork 6
feat: add multi-provider model tier support to runner and cron helpers (t132.7) #789
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
Merged
+138
−8
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -890,6 +890,94 @@ cleanup_sqlite_backups() { | |||||||
| # Export all constants for use in other scripts | ||||||||
| # ============================================================================= | ||||||||
|
|
||||||||
| # ============================================================================= | ||||||||
| # Model tier resolution (t132.7) | ||||||||
| # Shared function for resolving tier names to full provider/model strings. | ||||||||
| # Used by runner-helper.sh, cron-helper.sh, cron-dispatch.sh. | ||||||||
| # Tries: 1) fallback-chain-helper.sh (availability-aware) | ||||||||
| # 2) Static mapping (always works) | ||||||||
| # ============================================================================= | ||||||||
|
|
||||||||
| ####################################### | ||||||||
| # Resolve a model tier name to a full provider/model string (t132.7) | ||||||||
| # Accepts both tier names (haiku, sonnet, opus, flash, pro, grok, coding, eval, health) | ||||||||
| # and full provider/model strings (passed through unchanged). | ||||||||
| # Returns the resolved model string on stdout. | ||||||||
| ####################################### | ||||||||
| resolve_model_tier() { | ||||||||
| local tier="${1:-coding}" | ||||||||
|
|
||||||||
| # If already a full provider/model string (contains /), return as-is | ||||||||
| if [[ "$tier" == *"/"* ]]; then | ||||||||
| echo "$tier" | ||||||||
| return 0 | ||||||||
| fi | ||||||||
|
|
||||||||
| # Try fallback-chain-helper.sh for availability-aware resolution | ||||||||
| local chain_helper="${BASH_SOURCE[0]%/*}/fallback-chain-helper.sh" | ||||||||
|
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. To adhere to the repository style guide (line 11), please separate the declaration and assignment of this local variable.
Suggested change
References
|
||||||||
| if [[ -x "$chain_helper" ]]; then | ||||||||
| local resolved | ||||||||
| resolved=$("$chain_helper" resolve "$tier" --quiet 2>/dev/null) || true | ||||||||
| if [[ -n "$resolved" ]]; then | ||||||||
| echo "$resolved" | ||||||||
| return 0 | ||||||||
| fi | ||||||||
| fi | ||||||||
|
|
||||||||
| # Static fallback: map tier names to concrete models | ||||||||
| case "$tier" in | ||||||||
| opus|coding) | ||||||||
| echo "anthropic/claude-opus-4-6" | ||||||||
| ;; | ||||||||
| sonnet|eval) | ||||||||
| echo "anthropic/claude-sonnet-4-20250514" | ||||||||
| ;; | ||||||||
| haiku|health) | ||||||||
| echo "anthropic/claude-3-5-haiku-20241022" | ||||||||
| ;; | ||||||||
| flash) | ||||||||
| echo "google/gemini-2.5-flash-preview-05-20" | ||||||||
| ;; | ||||||||
| pro) | ||||||||
| echo "google/gemini-2.5-pro-preview-06-05" | ||||||||
| ;; | ||||||||
| grok) | ||||||||
| echo "xai/grok-3" | ||||||||
| ;; | ||||||||
| *) | ||||||||
| # Unknown tier — return as-is (may be a model name without provider) | ||||||||
| echo "$tier" | ||||||||
| ;; | ||||||||
| esac | ||||||||
|
|
||||||||
| return 0 | ||||||||
| } | ||||||||
|
|
||||||||
| ####################################### | ||||||||
| # Detect available AI CLI backends (t132.7) | ||||||||
| # Returns a newline-separated list of available backends. | ||||||||
| # Checks: opencode, claude | ||||||||
| ####################################### | ||||||||
| detect_ai_backends() { | ||||||||
| local -a backends=() | ||||||||
|
|
||||||||
| if command -v opencode &>/dev/null; then | ||||||||
| backends+=("opencode") | ||||||||
| fi | ||||||||
|
|
||||||||
| if command -v claude &>/dev/null; then | ||||||||
| backends+=("claude") | ||||||||
| fi | ||||||||
|
|
||||||||
| if [[ ${#backends[@]} -eq 0 ]]; then | ||||||||
| echo "none" | ||||||||
| return 1 | ||||||||
| fi | ||||||||
|
|
||||||||
| printf '%s\n' "${backends[@]}" | ||||||||
| return 0 | ||||||||
| } | ||||||||
|
|
||||||||
| # This ensures all constants are available when this file is sourced | ||||||||
| export CONTENT_TYPE_JSON CONTENT_TYPE_FORM USER_AGENT | ||||||||
| export HTTP_OK HTTP_CREATED HTTP_BAD_REQUEST HTTP_UNAUTHORIZED HTTP_FORBIDDEN HTTP_NOT_FOUND HTTP_INTERNAL_ERROR | ||||||||
|
|
||||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The repository style guide (line 11) requires declaring and assigning local variables on separate lines for safety under
set -e. This line combines both operations.References
local var="$1"pattern in functions, declaring and assigning separately for exit code safety. (link)