Metadata-Version: 2.5
Name: runeconomy
Version: 0.4.0
Summary: Find inference waste in agent workflows and verify performance improvements
Project-URL: Homepage, https://runeconomy.com/
Project-URL: Documentation, https://runeconomy.com/start/
Project-URL: Repository, https://github.com/ShreyanshMisra/runeconomy
Project-URL: Issues, https://github.com/ShreyanshMisra/runeconomy/issues
Author: shrey
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: ai-agents,inference,llm,observability,performance,vllm
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Testing
Classifier: Topic :: System :: Benchmark
Requires-Python: >=3.11
Requires-Dist: jsonschema<5,>=4.23
Description-Content-Type: text/markdown

# RunEconomy

<!-- mcp-name: io.github.ShreyanshMisra/runeconomy -->

**Your inference got faster. Did your agent still finish the task?**

Request-level benchmarks such as `vllm bench serve` and GuideLLM measure
tokens per second. Eval harnesses measure output accuracy. Neither tells you
whether switching BF16 to FP8, moving from a hosted API to self-hosted vLLM, or
pruning tools lowered your **cost per successful multi-step agent workflow**.

RunEconomy is a local-first CLI, MCP server and CI gate that:

1. **Audits** your real OpenAI-compatible agent traffic with no code changes,
   naming prefix-cache breaks, repeated tool output, unused tool definitions
   and serialized steps.
2. **Verifies** a serving, model or agent change with paired baseline and
   candidate runs under frozen task-quality, completion, identity and cost gates.
3. **Returns one defensible verdict**: `verified`, `regression`,
   `inconclusive` or `invalid`, with SHA-256 digests of every frozen input and
   an HTML report that leads with the verdict.

## 60-second audit of your own agent

Works in front of vLLM, SGLang, llama.cpp's `llama-server` or a hosted
OpenAI-compatible API. Requires Python 3.11 or newer.

```bash
python -m pip install runeconomy==0.4.0
runeconomy proxy --upstream "$OPENAI_BASE_URL" --audit
```

Point your agent's `OPENAI_BASE_URL` at the printed `http://127.0.0.1:...`
address, run one workflow and press Ctrl-C. RunEconomy writes
`session.audit.html` with observed token usage, estimated opportunities, the
affected calls and the command that prepares a paired comparison. The capture
stays on your machine and contains prompts and model output, so keep it private.

### Compare two agent versions (directional)

```bash
runeconomy quick-verify \
  --baseline "python agent_v1.py" \
  --candidate "python agent_v2.py" \
  --dataset tasks.json \
  --evaluator evaluator.json \
  --output first-comparison
```

Add `--allow-exec-evaluators` after reviewing a Python, command or pytest
evaluator. Child processes receive an allowlisted environment, so name any
credential they need in `RUNECONOMY_PASSTHROUGH_ENV` (for example
`RUNECONOMY_PASSTHROUGH_ENV=OPENAI_API_KEY`).

### No GPU or API key? Try it offline

```bash
runeconomy demo --open                 # a real frozen GPU report, rendered locally
runeconomy tutorial init ./runeconomy-tutorial && runeconomy tutorial serve
```

The tutorial runs synthetic requests against a deterministic localhost server.
Its generated README walks through `import`, `experiment init`, `validate`,
`run` and `report`.

### Let Claude Code or Codex drive it

```bash
claude mcp add runeconomy -- runeconomy mcp
# or install the portable agent skill
npx skills add ShreyanshMisra/runeconomy --skill runeconomy --all
```

