Skip to content

Add models frontmatter field for custom model pricing#38276

Draft
Copilot wants to merge 4 commits into
mainfrom
copilot/enable-configuring-models-frontmatter
Draft

Add models frontmatter field for custom model pricing#38276
Copilot wants to merge 4 commits into
mainfrom
copilot/enable-configuring-models-frontmatter

Conversation

Copilot AI commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Workflows currently have no way to declare pricing for custom or private models, nor to override built-in cost entries. This adds a models frontmatter field (using the same structure as models.json) that merges into models.json at runtime before AWF receives it.

Approach

Mirrors the existing model_multipliers.json merge pattern exactly:

  1. Compiler serializes the models overlay to JSON → emits as GH_AW_INFO_MODEL_COSTS in the activation job
  2. generate_aw_info.cjs merges it over the built-in models.json → writes /tmp/gh-aw/models.json
  3. Activation artifact includes /tmp/gh-aw/models.json; agent job receives it via GH_AW_MODELS_JSON_PATH

Merge semantics: overlay wins at model granularity (whole model entry replaced); unmentioned providers/models preserved from base.

The models field is disambiguated at parse time: when the value contains a top-level providers key it is treated as a models.json overlay; otherwise it falls through to the deprecated alias-map format for backward compatibility.

Changes

  • Go (frontmatter_types.go, frontmatter_parsing.go, compiler_types.go, workflow_builder.go, compiler_yaml.go) — parse and emit the new field; ParseFrontmatterConfig detects the providers-keyed structure and routes it to ModelCosts
  • awf_helpers.goGH_AW_MODELS_JSON_PATH now points to /tmp/gh-aw/models.json (the merged file) instead of the setup-copied original
  • compiler_activation_job_builder.go — include /tmp/gh-aw/models.json in activation artifact upload
  • merge_frontmatter_models.cjs (new) — mergeModelCosts() + writeMergedModelsJSON(); called from generate_aw_info.cjs
  • main_workflow_schema.jsonmodels property updated to oneOf: providers structure (new) or deprecated alias-array format (backward compat)

Usage

models:
  providers:
    anthropic:
      models:
        my-custom-claude:
          cost:
            input: "3e-06"
            output: "1.5e-05"
            cache_read: "3e-07"
            cache_write: "3.75e-06"

Copilot AI and others added 2 commits June 10, 2026 03:55
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot

  • rename "model-costs" to models
  • same structure as models.json file

Copilot AI and others added 2 commits June 10, 2026 04:35
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

@copilot

  • rename "model-costs" to models
  • same structure as models.json file

Done in 7e7a8bd / e8dc1fd.

  • Renamed the frontmatter field from model-costs to models
  • The models field now accepts the full models.json structure (providers key at root)
  • ParseFrontmatterConfig distinguishes the two formats: when models has a providers key it's routed to ModelCosts (new behavior); otherwise it falls through to the deprecated alias format for backward compatibility
  • Schema updated to use oneOf: providers structure or deprecated alias arrays
  • model-costs property removed from schema

Usage:

models:
  providers:
    anthropic:
      models:
        my-custom-claude:
          cost:
            input: "3e-06"
            output: "1.5e-05"

Copilot AI changed the title Add model-costs frontmatter field for custom model pricing Add models frontmatter field for custom model pricing Jun 10, 2026
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.

2 participants