Skip to content

docs: gmi() accepts budget; it refuses voice, avatar and channels - #625

Merged
jddunn merged 2 commits into
masterfrom
docs/gmi-accepts-budget
Oct 28, 2026
Merged

jddunn merged 2 commits into
masterfrom
docs/gmi-accepts-budget

Conversation

@jddunn

@jddunn jddunn commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Summary

gmi() and agent({ runtime: 'gmi' }) have taken budget since #382 merged on 16 October. The completion gateway checks every step of a turn against it, and the GMI's provider manager checks every metaprompt call. Two pages still said the GMI path throws when it is given a budget:

  • docs/GMI.md: the comparison table and the Construction paragraph.
  • docs/safety/COST_OPTIMIZATION.md: the spend budget section.

The options gmi() refuses at construction are voice, avatar and channels. This change makes both pages say so, and says what the GMI path does with a budget:

  • docs/GMI.md gets a Spend budget paragraph, which the gmi() doc comment already refers to. It covers the agent's budget and the per-call and per-send ones, what is checked and recorded, and the error a refused step ends the turn with. That error is the GMI's LLM_PROVIDER_ERROR error, not CostCapExceededError.
  • docs/GMI.md also listed the per-call options of generate() and stream() without abortSignal and budget, and said they throw on any other option. It listed the options of a session's send() and stream() without budget. All of these lists now match the code.
  • docs/safety/COST_OPTIMIZATION.md gets an On a GMI paragraph with the same facts, and notes that a session's send() and stream() take a budget on both runtimes.

docs/API_PATHS.md carries the same claim. #617 already fixes it on its own branch, so this change leaves that page alone. docs.agentos.sh builds these two pages from this repository, so the site keeps no copies to fix.

Linked issues

None.

Type of change

  • Bug fix
  • Feature
  • Performance
  • Documentation
  • Refactor
  • Tests
  • Build or CI

How this was verified

