Skip to content

Refactor AI credits pricing to a single shared type and schema ref#47723

Merged
pelikhan merged 11 commits into
mainfrom
copilot/unify-ai-credits-pricing-data
Jul 24, 2026
Merged

Refactor AI credits pricing to a single shared type and schema ref#47723
pelikhan merged 11 commits into
mainfrom
copilot/unify-ai-credits-pricing-data

Conversation

Copilot AI commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

models.providers.*.models.*.cost and models.default-ai-credits-pricing diverged in representation, which made pricing handling inconsistent across workflow parsing and AWF config emission. This PR unifies both paths around one Go type and one schema ref while preserving stricter constraints for default fallback pricing.

  • Go type unification

    • Reused AiCreditsPricingConfig for AWF apiProxy.defaultAiCreditsPricing instead of a duplicate AWF-only struct.
    • Added JSON tags to AiCreditsPricingConfig so serialized config remains {"input": ..., "output": ...}.
  • Schema unification

    • Reused $defs/ai_credits_pricing for models.providers.*.models.*.cost.
    • Kept models.default-ai-credits-pricing strict (input/output required, numeric, non-negative) via allOf layering on top of the shared ref.
  • Schema behavior coverage

    • Added parser schema tests for models.providers pricing:
      • accepts numeric and numeric-string token-class values
      • rejects invalid value types
"default-ai-credits-pricing": {
  "allOf": [
    { "$ref": "#/$defs/ai_credits_pricing" },
    {
      "required": ["input", "output"],
      "properties": {
        "input": { "type": "number", "minimum": 0 },
        "output": { "type": "number", "minimum": 0 }
      },
      "additionalProperties": false
    }
  ]
}

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 18.1 AIC · ⌖ 7.64 AIC · ⊞ 7K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 8.47 AIC · ⌖ 7.95 AIC · ⊞ 7K ·
Comment /souschef to run again


PR Sous Chef run marker

Run: https://github.com/github/gh-aw/actions/runs/30117832197

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 14 AIC · ⌖ 9.05 AIC · ⊞ 7K ·
Comment /souschef to run again

Copilot AI and others added 2 commits July 24, 2026 05:58
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title refactor: unify AI credits pricing types and schema refs Refactor AI credits pricing to a single shared type and schema ref Jul 24, 2026
Copilot AI requested a review from pelikhan July 24, 2026 06:07
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot default ai pricing also support cached write, read, etc... unify to a single type with all the field (see awf spec)_

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

@copilot default ai pricing also support cached write, read, etc... unify to a single type with all the field (see awf spec)_

Updated in 977dea2. models.default-ai-credits-pricing now supports cached read/write fields, and the unified AiCreditsPricingConfig carries those through to apiProxy.defaultAiCreditsPricing (cachedInput/cacheWrite) with schema and test coverage.

@github-actions

Copy link
Copy Markdown
Contributor

🤖 PR Triage

Field Value
Category refactor
Risk 🟡 Medium
Score 38 / 100
Action ⏸️ defer

Score breakdown: Impact 20 · Urgency 8 · Quality 10

Summary: DRAFT. Unifies AI credits pricing Go type and JSON schema — valid cleanup but no urgency. No reviews yet. Defer until draft is ready and higher-priority work is cleared.

Next action: Author should undraft when ready for review.

Generated by 🔧 PR Triage Agent · sonnet46 · 49.5 AIC · ⌖ 5.34 AIC · ⊞ 5.7K ·

@github-actions

Copy link
Copy Markdown
Contributor

Great work on this refactor! 👏 This PR beautifully consolidates the AI credits pricing representation across the codebase — unifying the schema definition and Go types while maintaining stricter validation for the default pricing config.

What stands out:

  • ✅ Focused scope: All changes serve a single goal (pricing unification)
  • ✅ Comprehensive tests: New test coverage for models.providers pricing behavior (numeric values, numeric-strings, invalid types)
  • ✅ Clear diff: Type consolidation and schema layering with allOf is well-structured
  • ✅ Detailed PR description: Problem, solution, and code example make the intent clear

This looks ready for core team review. The refactor should make pricing handling more maintainable and less error-prone going forward. 🎯

Generated by ✅ Contribution Check · sonnet46 · 56.3 AIC · ⌖ 7.56 AIC · ⊞ 6.2K ·

@github-actions

Copy link
Copy Markdown
Contributor

🤖 PR Triage

Field Value
Category refactor
Risk medium
Priority Score 40/100
Score Breakdown Impact: 20 · Urgency: 10 · Quality: 10
Recommended Action defer
CI ⚪ unknown (no checks)

Rationale: DRAFT. Schema/type unification for AI credits pricing. Non-critical path refactor; good description but still a draft with no CI. Defer until undrafted and CI passes.

Generated by 🔧 PR Triage Agent · sonnet46 · 32.4 AIC · ⌖ 5.13 AIC · ⊞ 5.7K ·

