narcolepticchicken commited on
Commit
cbb24e9
Β·
verified Β·
1 Parent(s): 2978c49

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +66 -16
README.md CHANGED
@@ -1,26 +1,76 @@
1
- ---
2
- tags:
3
- - ml-intern
4
- ---
5
 
6
- # narcolepticchicken/agent-cost-optimizer
7
 
8
- <!-- ml-intern-provenance -->
9
- ## Generated by ML Intern
10
 
11
- This model repository was generated by [ML Intern](https://github.com/huggingface/ml-intern), an agent for machine learning research and development on the Hugging Face Hub.
 
 
 
 
 
 
 
12
 
13
- - Try ML Intern: https://smolagents-ml-intern.hf.space
14
- - Source code: https://github.com/huggingface/ml-intern
15
 
16
- ## Usage
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
  ```python
19
- from transformers import AutoModelForCausalLM, AutoTokenizer
20
 
21
- model_id = "narcolepticchicken/agent-cost-optimizer"
22
- tokenizer = AutoTokenizer.from_pretrained(model_id)
23
- model = AutoModelForCausalLM.from_pretrained(model_id)
24
  ```
25
 
26
- For non-causal architectures, replace `AutoModelForCausalLM` with the appropriate `AutoModel` class.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Agent Cost Optimizer (ACO)
 
 
 
2
 
3
+ A universal control layer that reduces total cost of autonomous agent runs while preserving task quality.
4
 
5
+ ## Core Thesis
 
6
 
7
+ Most agent cost is wasted through:
8
+ - Overusing frontier models
9
+ - Sending huge context every turn
10
+ - Using tools unnecessarily
11
+ - Failing and retrying blindly
12
+ - Ignoring cache boundaries
13
+ - Using verifiers everywhere instead of selectively
14
+ - Not learning from previous traces
15
 
16
+ ACO learns when to spend and when not to spend.
 
17
 
18
+ ## Architecture
19
+
20
+ ### 10 Core Modules
21
+
22
+ 1. **Cost Telemetry Collector** β€” Structured trace collection with normalized schema
23
+ 2. **Task Cost Classifier** β€” Predicts expected cost, risk, model strength needed
24
+ 3. **Model Cascade Router** β€” Dynamic model selection (tiny β†’ cheap β†’ medium β†’ frontier β†’ specialist)
25
+ 4. **Context Budgeter** β€” Decides what context is needed vs. what can be omitted/summarized/cached
26
+ 5. **Cache-Aware Prompt Layout** β€” Optimizes prompt structure for prefix-cache reuse
27
+ 6. **Tool-Use Cost Gate** β€” Predicts whether a tool call is worth the cost
28
+ 7. **Verifier Budgeter** β€” Selective verification based on risk, confidence, task type
29
+ 8. **Retry/Recovery Optimizer** β€” Intelligent failure recovery without blind retry loops
30
+ 9. **Meta-Tool Miner** β€” Compresses repeated workflows into reusable deterministic scripts
31
+ 10. **Early Termination / Doom Detector** β€” Detects runs unlikely to succeed and stops them
32
+
33
+ ## Installation
34
+
35
+ ```bash
36
+ pip install agent-cost-optimizer
37
+ ```
38
+
39
+ ## Quick Start
40
 
41
  ```python
42
+ from aco import AgentCostOptimizer
43
 
44
+ optimizer = AgentCostOptimizer.from_config("config.yaml")
45
+ result = optimizer.optimize(agent_request, run_state)
 
46
  ```
47
 
48
+ ## Reward Objective
49
+
50
+ ```
51
+ cost_adjusted_score =
52
+ task_success_score
53
+ + safety_bonus
54
+ + artifact_completion_bonus
55
+ + calibration_bonus
56
+ - model_cost_penalty
57
+ - tool_cost_penalty
58
+ - latency_penalty
59
+ - retry_penalty
60
+ - unnecessary_verifier_penalty
61
+ - false_done_penalty
62
+ - unsafe_cheap_model_penalty
63
+ - missed_escalation_penalty
64
+ ```
65
+
66
+ ## Benchmarks
67
+
68
+ - Coding Agent Tasks
69
+ - Research Agent Tasks
70
+ - Tool-Use Tasks
71
+ - Document / Contract / QA Tasks
72
+ - Long-Horizon Agent Tasks
73
+
74
+ ## License
75
+
76
+ MIT