metadata
tags:
- ml-intern
Agent Cost Optimizer (ACO)
A universal control layer that reduces total cost of autonomous agent runs while preserving task quality.
Core Thesis
Most agent cost is wasted through:
- Overusing frontier models
- Sending huge context every turn
- Using tools unnecessarily
- Failing and retrying blindly
- Ignoring cache boundaries
- Using verifiers everywhere instead of selectively
- Not learning from previous traces
ACO learns when to spend and when not to spend.
Architecture
10 Core Modules
- Cost Telemetry Collector β Structured trace collection with normalized schema
- Task Cost Classifier β Predicts expected cost, risk, model strength needed
- Model Cascade Router β Dynamic model selection (tiny β cheap β medium β frontier β specialist)
- Context Budgeter β Decides what context is needed vs. what can be omitted/summarized/cached
- Cache-Aware Prompt Layout β Optimizes prompt structure for prefix-cache reuse
- Tool-Use Cost Gate β Predicts whether a tool call is worth the cost
- Verifier Budgeter β Selective verification based on risk, confidence, task type
- Retry/Recovery Optimizer β Intelligent failure recovery without blind retry loops
- Meta-Tool Miner β Compresses repeated workflows into reusable deterministic scripts
- Early Termination / Doom Detector β Detects runs unlikely to succeed and stops them
Installation
pip install agent-cost-optimizer
Quick Start
from aco import AgentCostOptimizer
optimizer = AgentCostOptimizer.from_config("config.yaml")
result = optimizer.optimize(agent_request, run_state)
Reward Objective
cost_adjusted_score =
task_success_score
+ safety_bonus
+ artifact_completion_bonus
+ calibration_bonus
- model_cost_penalty
- tool_cost_penalty
- latency_penalty
- retry_penalty
- unnecessary_verifier_penalty
- false_done_penalty
- unsafe_cheap_model_penalty
- missed_escalation_penalty
Benchmarks
- Coding Agent Tasks
- Research Agent Tasks
- Tool-Use Tasks
- Document / Contract / QA Tasks
- Long-Horizon Agent Tasks
License
MIT
Generated by ML Intern
This model repository was generated by ML Intern, an agent for machine learning research and development on the Hugging Face Hub.
- Try ML Intern: https://smolagents-ml-intern.hf.space
- Source code: https://github.com/huggingface/ml-intern
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "narcolepticchicken/agent-cost-optimizer"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)
For non-causal architectures, replace AutoModelForCausalLM with the appropriate AutoModel class.