feat: add cost policy + refresh model catalog for GitHub AI Credits billing#1089
Open
melodiouscode wants to merge 1 commit into
Open
Conversation
…illing - New GitHubModelCategory, CostPolicyConfig, CostPolicyOutcome types in models.ts - Full updated model catalog: Lightweight/Versatile/Powerful categories - costPolicy field added to schema and ModelSelectionConfig - DEFAULT_FALLBACK_CHAINS updated to current active model IDs - model-selector.ts: two-phase resolution with post-selection cost policy veto - warn-and-allow for explicit overrides exceeding ceiling - automatic downgrade + fallback chain pruning for automatic selections - All squad.agent.md templates and skill files updated with new catalog - New tests: model-selector-policy.test.ts - Deleted dangling test stub (cost-policy.test.ts) -- actual tests in model-selector-policy.test.ts Closes bradygaster#1080 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds cost policy support and refreshes Squad’s GitHub model catalog/fallback chains to align with GitHub AI Credits billing, updating both runtime behavior (SDK) and the synced agent/templates/docs/test suite.
Changes:
- Introduces cost policy types and catalog metadata (GitHub category + included/availability) and updates model pricing/catalog entries.
- Implements two-phase model resolution (base selection → policy enforcement) plus ceiling-aware fallback pruning.
- Propagates the refreshed catalog and cost policy guidance across synced templates/skills and updates/adds tests accordingly.
Reviewed changes
Copilot reviewed 29 out of 30 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| test/telemetry-auto-wiring.test.ts | Updates estimateCost expectations and allows zero-priced “included” models. |
| test/models.test.ts | Refreshes expected model IDs and adds coverage for new catalog fields/category invariants. |
| test/model-selector-policy.test.ts | Adds cost policy behavior tests (warn/allow, downgrade, preferIncluded, pruning). |
| test/model-fallback.test.ts | Updates fallback-chain expectations to new model IDs and semantics. |
| test/integration.test.ts | Aligns integration expectations with updated premium chain start model. |
| test/economy-mode.test.ts | Updates economy-mode mapping expectations for new defaults/IDs. |
| test/config-schema.test.ts | Updates default config expectations for refreshed default/tier models. |
| test/config-integration.test.ts | Aligns config integration assertions with refreshed default model. |
| test/compat-v041.test.ts | Updates compat expectations for refreshed fallback chain start model. |
| test/agents.test.ts | Updates per-agent model selection + fallback chain assertions to refreshed IDs. |
| templates/squad.agent.md.template | Documents two-phase model selection, cost policy, and updated catalog. |
| packages/squad-cli/templates/squad.agent.md.template | CLI template sync of model-selection + cost policy guidance and catalog. |
| packages/squad-sdk/templates/squad.agent.md.template | SDK template sync of model-selection + cost policy guidance and catalog. |
| .squad-templates/squad.agent.md | Canonical template update for cost policy + refreshed catalog. |
| .github/agents/squad.agent.md | Synced agent file update with cost policy and refreshed catalog guidance. |
| packages/squad-sdk/templates/skills/model-selection/SKILL.md | Updates model-selection skill scope/structure for policy + ceiling-aware fallback. |
| packages/squad-cli/templates/skills/model-selection/SKILL.md | CLI skill template sync for updated model-selection behavior. |
| .squad/skills/model-selection/SKILL.md | Project skill sync for updated model-selection behavior. |
| .copilot/skills/model-selection/SKILL.md | Copilot skill sync for updated model-selection behavior. |
| packages/squad-sdk/src/runtime/constants.ts | Refreshes fallback chains and default model constants to current active IDs. |
| packages/squad-sdk/src/runtime/config.ts | Adds config validation for models.costPolicy (maxCategory/preferIncluded). |
| packages/squad-sdk/src/config/schema.ts | Adds costPolicy to config schema and refreshes default tier model lists. |
| packages/squad-sdk/src/config/models.ts | Adds cost policy types, GitHub category metadata, catalog refresh, pricing helper, and economy map updates. |
| packages/squad-sdk/src/agents/model-selector.ts | Adds policy-aware finalize step and new resolution sources; prunes fallbacks by ceiling. |
| packages/squad-sdk/src/agents/index.ts | Re-exports new policy helper functions. |
| .gitignore | Ignores .squad/.scratch/ runtime state. |
| .changeset/cost-policy-billing-update.md | Adds changeset describing SDK/CLI updates for AI Credits transition. |
| package.json | Updates monorepo version (currently to a prerelease -build value). |
| packages/squad-sdk/package.json | Updates SDK package version (currently to a prerelease -build value). |
| packages/squad-cli/package.json | Updates CLI package version (currently to a prerelease -build value). |
Comment on lines
+493
to
500
| ```json | ||
| { | ||
| "costPolicy": { | ||
| "maxCategory": "Versatile", | ||
| "preferIncluded": true | ||
| } | ||
| } | ||
| ``` |
Comment on lines
+493
to
500
| ```json | ||
| { | ||
| "costPolicy": { | ||
| "maxCategory": "Versatile", | ||
| "preferIncluded": true | ||
| } | ||
| } | ||
| ``` |
Comment on lines
+493
to
500
| ```json | ||
| { | ||
| "costPolicy": { | ||
| "maxCategory": "Versatile", | ||
| "preferIncluded": true | ||
| } | ||
| } | ||
| ``` |
Comment on lines
+493
to
500
| ```json | ||
| { | ||
| "costPolicy": { | ||
| "maxCategory": "Versatile", | ||
| "preferIncluded": true | ||
| } | ||
| } | ||
| ``` |
Comment on lines
+493
to
500
| ```json | ||
| { | ||
| "costPolicy": { | ||
| "maxCategory": "Versatile", | ||
| "preferIncluded": true | ||
| } | ||
| } | ||
| ``` |
| | Writing code (implementation, refactoring, test code, bug fixes) | `claude-sonnet-4.6` | Versatile | Best default quality/cost balance for production code. | | ||
| | Writing prompts, agent designs, routing logic, structured system text | `claude-sonnet-4.6` | Versatile | Prompt architecture behaves like code. | | ||
| | Docs, planning, triage, changelogs, logging, mechanical ops | `claude-haiku-4.5` | Lightweight | Cheap default when no stronger policy preference is active. | | ||
| | Visual/design work or image-heavy judgment | `claude-opus-4.7` | Powerful | Highest-stakes reasoning / best vision-capable default. | |
| | Writing code (implementation, refactoring, test code, bug fixes) | `claude-sonnet-4.6` | Versatile | Best default quality/cost balance for production code. | | ||
| | Writing prompts, agent designs, routing logic, structured system text | `claude-sonnet-4.6` | Versatile | Prompt architecture behaves like code. | | ||
| | Docs, planning, triage, changelogs, logging, mechanical ops | `claude-haiku-4.5` | Lightweight | Cheap default when no stronger policy preference is active. | | ||
| | Visual/design work or image-heavy judgment | `claude-opus-4.7` | Powerful | Highest-stakes reasoning / best vision-capable default. | |
| | Writing code (implementation, refactoring, test code, bug fixes) | `claude-sonnet-4.6` | Versatile | Best default quality/cost balance for production code. | | ||
| | Writing prompts, agent designs, routing logic, structured system text | `claude-sonnet-4.6` | Versatile | Prompt architecture behaves like code. | | ||
| | Docs, planning, triage, changelogs, logging, mechanical ops | `claude-haiku-4.5` | Lightweight | Cheap default when no stronger policy preference is active. | | ||
| | Visual/design work or image-heavy judgment | `claude-opus-4.7` | Powerful | Highest-stakes reasoning / best vision-capable default. | |
| | Writing code (implementation, refactoring, test code, bug fixes) | `claude-sonnet-4.6` | Versatile | Best default quality/cost balance for production code. | | ||
| | Writing prompts, agent designs, routing logic, structured system text | `claude-sonnet-4.6` | Versatile | Prompt architecture behaves like code. | | ||
| | Docs, planning, triage, changelogs, logging, mechanical ops | `claude-haiku-4.5` | Lightweight | Cheap default when no stronger policy preference is active. | | ||
| | Visual/design work or image-heavy judgment | `claude-opus-4.7` | Powerful | Highest-stakes reasoning / best vision-capable default. | |
| | Writing code (implementation, refactoring, test code, bug fixes) | `claude-sonnet-4.6` | Versatile | Best default quality/cost balance for production code. | | ||
| | Writing prompts, agent designs, routing logic, structured system text | `claude-sonnet-4.6` | Versatile | Prompt architecture behaves like code. | | ||
| | Docs, planning, triage, changelogs, logging, mechanical ops | `claude-haiku-4.5` | Lightweight | Cheap default when no stronger policy preference is active. | | ||
| | Visual/design work or image-heavy judgment | `claude-opus-4.7` | Powerful | Highest-stakes reasoning / best vision-capable default. | |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Add cost policy support and refresh the GitHub model catalog for the AI Credits billing transition.
What this PR does
Notes on diff size
This PR touches 66 files. The large diff is intentional and expected — the model catalog and \squad.agent.md\ changes propagate to multiple template targets by design:
This is the intended template sync architecture, not branch contamination.
Changeset
Included: .changeset/cost-policy-billing-update.md\
Closes #1080