Skip to content

feat: add cost policy + refresh model catalog for GitHub AI Credits billing#1089

Open
melodiouscode wants to merge 1 commit into
bradygaster:devfrom
melodiouscode:melodiouscode/1080-cost-policy-billing-update
Open

feat: add cost policy + refresh model catalog for GitHub AI Credits billing#1089
melodiouscode wants to merge 1 commit into
bradygaster:devfrom
melodiouscode:melodiouscode/1080-cost-policy-billing-update

Conversation

@melodiouscode
Copy link
Copy Markdown

@melodiouscode melodiouscode commented May 5, 2026

Summary

Add cost policy support and refresh the GitHub model catalog for the AI Credits billing transition.

What this PR does

  • New types: \GitHubModelCategory, \CostPolicyConfig, \CostPolicyOutcome\ in \models.ts\
  • Updated model catalog: Full Lightweight/Versatile/Powerful category mapping with credit costs and included-model flags
  • \costPolicy\ config field: Added to \ModelSelectionConfig\ and schema
  • Updated fallback chains: \DEFAULT_FALLBACK_CHAINS\ refreshed to current active model IDs
  • Two-phase model resolution in \model-selector.ts:
    • Post-selection cost policy veto (warn-and-allow for explicit Layer 0/1 overrides, auto-downgrade for Layer 2-4)
    • Ceiling-aware fallback chain pruning
  • Template sync: All \squad.agent.md\templates and skill files updated with new catalog
  • New tests: \test\model-selector-policy.test.ts\ — full cost policy coverage
  • Cleanup: Removed dangling \test/cost-policy.test.ts\ stub (tests live in \model-selector-policy.test.ts)

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:

  • .squad-templates/\ (root templates)
  • \packages/squad-cli/templates/\
  • \packages/squad-sdk/templates/\
  • .github/agents/squad.agent.md\
  • .squad/skills/model-selection/SKILL.md\ + .copilot/skills/model-selection/SKILL.md\

This is the intended template sync architecture, not branch contamination.

Changeset

Included: .changeset/cost-policy-billing-update.md\

  • @bradygaster/squad-sdk: minor
  • @bradygaster/squad-cli: patch

Closes #1080

…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>
@melodiouscode melodiouscode marked this pull request as ready for review May 8, 2026 18:08
Copilot AI review requested due to automatic review settings May 8, 2026 18:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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. |
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.

feat: add cost policy support and refresh model catalog for GitHub AI Credits billing

2 participants