Skip to content
Agentic Control Plane

Prime Agent Cost Tracking — Registering a Provider for the Proxy

David Crowe David Crowe · · Updated · 8 min read
prime-agent primeintellect cost tokens reference
Share X HN LinkedIn
An ACP session trace: each model call priced with its token and cached-token counts, interleaved with the tool calls it drove — the cost X-ray for one run

Just want the answer? Prime Agent has no cost hook either — register a provider that points at the proxy:

curl -sf https://agenticcontrolplane.com/install.sh | bash

// ~/.prime/agent/extensions/acp-cost.ts
pi.registerProvider("anthropic", {
  baseUrl: "https://api.agenticcontrolplane.com/v1",
});

Full Prime Agent install guide →  ·  Prime Agent's control model, explained →  ·  free up to 5 agents

Prime Agent — PrimeIntellect-ai/prime-agent, a hard fork of pi — kept pi’s minimalism and pushed it further: one model-facing tool (a persistent ipython kernel) instead of pi’s four, wrapped in daemon-backed sessions built for unattended, long-running work. What it inherited from pi along with the minimalism is the honest zero: no permission framework, and no cost tracking either. The control-model reference covers the first gap. This is the second.

No native hook, same as pi

Prime Agent’s two typed extension events, tool_call and tool_result, work exactly as they do in pi — deny or rewrite a call before it runs, redact or rewrite what comes back after. Neither carries a token count. The kernel executes code; it doesn’t report what the model call that produced the code cost, and there’s no third event that would. If you’ve read the pi cost post, the shape of the gap is identical, because Prime Agent didn’t change this part of the fork.

What is different is the stakes: Prime Agent is explicitly built to run longer with less supervision — daemon sessions that persist across restarts, bounded /autonomous mode, recursive subagents. A harness built to run unattended for hours is exactly where an unnoticed cost spike does the most damage before anyone looks.

The provider seam

pi’s model-routing API survived the fork intact: pi.registerProvider(name, config), called from an extension file, re-points a named provider’s baseUrl. Prime Agent’s control-model reference already documents this line as “the metering half of the story” alongside the tool_call/tool_result policy pair — this post is that half, in full.

// ~/.prime/agent/extensions/acp-cost.ts
pi.registerProvider("anthropic", {
  baseUrl: "https://api.agenticcontrolplane.com/v1",
});

Dropped in the global extensions path (~/.prime/agent/extensions/, no trust prompt — where a control extension belongs, per the same reference), this takes effect for every session the daemon hosts. Three lines, no build step — Prime Agent loads TypeScript directly via jiti, same as pi. Anthropic-shaped traffic now transits the ACP proxy, which forwards the request unchanged upstream and reads the token-usage fields off the response on the way through.

What you get

Once registered, every model call Prime Agent makes shows up priced in the console, joined to whatever the tool_call/tool_result extension is separately recording for the ipython kernel:

  • Per-call cost — tokens in and out, priced to dollars, rolled up per session and across the daemon’s restarts
  • Prompt-cache hit rate — worth watching closely here, since a long-running daemon session is exactly where a cold cache compounds unnoticed
  • The loop-vs-leaf split — how much of a long autonomous run is spent re-deriving context versus doing the next step of actual work
  • A policy check on the tool calls the model emits — a second, coarser layer than the extension’s own tool_call interception on the kernel, not a substitute for it

Because Prime Agent’s daemon can keep a session alive across /autonomous continuations and scheduled wakeups, this is closer to a running meter than a single-session report — the console’s per-day rollup is the more useful view for a session that outlives any one terminal window.

Budget limits

Registering the provider is what makes a budget cap possible at all. Workspace-billed traffic is checked against your workspace’s daily LLM cost cap at the gateway, before the call reaches the upstream provider — a session that would exceed it fails closed rather than running up further spend. Bring-your-own-key traffic is billed by whichever provider you’re calling directly; ACP can meter it but can’t enforce a cap on an account it doesn’t hold. Without registerProvider, Prime Agent’s daemon has no cap at all — nothing in its path can see the spend to stop it, which matters more for a harness whose sessions are designed to keep running after you’ve stopped watching.

Cost and policy are still two separate pieces

Registering the provider doesn’t add tool-call policy, and installing the tool_call/tool_result extension doesn’t add cost visibility — they’re unrelated integrations that happen to write to the same console. For Prime Agent specifically, that matters more than it does for most harnesses: because there’s no native permission framework underneath either one, the extension file is the entire control story, cost included. Nothing stops you from shipping only one half, but a daemon that runs unattended for hours is the case where both halves — knowing what it’s allowed to do, and knowing what it’s spending — earn their keep together.

Frequently asked questions

Does Prime Agent track cost natively?

No. Prime Agent is a hard fork of pi that kept pi’s typed extension events (tool_call, tool_result) but ships no permission framework and no usage-metering hook. There’s no built-in dollar figure anywhere in the harness — the same honest zero as pi, and for the same reason: the ipython kernel is the one model-facing tool, and cost was never part of what it reports about itself.

How do you add cost tracking to Prime Agent?

Through the provider seam, not the extension events. Prime Agent inherited pi’s pi.registerProvider(name, { baseUrl }) API, which re-points model traffic at a different endpoint. Pointing it at the ACP proxy (https://api.agenticcontrolplane.com/v1) makes every model call pass through a point that reads token usage off the response and prices it — three lines in an extension file, unrelated to the tool_call/tool_result policy pair.

Does Prime Agent's hasUI bug affect cost tracking?

No — hasUI decides whether an extension prompts for approval on tool_call, which is a policy question. The provider seam that carries cost has no approval step: it forwards every model call through the proxy unconditionally, so the print-mode hasUI bug documented for Prime Agent’s control model doesn’t touch cost visibility at all.

If Prime Agent has no permission framework, does the ACP extension replace one?

Functionally, yes, for tool calls: workspace policy decides allow/ask/deny on every tool_call the ipython kernel would otherwise run unrestricted, and tool_result carries output scanning and the audit ledger. Cost is the second, independent half — the registerProvider call — and together the two pieces are the entire control and visibility story for a harness that ships neither on its own.

Where to read more

Share X HN LinkedIn
Get the next data drop
What agents actually cost, new tool-surface captures, and the occasional incident post-mortem — sent when we publish something worth your inbox, not on a schedule. Unsubscribe anytime.
Share: Twitter LinkedIn
Related posts

← back to blog