aaif-goose / aaif-goose/goose

Estimate costs through canonical provider aliases

Open
#11,786 5 comments 0 reactions 1 assignee Assigned to @bioinfornatics View on GitHub
Dominant language
Rust
Stars
54.2k
Forks
6.2k
Avg merge
3d 4h
Merged PRs (30d)
240

Description

**What problem would this solve?**

Goose can receive usage tokens without receiving a provider-reported cost. In that case, provider aliases and hosting providers may fail to resolve public pricing even when the underlying model is known.

Two concrete cases are:

- ChatGPT Codex serves OpenAI GPT models, but its Goose provider ID does not match the OpenAI catalog namespace.
- Azure Foundry deployments can use custom deployment names and host models from OpenAI, Anthropic, DeepSeek, Mistral, Meta, Microsoft, and other publishers. Pricing must use deployment metadata's underlying model rather than assuming every Azure model is OpenAI.

**What would a good outcome look like?**

When a provider does not report cost, Goose should calculate a clearly identified public-price estimate from the canonical model catalog:

- `chatgpt_codex/gpt-*` resolves through the OpenAI catalog.
- Azure Foundry project deployments retain their deployment alias on the wire but use the discovered underlying model for pricing and capabilities.
- Recognizable resource and MaaS model names resolve through controlled canonical publisher inference.
- Open-weight models with zero publisher rates use a non-zero host catalog rate when one exists.
- Unknown or ambiguous models remain unpriced instead of receiving an arbitrary estimate.
- Provider-reported cost remains authoritative.
- The legacy and state-machine agent loops behave identically.

**Possible approaches**

- Add `chatgpt_codex` as a canonical alias for `openai`.
- Reuse Azure Foundry deployment metadata already returned by `/deployments` and carry its underlying `modelName` in `ProviderUsage.model`.
- Keep one shared cost-resolution helper for both agent loops.
- Add a regression matrix for OpenAI, Anthropic, DeepSeek, Mistral, Meta/open-weight, Microsoft Phi, and unknown models.
- Describe fallback values as public estimates rather than invoices.

**Additional context**

A candidate implementation is available on [`bioinfornatics:feat/adaptive-default-cost-estimates`](https://github.com/bioinfornatics/goose/tree/feat/adaptive-default-cost-estimates), commit [`741edd9c5`](https://github.com/bioinfornatics/goose/commit/741edd9c5).

Validation completed:

- `cargo build --release -p goose-cli`
- `cargo fmt --check`
- `cargo clippy --all-targets -- -D warnings`
- 16 canonical-model tests
- 22 Azure Foundry tests
- 16 canonical-cost tests
- independent reviews by `gpt-5.6-sol`, `claude-sonnet-5`, and `DeepSeek-V4-Flash`, all returning ACCEPT

- [x] I have verified this does not duplicate an existing feature request

Please add this issue to the [Goose Issues board](https://github.com/orgs/aaif-goose/projects/1) and move it to **Ready** if the scope is approved. The upstream PR will be opened only after that gate.

Contributor guide

Open the contributing guide

Research direction

The issue involves cost estimation logic in the Goose backend. Start by examining the candidate implementation branch `feat/adaptive-default-cost-estimates` and commit `741edd9c5`. Look for the shared cost-resolution helper and the provider alias mapping. Review the existing tests (canonical-model, Azure Foundry, canonical-cost) to understand the expected behavior. The change touches provider usage handling and pricing resolution across multiple model catalogs.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.