@pelikhan
pelikhan marked this pull request as ready for review July 24, 2026 15:09
Copilot AI review requested due to automatic review settings July 24, 2026 15:09
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot resolve the merge conflicts on this branch.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Unifies AI credit pricing types and schema references across workflow parsing and AWF config generation.

Changes:

  • Reuses AiCreditsPricingConfig, including cache pricing fields.
  • Shares the pricing schema while retaining strict fallback validation.
  • Adds schema, extraction, serialization, and workflow coverage.
Show a summary per file
File Description
pkg/workflow/workflow_builder.go Extracts cache pricing.
pkg/workflow/sandbox.go Adds JSON tags and cache fields.
pkg/workflow/frontmatter_extraction_security_test.go Tests cache extraction.
pkg/workflow/awf_config.go Reuses the shared pricing type.
pkg/workflow/awf_config_test.go Tests AWF cache pricing output.
pkg/parser/schemas/main_workflow_schema.json Unifies pricing schemas.
pkg/parser/schema_test.go Tests pricing validation behavior.
.github/workflows/daily-byok-ollama-test.lock.yml Regenerates fallback pricing output.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 8/8 changed files
  • Comments generated: 1
  • Review effort level: Medium

Comment thread pkg/parser/schemas/main_workflow_schema.json Outdated

Copilot AI commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

origin/main is already merged into this branch and there are no remaining merge conflicts. Current merge commit is 17d515e.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

@copilot unify types ai_credits_pricing and default_ai_credits_pricing - same type

Done in 6e59c45. models.default-ai-credits-pricing now directly reuses #/$defs/ai_credits_pricing, so both default pricing and provider model cost use the same schema type.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, update this branch if needed, and rerun checks once the branch is ready. Current PR status shows pending checks on the latest head; if those are stale, please confirm and retrigger the appropriate validation after updating the branch.

Run: https://github.com/github/gh-aw/actions/runs/30110451496

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 18.1 AIC · ⌖ 7.64 AIC · ⊞ 7K ·
Comment /souschef to run again

Copilot AI and others added 2 commits July 24, 2026 17:14
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, update this branch if needed, and rerun checks once the branch is ready. Current PR status shows pending checks on the latest head; if those are stale, ple...

Done on branch head cdd4617.

  • Applied and validated the outstanding schema/test fix from the unresolved review thread (numeric-string enforcement for pricing values).
  • Ran local validation: make fmt, make lint, make test-unit, make test, and make agent-report-progress.
  • Confirmed the referenced run 30110451496 is successful and has no failed jobs.

Checks on prior heads are now stale after the new push from this agent. I can’t reliably retrigger PR CI from this environment; a maintainer should re-trigger checks (close/reopen PR, workflow_dispatch, or a maintainer push).

Copilot AI requested a review from gh-aw-bot July 24, 2026 17:20
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, update this branch if needed, address unresolved review feedback, and rerun or retrigger checks once the branch is up to date.

Unresolved review feedback:

Run: https://github.com/github/gh-aw/actions/runs/30115096773

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 8.47 AIC · ⌖ 7.95 AIC · ⊞ 7K ·
Comment /souschef to run again

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, update this branch if needed, address unresolved review feedback, and rerun or retrigger checks once the branch is up to date.

Unresolved review feedback:...

Done on head f2e443c.

  • Ran PR finisher triage and verified there are no unresolved in-scope review threads; the referenced feedback thread is already resolved.
  • Verified prior referenced run 30115096773 is successful and has 0 failed jobs.
  • Ran local validation: make fmt, make lint, TEST_UNIT_RUN_FULL=1 make test-unit, make test, and make recompile.
  • Branch is up to date with main via merge commit 7e84db1.
  • Checks for current head are already retriggered and currently active (CWI in progress, CGO queued, Doc Build succeeded).

@github-actions

Copy link
Copy Markdown
Contributor

🤖 PR Triage

Field Value
Category refactor
Risk 🟡 Medium
Score 44/100
Score breakdown impact=22, urgency=8, quality=14
Recommended action batch_review

Rationale: Unifies AI credits pricing representation across Go types and JSON schema. Well-described with added schema behavior tests. CI mostly passing but build-wasm is failing. Can be batch-reviewed with other schema/type refactors.

Blockers: build-wasm CI failure needs investigation.

Generated by 🔧 PR Triage Agent · sonnet46 · 39.2 AIC · ⌖ 4.9 AIC · ⊞ 5.7K ·

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, confirm the branch is up to date, verify the previously referenced unresolved feedback is fully resolved on the current head, and rerun or retrigger any remaining checks as needed.

Failed checks on the latest head:

Run: https://github.com/github/gh-aw/actions/runs/30117832197

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 14 AIC · ⌖ 9.05 AIC · ⊞ 7K ·
Comment /souschef to run again

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
@pelikhan
pelikhan merged commit 228021a into main Jul 24, 2026
23 checks passed
@pelikhan
pelikhan deleted the copilot/unify-ai-credits-pricing-data branch July 24, 2026 20:11
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.83.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants