Cost control for AI agents — loop detection, budget caps, audit trail
Project description
Orka
Your AI agent burns money in a loop. Orka cuts it before the bill lands — and proves how much it saved.
What just happened
An OpenAI Operator agent bought a dozen eggs for $31 — its own safety protocol failed to trigger.
Replit's coding agent deleted a production database in 9 seconds, during a freeze meant to prevent exactly that.
A research agent burned $200 in a retry loop at 3am before anyone noticed.
There's no checkpoint between your agent's decision and the irreversible action. No cost cap. No loop detection. No audit trail.
Orka sits in front of every action and decides: let it pass, flag it, or cut it.
Installation
One-line (Linux / macOS)
curl -fsSL https://orka.ia.br/install.sh | bash
Windows (PowerShell)
irm https://orka.ia.br/install.ps1 | iex
Homebrew (macOS / Linux)
brew tap mathhMadureira/orka https://github.com/mathhMadureira/orka
brew install mathhMadureira/orka/orka
Winget (Windows)
winget install Orka.Orka
pip (Python SDK)
pip install orkaia
# with proxy support:
pip install "orkaia[proxy]"
# everything:
pip install "orkaia[all]"
npm (TypeScript / Node.js SDK)
npm install orkaia-js
Docker
docker run --rm -it ghcr.io/mathhmadureira/orka:latest orka version
Quick start — no API key, no signup
import orka
orka.init(mode="local") # zero network, runs offline
@orka.guard(agent_id="my-agent", task_type="web_search")
def search(query: str) -> str:
return your_llm.call(query)
# Same query repeated = loop detected
for i in range(10):
search(query="python tutorial")
# See what Orka caught
orka.summary()
Output:
==================================================
Orka Run Summary
==================================================
Actions: 10
Interventions: 1
Cost: ~$0.0230
Saved: ~$0.1610 ← 7× your cost
==================================================
[loop_guard] Identical action repeated 3× — halted
==================================================
CLI
orka <command> [options]
Commands:
init Interactive first-time setup
login Save an API key to local config
config Read or write config values
doctor Diagnose environment and connectivity
version Show installed version
update Upgrade to the latest version
wrap Run any process wrapped by the Orka proxy
report Show local audit report
mcp Start the MCP stdio server
run Run an agent action via Orka cloud API
Examples
# First time setup
orka init
# Save API key
orka login
# Wrap any LLM process — intercepts OpenAI/Anthropic calls automatically
orka wrap --budget 2.00 --enforce -- python my_agent.py
# View audit report
orka report
# Check for updates
orka version --check
orka update
# Diagnose your environment
orka doctor
Wrap mode (proxy interceptor)
orka wrap starts a local HTTP proxy that intercepts OpenAI-compatible and Anthropic API calls made by any subprocess. No code changes needed.
orka wrap \
--budget 5.00 \
--loop-threshold 3 \
--enforce \
-- python agent.py
| Flag | Default | Description |
|---|---|---|
--budget |
5.00 |
Max spend in USD per run |
--loop-threshold |
3 |
Halt after N identical consecutive actions |
--enforce |
off | Block (not just observe) when limits exceeded |
--upstream |
OpenAI | Upstream provider URL |
Python SDK — decorator pattern
import orka
# Cloud mode (full governance + audit)
client = orka.init(api_key="orka_...")
@orka.guard(agent_id="summarizer-v1", task_type="summarize")
def summarize(text: str) -> str:
return openai_client.chat(text)
result = summarize("long article...")
Python SDK — economy module
import orka
economy = orka.economy(
per_run_usd=2.00, # hard budget per run
loop_threshold=3, # stop after 3 identical actions
on_exceed="pause", # "pause" | "block"
)
with economy.run():
agent.run(task)
print(economy.summary())
TypeScript SDK
import orka from "orkaia-js";
const client = orka.init("orka_YOUR_KEY");
const summarize = orka.guard(
async (text: string) => openai.chat(text),
{ agentId: "summarizer", taskType: "summarize" }
);
await summarize("long article...");
Local mode vs Cloud mode
| Feature | Local (free, offline) | Cloud |
|---|---|---|
| Loop detection | ✓ | ✓ |
| Budget caps | ✓ | ✓ |
| Audit trail | SQLite ~/.orka/local.db |
PostgreSQL |
| Human approvals | — | ✓ |
| Multi-agent | — | ✓ |
| Policy enforcement | — | ✓ |
| Team dashboard | — | ✓ |
| Retention | Local disk | 7–14 days |
MCP server
# Add to your MCP client config (Claude, Cursor, etc.)
orka mcp
Exposes read-only tools: list_actions, list_interventions, get_summary.
Building from source
git clone https://github.com/mathhMadureira/orka
cd orka/sdk/python
pip install -e ".[dev]"
pytest tests/ -v
# Build standalone binary
pip install pyinstaller
pyinstaller orka.spec
./dist/orka version
Contributing
git clone https://github.com/mathhMadureira/orka
cd orka/sdk/python
pip install -e ".[dev]"
# Lint
ruff check orka/
# Type check
mypy orka/ --ignore-missing-imports
# Tests
pytest tests/ -v
Releases
Releases are triggered by pushing a version tag:
git tag v1.0.0
git push origin v1.0.0
This automatically:
- Runs all tests (Python 3.10, 3.11, 3.12 + TypeScript)
- Builds binaries for Windows x64, Linux x64, Linux ARM64, macOS Intel, macOS Apple Silicon
- Creates a GitHub Release with all binaries attached
- Publishes
orkaiato PyPI - Publishes
orkaia-jsto npm - Updates the Homebrew formula
License
MIT — see LICENSE
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file orkaia-0.4.0.tar.gz.
File metadata
- Download URL: orkaia-0.4.0.tar.gz
- Upload date:
- Size: 32.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ffed8061f3d0ef00a7b37ece2cb761324d608f8f52bae305db36572df4bd258c
|
|
| MD5 |
ff3011a2b535b7038e9799d47196c16e
|
|
| BLAKE2b-256 |
e43f8787431cc4a4ce25e9f017a256c2c80512bbcf6edf2fe10cc9c2a298b332
|
File details
Details for the file orkaia-0.4.0-py3-none-any.whl.
File metadata
- Download URL: orkaia-0.4.0-py3-none-any.whl
- Upload date:
- Size: 26.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63938099c07812021b2b9c90dde771d9ae5db4bd9bbfaa74d27e8fb33c5536f7
|
|
| MD5 |
76bb1512f4c4c8d99465369bfbeb6ac7
|
|
| BLAKE2b-256 |
2e36912af52ad93533cc51fdce87954b3541a1446a665f45497f4d98e920079b
|