Every sentence was checked against master (41e2ded): src/api/gmi.ts (UNSUPPORTED_ON_GMI, the per-call options, the budget check before each attempt, the session's send() and stream()), src/api/runtime/gatewayProviderManager.ts, src/api/runtime/gmiSession.ts and src/api/runtime/spendBudget.ts. src/api/__tests__/gmi-runtime.budget.test.ts already covers the behavior the pages describe. The rest is this pull request's CI.

Migration notes

None.

Checklist

  • Tests cover the changed behavior.
  • Docs are updated.
  • The title follows Conventional Commits, with ! before the colon for a change that breaks users (feat!: or feat(api)!:).
  • No secrets or private data are included.
  • Every automated review thread is settled (how).
  • I have read this change and can explain every line.

Summary by Sourcery

Clarify GMI capabilities and spend-budget behavior across the user-facing documentation.

Documentation:

  • Update GMI documentation to accurately describe supported spend budgets, budget enforcement, per-call and session options, and unsupported construction options.
  • Document GMI budget behavior and error handling in the cost optimization guide.

Summary by CodeRabbit

  • Documentation
    • Clarified how to set and override spending budgets for GMI agents, sessions, and one-shot requests.
    • Explained when budgets are checked, which costs count, and how budget limits affect completion steps and metaprompt calls.
    • Documented that refused completion steps end the turn with an error, while refused metaprompt calls leave the current reply unchanged.

gmi() and agent({ runtime: 'gmi' }) have taken `budget` since #382: the
completion gateway checks every step of a turn against it and the GMI's
provider manager every metaprompt call. GMI.md and COST_OPTIMIZATION.md
still said the GMI path throws when it is given a budget. The options it
refuses at construction are voice, avatar and channels.

GMI.md also listed the per-call options of generate() and stream()
without abortSignal and budget, and the options of a session's send()
and stream() without budget, though the GMI path takes them. A new Spend
budget paragraph in GMI.md, and an On a GMI paragraph in
COST_OPTIMIZATION.md, say what the GMI path does with a budget,
including the error a refused step ends the turn with.
@jddunn
jddunn requested a review from Victor-Evogor as a code owner October 28, 2026 14:13
@sourcery-ai

sourcery-ai Bot commented Oct 28, 2026

Copy link
Copy Markdown

Sorry @jddunn, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 3 days and 11 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T14:27:05.141516Z a7abf9b Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@sourcery-ai

sourcery-ai Bot commented Oct 28, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Documentation now accurately describes GMI support for shared and per-call spend budgets, its unsupported construction options, API option surfaces, enforcement points, accounting, and error behavior.

Sequence diagram for GMI spend budget enforcement

sequenceDiagram
    participant Caller
    participant GMI
    participant Gateway as CompletionGateway
    participant Manager as ProviderManager
    participant Provider
    participant Budget as SpendBudget

    Caller->>GMI: agent.generate() or session.send()
    GMI->>Gateway: completion call
    Gateway->>Budget: check completion budget
    alt budget permits step
        Gateway->>Provider: send completion request
        Provider-->>Gateway: result or billed failure
        Gateway->>Budget: record finished or billed step
        Gateway-->>GMI: completion result
    else budget refuses step
        Gateway-->>GMI: LLM_PROVIDER_ERROR
        GMI-->>Caller: reject or stream error part
    end

    GMI->>Manager: metaprompt call
    Manager->>Budget: check metaprompt budget
    alt budget permits metaprompt
        Manager->>Provider: send metaprompt request
        Provider-->>Manager: metaprompt result
        Manager->>Budget: record metaprompt call
    else budget refuses metaprompt
        Manager-->>GMI: leave turn reply unchanged
    end
Loading

File-Level Changes

Change Details Files
Updated GMI capability and construction documentation to distinguish unsupported options from supported spend budgets.
  • Removed budget from the list of options rejected at construction.
  • Documented validation errors for invalid budget limits and retained rejection of voice, avatar, and channels.
  • Added the GMI spend-budget behavior, including shared and per-call budgets, completion and metaprompt checks, accounting, callbacks, and failure semantics.
docs/GMI.md
Aligned GMI API option lists and budget behavior with the implemented runtime surface.
  • Added budget and abortSignal to the documented per-call and session method options.
  • Documented that budget refusals surface as GMI LLM_PROVIDER_ERROR failures rather than CostCapExceededError.
  • Clarified stream, fallback, metaprompt, external-cost, and cognitive-memory budget behavior.
docs/GMI.md
docs/safety/COST_OPTIMIZATION.md
Corrected cost-optimization guidance for GMI runtimes.
  • Removed the claim that GMI rejects all budgets.
  • Added GMI-specific budget enforcement and accounting details, including session-level budget overrides.
docs/safety/COST_OPTIMIZATION.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can turn on the rule miner and Qodo learns your standards from review history

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Document GMI spend budgets and supported options

📝 Documentation 🕐 10-20 Minutes

Grey Divider

AI Description

• Correct documentation that said GMI rejects budgets; only voice, avatar, and channels are
 unsupported at construction.
• Explain shared and per-call budgets, enforcement, metaprompt accounting, and refusal errors.
• Add missing budget and abort-signal options to GMI call and session documentation.
Diagram

graph TD
  A["GMI calls"] --> B["Effective budget"] --> C["Completion gateway"] --> D{"Budget permits?"} -->|yes| E["Completion call"]
  B --> F["Provider manager"] -->|checks budget| G["Metaprompt call"]
  D -->|no| H["GMI error"]
Loading
High-Level Assessment

Correcting both the GMI reference and the spend-budget guide is appropriate: readers encounter the outdated claim in both places. Consolidating the explanation into one page would reduce repetition but make the other less useful on its own.

Files changed (2) +9 / -5

Documentation (2) +9 / -5
GMI.mdCorrect GMI construction and call-option guidance +6/-4

Correct GMI construction and call-option guidance

• Removes budget from the construction options described as unsupported and documents budget validation instead. Adds missing budget and abort-signal call options, plus a spend-budget section covering sharing, enforcement, accounting, and GMI refusal behavior.

docs/GMI.md

COST_OPTIMIZATION.mdExplain spend budgets on GMI agents +3/-1

Explain spend budgets on GMI agents

• Removes the claim that the GMI runtime rejects budgets and clarifies session-level budget overrides. Adds GMI-specific guidance on completion and metaprompt checks, accounting, refusal errors, and unmetered cognitive-memory embeddings.

docs/safety/COST_OPTIMIZATION.md

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 41e2ded and a7abf9b.

Files selected for processing: 2
  • docs/GMI.md
  • docs/safety/COST_OPTIMIZATION.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

Walkthrough

The documentation now describes GMI budget settings, per-call overrides, and one-shot cancellation options. It also explains budget validation, checks and cost recording for completion and metaprompt calls, and the outcomes when those calls are refused.

Changes: GMI budget documentation

Layer / File(s) Summary
Budget options and validation
docs/GMI.md, docs/safety/COST_OPTIMIZATION.md
The documentation describes accepted budget settings and validation, session and one-shot budget options, and one-shot abortSignal behavior.
GMI spend-budget behavior
docs/GMI.md, docs/safety/COST_OPTIMIZATION.md
The documentation describes shared and per-call budgets, checks and cost recording for completion and metaprompt calls, refusal outcomes, limit callback labels, and excluded embedding calls.

Priority: Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Other

Merge Risk: Minimal · up to a7abf

The documentation updates present no identified merge-blocking risk.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title clearly identifies the main documentation changes: GMI budget support and refusal of unsupported construction options.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description includes all required template sections. It provides a clear summary, change type, verification details, migration notes, and completed checklist items.
Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

On the GMI path a refusal for a model with no price row ends the turn with the GMI's LLM_PROVIDER_ERROR error as a cap refusal does, so neither error class reaches the caller.
@jddunn

jddunn commented Oct 28, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: a7abf9b6fd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jddunn
jddunn merged commit 4e67b44 into master Oct 28, 2026
20 checks passed
@jddunn
jddunn deleted the docs/gmi-accepts-budget branch October 28, 2026 14:30
@jddunn jddunn mentioned this pull request Oct 28, 2026
6 of 13 tasks
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.

1 participant