Skip to content

feat(spend): per-API-key spend scope (spend.apiKey) and opt-in keys on loopback #6156

Closed as not planned

Description

@kakaholigan

Context: we run agent fleets and a human's Codex through one ocx on 127.0.0.1. On loopback, keys are ignored by
design (auth-cors.ts isLoopbackRequestHost), so usage.jsonl rows carry apiKeyId=null. spend.{root,identity,pool}
cannot express "this client's budget".

Ask:

  1. An opt-in config flag to require/resolve bearer keys on loopback too, so apiKeyId is recorded.
  2. A spend scope keyed by API key: spend.apiKey..maxTokens (+ window), enforced like root/pool, refused with
    the same error shape.
  3. Admission checks for spend.identity / spend.pool on the forward path (openai-responses provider to another ocx):
    today these scopes book after the fetch (alreadySent) and never refuse; only root has a pre-dispatch check, so
    no daily or per-account cap is enforceable.

Workaround today: a second instance with its own OPENCODEX_HOME + port (per AGENTS_INSTALL.md) that forwards to the
first, with session_affinity_header mapping each agent session to a root alias. The per-session cap works (429 on
the second instance while the first returns 200), but there is no daily/pool cap and we run two ledgers.

Activity

  1. github-actions commented on Sep 28, 2026

    @github-actions
    Contributor

    Issue closed: use an issue template

    Thanks for taking the time to submit this issue. It was closed automatically because it was not opened with a recognized issue template (Bug report, Feature request, Documentation, or Provider compatibility). Freeform and API-opened issues cannot skip this check.

    • This issue does not use a recognized issue template.

    Please edit the issue to add:

    • Open a new issue with the Bug report, Feature request, Documentation, or Provider compatibility template.
    • Or edit this issue so the body uses the template section headings for the kind of report you are filing.

    See the Contributing guide for details.

    Once the report passes the automated checks, it will be reopened automatically unless a maintainer has changed its state.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions