Skip to content

How to build per-agent budgets with Tray Helix

An agent's cost follows its traffic and its loops, and the month's total arrives too late. Set a budget per agent and check it before every run.

Last reviewed November 2026

App, built with Tray Helix

The short answer

On Tray Helix you set your own budget per agent and enforce it in the app. Each model call returns its token usage, and the agent records it with the model in the app's database. Before each run, a check compares the agent's spend this month with its budget. When the budget is spent, the agent stops, switches to a cheaper model or asks a person to approve the run, whichever you chose.

agent-budgets.helix-app.ai

Agent Budgets

4

Agents with budgets

1

At 90% or more

0

Over budget

Agent Monthly budget Spent this month When spent Model
Ticket triage $400 $362 (91%) Switch to cheaper model Main model
IT access $150 $41 (27%) Ask for approval Main model
CRM hygiene $250 $198 (79%) Stop until next month Main model
Invoice matching $300 $120 (40%) Ask for approval Main model
A sketch of the budgets view. The figures come from the token usage each call returned, priced at the rates you set.

What matters here

  • On Tray Helix you set your own budget per agent, enforced in the app, from the token usage the model provider returns on every call.
  • Record the model and the input and output tokens of every call, priced at the rates you pay for that model.
  • Check the budget before each run starts, so an agent can't spend past it unnoticed.
  • Choose what happens when the budget is spent: stop, switch to a cheaper model, or ask a person to approve the run.
  • Your agent analytics app can show spend against budget per agent, next to the outcomes that spend produced.

Who this is for

You own agents in production and someone has asked what they cost and what stops them costing more. You want a limit per agent that you set, not a surprise at month end.

How it works in practice

From a model call to a run that stops when it should.

  1. 1

    Every model call returns usage

    Model providers return input and output tokens on each call.

  2. 2

    The agent records it

    Agent, run, model and tokens go into the app's database, priced at the rate for that model.

  3. 3

    A check runs before each run

    It adds up this month's spend for the agent and compares it with the budget.

  4. 4

    The rule applies

    Under budget, the run goes ahead. Spent, it stops, switches model or waits for approval.

  5. 5

    Owners see it coming

    A Slack notice at 80% of budget gives the owner time to decide.

What per-agent budgets are made of

A usage record, a rate table, a check and a rule.

A usage record

Each model call: agent, run, model, input tokens, output tokens and time.

A rate table

The price per million input and output tokens for each model, as you pay it. Editable.

A pre-run check

Before each run, this month's spend for the agent against its budget.

A rule per agent

What happens when the budget is spent: stop, switch to a cheaper model, or ask for approval.

The prompts

Paste these into Claude Code, Codex or Cursor in order. Each one leaves you with something that runs, so you can stop after any step.

These prompts start from a Helix project, which is what handles sign-in, credentials and hosting. Start with Helix.

1

Record usage on every call

The numbers a budget depends on.

Claude Code, Codex or Cursor

In my Helix app, record the usage of every model call the agent makes.

Store the agent, the run, the model, input tokens and output tokens as the model provider returns them, and the time.

Keep a rate table I can edit: price per million input tokens and per million output tokens for each model we use. Price each call from it.

2

Budgets and the pre-run check

Stop spending before it happens.

Claude Code, Codex or Cursor

Add a monthly budget per agent, and a rule for when it is spent: stop until next month, switch to a cheaper model I name, or ask for approval before each further run.

Before every run, add up the agent's spend this month and compare it with the budget. Under budget, run as normal. Over budget, apply the rule. Record each decision with the spend and the budget at the time.

At 80% of budget, post the agent's owner in Slack once.

Checking before the run, not after, is what makes this a budget and not a report.
3

The budgets view

Spend against budget, per agent.

Claude Code, Codex or Cursor

Show a budgets view: each agent, its monthly budget, spend this month as an amount and a percentage, the rule, and the model it is running on now. Show a history of budget decisions, and let owners edit their own agent's budget.

4

Connect it to real systems

Where the warnings go.

Claude Code, Codex or Cursor

Now connect it to the systems we actually run.

Anything in angle brackets is a placeholder. Swap it for whatever we use.

<Slack>. Warn owners at 80% of budget and when a budget is spent.

Tray holds the credential as a workspace authentication, so the app references a name and never the secret itself.
5

Ship it

A URL, and the owners on it.

Claude Code, Codex or Cursor

Deploy my app.

Your assistant runs helix deploy and the app comes back as a URL. Set Access Control so owners edit only their own agent's budget.

What it connects to

The usage comes from the model calls. Everything else is in the app.

Named systems are the ones most teams actually run, not a list of the only ones that work. Swap in whatever you use.

Running it for real

The build gets you budgets you set. Running it means changes are reviewed and spend is visible next to outcomes.

  1. 1

    Budget rules ship with the agent

    The check is code in the app, so it deploys from CI, deploy approvals gate changes, and you can roll back any deployment.

  2. 2

    Owners set their own budgets

    SSO and access control decide who can change an agent's budget, and each change is recorded.

  3. 3

    Model keys held by Tray

    Model and system credentials are held in Tray, not in the code.

  4. 4

    Every budget decision logged

    Each pre-run check and its outcome is recorded, and Tray streams agent logs to your SIEM.

  5. 5

    AI usage per app

    Tray shows AI usage per app, next to the per-agent spend your budgets track.

Questions people ask

Can I set a budget per agent on Tray Helix?

Yes, as one you set and enforce in the app. Each run records the token usage the model provider returns, and the model, in the app's database. A check before each run stops it, switches to a cheaper model or asks for approval when that agent's monthly budget is spent.

Where do the cost figures come from?

From the input and output tokens the model provider returns on every call, priced with a rate table you keep in the app.

What happens when an agent's budget runs out?

Whatever rule you set for that agent: stop until next month, switch to a cheaper model, or ask a person to approve each further run.

Can I see spend next to results?

Yes. Your agent analytics app can join the usage records with the outcomes each agent produced, such as resolved tickets, to show cost per outcome.

Build it, then run it properly

Helix is the governed runtime for AI-built apps and agents. Deploy what you build, put SSO in front of it, connect it to your systems with managed credentials, and give it a named owner.