The MCP server stops for your approval, through a single-use token bound to the
workspace digests, before any paid run.
[Agents guide](https://runeconomy.com/agents/) · [MCP server](docs/mcp.md)

## Proof on real GPUs

Every number below comes from a frozen decision record with a SHA-256 digest.

| Decision | What a request benchmark sees | Verdict | What the verdict supports |
| --- | --- | --- | --- |
| **Proof 3** · Qwen2.5-14B BF16 to online FP8, 16 concurrent agents, NVIDIA L40S | Mean workflow latency −27% (−499 ms), p95 2,254 → 1,625 ms | **`verified`** · 200/200 tasks passed in both arms, cost per 1,000 successes $0.065 → $0.048 (−26%) | The speedup, for this workload |
| **Proof 4** · Remove the search tool, same model and server | Median latency halved, input tokens −56% | **`regression`** · Task success 100% → 54%, below the 80% floor | Blocking the change |
| **Study 3** · Hosted DeepSeek to self-hosted Qwen on one Modal A10G | 1.75 s faster on shared successes | **`regression`** · 75/80 tasks passed, cost per 1,000 successes $0.748 against $0.251 | Keeping the hosted configuration |
| **Study 2** · Move a request ID after a 1.8K-token system prompt (descriptive) | Server TTFT p50 935 → 96 ms | Cached tokens 1.3 → 1,741.6, cost per 1,000 successful requests $0.151 → $0.022 (−85%) | A layout change worth a preregistered test |

[Scoreboard and digests](https://runeconomy.com/scoreboard/) ·
[Proofs 3 and 4](https://runeconomy.com/proofs/) ·
[Study 3](https://runeconomy.com/study-3/) ·
[Open the reports](https://runeconomy.com/demo/)

### We publish the runs RunEconomy refused

A verifier that only reports wins is not checking anything. Two frozen runs
measured faster and still returned **`invalid`**:

- **Proof 1** · Move dynamic metadata behind stable instructions. Mean latency
  fell 62.43 ms on 36 pairs where both arms succeeded, and the candidate
  gained 105 cached tokens. But 37/40 baseline and 38/40 candidate tasks
  passed, the baseline lower bound was 79.61% against an 80% floor, and paired
  non-inferiority also failed. Retuning on those results would reuse a consumed
  held-out workload, so a fresh claim needs fresh tasks.
  [Read Proof 1](https://runeconomy.com/proof/) ·
  [Aggregate evidence](src/runeconomy/data/public-proof-rejection.json)
- **Proof 2** · BF16 to FP8. Mean latency fell 391 ms on 179 successful pairs,
  but one shared application failure left each arm at 179/180 completions
  against a frozen 180/180 contract.
  [Read Proof 2](https://runeconomy.com/articles/proof-2-fp8-near-miss/)

All published proofs use synthetic multi-step workloads on pinned models,
GPUs and engine versions. They show what RunEconomy decides, not results for
every model.

## Run an experiment on your deployment

Start in a fresh private directory outside version control. Save a read-only
probe of the server first:

```bash
runeconomy doctor --base-url "$VLLM_BASE_URL" --api-key-env VLLM_API_KEY --json > doctor.json
```

For a serving or prompt-layout change you can test with captured requests, use
static replay. For changes to tools, retries or multi-turn decisions, run both
complete agents with `--mode agent-process`.

```bash
runeconomy proxy --upstream "$VLLM_BASE_URL" --record session.jsonl
runeconomy import session.jsonl --type proxy --replay-context replay-context.json --output evidence.json
runeconomy experiment init --from-evidence evidence.json --output experiment/
runeconomy experiment validate experiment/ --doctor-report doctor.json
runeconomy experiment plan experiment/
runeconomy experiment run experiment/ --output results/
runeconomy experiment report results/result.json --output report.html --open
```

`replay-context.json` supplies your serving identity, evaluator and replay
design, as shown in the [capture guide](https://runeconomy.com/proxy/).
Agent-process workspaces also need `--allow-exec-agents` on `experiment run`.
To turn a reviewed design into a held-out CI gate, prepare fresh tasks, run
`runeconomy experiment freeze experiment/`, then run with `--require-frozen`.
Already have OpenInference/OTLP, Phoenix, vLLM or Prefixwise evidence? Start
with `runeconomy import SOURCE --output evidence.json`. An *unresolved
workspace* means import succeeded but a required input, such as a pinned model
revision or task evaluator, is still missing.

[Quickstart](https://runeconomy.com/start/) ·
[Evidence formats](https://runeconomy.com/evidence/) ·
[Experiment contract](https://runeconomy.com/experiments/) ·
[CLI reference](https://runeconomy.com/cli/) ·
[GitHub Action](docs/github-action.md) ·
[JSON contracts](docs/json-contracts-patch-freeze.md)

## Troubleshooting and bug reports

Record the displayed `runeconomy.*` error code. To collect diagnostics locally:

```bash
runeconomy support-bundle experiment/ --output runeconomy-support.zip
```

Inspect the archive before sharing it. Keep raw captures and experiment
artifacts private. [Troubleshooting](https://runeconomy.com/troubleshooting/) ·
[Privacy and support bundles](https://runeconomy.com/privacy/)

## Preview: staging canary gateway

Testing two live serving stacks with prefix-affinity routing and rollback on a
`regression` verdict? The Rust staging ingress under [`gateway/`](gateway/) is
a preview. The [staging pilot guide](docs/staging-pilot.md) includes a
credential-free fixture, measured Q8 and Q4 results and rollback instructions.

## Current scope (0.4.0)

A local-first CLI and MCP server for operator-reviewed experiments and CI
gates. Prompts, traces and artifacts stay on your machine, RunEconomy sends no
telemetry, and no hosted dashboard is required. There is no managed OTLP
collector or framework-specific SDK yet, and raw prompts, traces, evaluator
data and experiment artifacts remain the operator's responsibility.

[Scope and migration notes](https://runeconomy.com/alpha/) ·
[0.4.0 release notes](docs/release-notes-0.4.0.md) ·
[Development and validation](docs/development.md) ·
[Documentation](https://runeconomy.com/) ·
[PyPI](https://pypi.org/project/runeconomy/)

The [documentation site](https://runeconomy.com/) is generated from the
version-controlled sources under [`site/`](site/).
