Skip to content

Uni-CLI — Agent-Native Command Budget

Honest measurement of the context budget behind unicli SITE CMD. Numbers in the "Results" section below are produced by npm run bench and are reproducible in CI fixture mode and on a dev machine in live mode.

Why This File Exists

Agent-native infrastructure should publish real cost numbers. Uni-CLI measures both the command invocation and the response body so public claims stay tied to the current code, fixtures, and output contract.

The v0.216.3 fixture bench measures current v2 AgentEnvelope response bodies at 357-415 tokens for representative --limit 5 list-style calls. Total invocation-plus-response budgets land at 364-423 tokens in the same suite. unicli list is much larger because it intentionally emits the full 235-site / 1448-command catalog.

This file ships real numbers or says TODO: -- nothing in between.

How We Measure

  1. Build the CLI (npm run build) so dist/main.js is current.
  2. Run each (site, command) pair at fixed inputs (default args, --limit 5 unless noted). Capture stdout as JSON.
  3. Tokenise the piped stdout via an o200k_base heuristic approximator (bench/tokens.ts). The heuristic matches real tiktoken counts within roughly 6-8% on English and compact JSON; rounding to tens of tokens is honest at this precision.
  4. Record p50 and p95 across the configured number of iterations (BENCH_RUNS, default 50) of in-process tokenisation in fixture mode, or subprocess wall-clock in live mode.
  5. Also capture the invocation-string token count so the agent-side command cost is visible.

The harness lives under bench/ and is wired into npm run bench.

ModeCommandNetworkUse
livenpm run benchyesDev-machine sanity check, refreshes fixtures.
fixtureBENCH_FIXTURES_ONLY=1 npm run benchnoCI and reproducible reports. Reads bench/fixtures/*.json.

Fixture files are committed under bench/fixtures/ alongside the scripts. Legacy fixture payloads are normalized into the current v2 AgentEnvelope shape before token counting, so the benchmark tracks the current public output contract even when source fixtures predate the envelope migration.

Results

Generated 2026-04-27T04:36:49.364Z on Node v22.22.2 / darwin-arm64. Mode: fixture (20 iterations per case). Reproduce with npm run bench (local live mode) or BENCH_FIXTURES_ONLY=1 npm run bench (CI-deterministic fixture mode).

Cold start: unicli list

metricvalue
wall p5038 ms
wall p9544 ms
response tokens73242
response chars263668
sites listed235
commands listed1448

Adapter call: p50/p95 response tokens

categorycommandinvocation tokensresponse p50 tokensresponse p95 tokenswall p50 mswall p95 msmode
newsunicli hackernews top --limit 594044040.0040.073fixture
socialunicli reddit hot --limit 584154150.0050.011fixture
social-cnunicli 36kr hot --limit 573573570.0030.005fixture
devunicli github-trending daily --limit 5114004000.0050.007fixture

Public call budget

metricvalue
Smallest total call budget364 tokens
Largest total call budget423 tokens
Median total call budget412 tokens
Representative response token span357-415 tokens

Public Budget

The public operating target is straightforward:

  • common list-style calls should stay under 600 total tokens at --limit 5;
  • failure envelopes should stay compact enough for an agent to repair without loading unrelated documentation;
  • full-catalog output should remain explicit, not automatic.

The current fixture suite clears that bar. If a future command class needs a larger payload, it should expose pagination, --limit, or --compact.

Reproducibility

The bench/ directory is self-contained:

  • bench/tokens.ts — token estimator (no native deps).
  • bench/cold-start.tsunicli list cold-start runner.
  • bench/adapter-call.ts — per-command p50/p95 runner (live or fixture mode).
  • bench/report.ts — orchestrator, writes bench/results.json and patches this file between <!-- BENCH:begin --> and <!-- BENCH:end -->.
  • bench/fixtures/ — captured JSON responses (rerun npm run bench in live mode to refresh; commit the diff if upstream shape changes).

npm run bench is not part of npm run verify because it prefers network. CI runs it only in fixture mode, on an explicit workflow dispatch or a scheduled maintenance check.


Last reviewed: 2026-04-26.

Released under the Apache-2.0 License