agentwaste 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agentwaste-0.1.0/.gitignore +11 -0
- agentwaste-0.1.0/CHANGELOG.md +14 -0
- agentwaste-0.1.0/LICENSE +21 -0
- agentwaste-0.1.0/PKG-INFO +152 -0
- agentwaste-0.1.0/README.md +124 -0
- agentwaste-0.1.0/docs/sidebar.json +18 -0
- agentwaste-0.1.0/docs/src/content/docs/contributing.mdx +30 -0
- agentwaste-0.1.0/docs/src/content/docs/detectors/duplicate-call.mdx +27 -0
- agentwaste-0.1.0/docs/src/content/docs/detectors/error-thrash.mdx +26 -0
- agentwaste-0.1.0/docs/src/content/docs/detectors/huge-result.mdx +27 -0
- agentwaste-0.1.0/docs/src/content/docs/detectors/idle-cache-rebuild.mdx +42 -0
- agentwaste-0.1.0/docs/src/content/docs/detectors/overview.mdx +19 -0
- agentwaste-0.1.0/docs/src/content/docs/detectors/reread.mdx +30 -0
- agentwaste-0.1.0/docs/src/content/docs/detectors/uncached-context.mdx +42 -0
- agentwaste-0.1.0/docs/src/content/docs/faq.mdx +42 -0
- agentwaste-0.1.0/docs/src/content/docs/guides/reducing-waste.mdx +21 -0
- agentwaste-0.1.0/docs/src/content/docs/guides/sharing-your-card.mdx +30 -0
- agentwaste-0.1.0/docs/src/content/docs/how-it-works.mdx +69 -0
- agentwaste-0.1.0/docs/src/content/docs/index.mdx +53 -0
- agentwaste-0.1.0/docs/src/content/docs/privacy.mdx +14 -0
- agentwaste-0.1.0/docs/src/content/docs/quickstart.mdx +82 -0
- agentwaste-0.1.0/docs/src/content/docs/reference/cli.mdx +26 -0
- agentwaste-0.1.0/docs/src/content/docs/reference/json-output.mdx +52 -0
- agentwaste-0.1.0/pyproject.toml +52 -0
- agentwaste-0.1.0/src/agentwaste/__init__.py +3 -0
- agentwaste-0.1.0/src/agentwaste/__main__.py +5 -0
- agentwaste-0.1.0/src/agentwaste/analysis.py +68 -0
- agentwaste-0.1.0/src/agentwaste/card.py +50 -0
- agentwaste-0.1.0/src/agentwaste/cli.py +55 -0
- agentwaste-0.1.0/src/agentwaste/cost.py +23 -0
- agentwaste-0.1.0/src/agentwaste/demo.py +58 -0
- agentwaste-0.1.0/src/agentwaste/detectors.py +203 -0
- agentwaste-0.1.0/src/agentwaste/model.py +45 -0
- agentwaste-0.1.0/src/agentwaste/report.py +81 -0
- agentwaste-0.1.0/src/agentwaste/sources/__init__.py +0 -0
- agentwaste-0.1.0/src/agentwaste/sources/claude_code.py +124 -0
- agentwaste-0.1.0/tests/conftest.py +61 -0
- agentwaste-0.1.0/tests/test_claude_code_source.py +74 -0
- agentwaste-0.1.0/tests/test_demo.py +22 -0
- agentwaste-0.1.0/tests/test_detectors.py +158 -0
- agentwaste-0.1.0/tests/test_docs.py +106 -0
- agentwaste-0.1.0/tests/test_packaging.py +22 -0
- agentwaste-0.1.0/tests/test_report_and_cli.py +112 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0 (unreleased)
|
|
4
|
+
|
|
5
|
+
First release of agentwaste, pivoted from the AgentSight SDK (now in
|
|
6
|
+
`legacy/agentsight`).
|
|
7
|
+
|
|
8
|
+
- Claude Code transcript reader.
|
|
9
|
+
- Six detectors: idle cache rebuild, uncached context (Claude, and
|
|
10
|
+
informational for self-hosted models), re-read, duplicate call, huge result,
|
|
11
|
+
error thrash.
|
|
12
|
+
- Terminal report with fixes, `--json`, shareable `--card`, optional
|
|
13
|
+
`--usd-per-mtok`, and `--demo` synthetic sessions.
|
|
14
|
+
- Documentation site (Astro Starlight) at https://nikghodki.github.io/agentwaste/.
|
agentwaste-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 NIKHIL GHODKI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: agentwaste
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Find where your AI coding agent wastes tokens, and how to stop it
|
|
5
|
+
Project-URL: Homepage, https://github.com/nikghodki/agentwaste
|
|
6
|
+
Project-URL: Documentation, https://nikghodki.github.io/agentwaste/
|
|
7
|
+
Project-URL: Issues, https://github.com/nikghodki/agentwaste/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/nikghodki/agentwaste/blob/main/CHANGELOG.md
|
|
9
|
+
Author-email: nikghodki <nikghodki@gmail.com>
|
|
10
|
+
License: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: ai-agents,claude-code,cli,cost,developer-tools,llm,prompt-caching,tokens
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Software Development
|
|
23
|
+
Classifier: Topic :: Utilities
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
<div align="center">
|
|
30
|
+
|
|
31
|
+
# agentwaste
|
|
32
|
+
|
|
33
|
+
**Your AI coding agent is wasting tokens. Find out where, and how to stop it.**
|
|
34
|
+
|
|
35
|
+
[](https://github.com/nikghodki/agentwaste/actions/workflows/ci.yml)
|
|
36
|
+
[](https://nikghodki.github.io/agentwaste/)
|
|
37
|
+
[](https://www.python.org/)
|
|
38
|
+
[](https://github.com/nikghodki/agentwaste/tree/main/LICENSE)
|
|
39
|
+
|
|
40
|
+
[**Documentation**](https://nikghodki.github.io/agentwaste/) ·
|
|
41
|
+
[Quickstart](https://nikghodki.github.io/agentwaste/quickstart/) ·
|
|
42
|
+
[How it works](https://nikghodki.github.io/agentwaste/how-it-works/) ·
|
|
43
|
+
[Contributing](https://github.com/nikghodki/agentwaste/blob/main/CONTRIBUTING.md)
|
|
44
|
+
|
|
45
|
+
<img src="https://raw.githubusercontent.com/nikghodki/agentwaste/main/assets/report.png" alt="agentwaste report: 41% waste, grade D, with re-caching after idle breaks as the top finding and a fix for each pattern" width="820">
|
|
46
|
+
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
## Try it in 10 seconds
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
uvx --from git+https://github.com/nikghodki/agentwaste agentwaste
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
That's it: no install, no account, no config. It reads the Claude Code logs
|
|
56
|
+
already on your machine and prints a report. No history yet? Add `--demo`.
|
|
57
|
+
|
|
58
|
+
Want the `agentwaste` command permanently? Install it once:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
uv tool install git+https://github.com/nikghodki/agentwaste # or: pipx install git+https://github.com/nikghodki/agentwaste
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The examples below use the installed command. Without installing, put
|
|
65
|
+
`uvx --from git+https://github.com/nikghodki/agentwaste` in front of them.
|
|
66
|
+
|
|
67
|
+
## Why
|
|
68
|
+
|
|
69
|
+
Usage trackers tell you **how much** you used. agentwaste tells you **why**,
|
|
70
|
+
and how much of it was avoidable.
|
|
71
|
+
|
|
72
|
+
On one developer's month of Claude Code use, **about a third of all input cost
|
|
73
|
+
was re-caching the conversation after stepping away for more than five
|
|
74
|
+
minutes.** Nobody noticed, because nothing showed it.
|
|
75
|
+
|
|
76
|
+
Whether you pay per token or hit subscription limits, that's waste you can fix
|
|
77
|
+
in minutes once you can see it.
|
|
78
|
+
|
|
79
|
+
## What it finds
|
|
80
|
+
|
|
81
|
+
| | Pattern | What's happening | The fix |
|
|
82
|
+
|---|---|---|---|
|
|
83
|
+
| ⏸️ | **Idle cache rebuild** | You step away, the 5-minute prompt cache expires, and the next message re-writes the whole context at 1.25x | `/compact` before a break, or the 1-hour cache |
|
|
84
|
+
| 🔁 | **Uncached context** | Every turn re-sends the conversation without caching, often because a proxy drops cache markers | Fix the proxy so caching survives |
|
|
85
|
+
| 📄 | **Re-read** | The agent re-reads a file it already read, with no change in between | Put the facts in `CLAUDE.md` |
|
|
86
|
+
| 🔍 | **Duplicate call** | The same search or fetch runs again with nothing changed | Reuse results, search more precisely |
|
|
87
|
+
| 📦 | **Huge result** | One 10k+ token output, carried in every later message | `head`, filters, ranged reads |
|
|
88
|
+
| 💥 | **Error thrash** | The same tool fails 3+ times in a row | Give the agent the missing context |
|
|
89
|
+
|
|
90
|
+
Every finding comes with its cost, the worst offenders and a specific fix.
|
|
91
|
+
[Exact definitions →](https://nikghodki.github.io/agentwaste/detectors/overview/)
|
|
92
|
+
|
|
93
|
+
## Share your grade
|
|
94
|
+
|
|
95
|
+
<img src="https://raw.githubusercontent.com/nikghodki/agentwaste/main/assets/card.png" alt="Shareable agentwaste card: grade D, 41% of input tokens wasted, top categories re-caching after idle breaks, huge tool outputs and uncached context" width="300" align="right">
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
agentwaste --card my-card.html
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
A one-file card with your grade and top waste categories, ready to screenshot
|
|
102
|
+
and post. It contains **aggregates only**: no paths, project names, commands
|
|
103
|
+
or code. A test enforces that on every change.
|
|
104
|
+
|
|
105
|
+
<br clear="right">
|
|
106
|
+
|
|
107
|
+
## More options
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
agentwaste --days 7 # last week only (default 30; 0 = everything)
|
|
111
|
+
agentwaste --usd-per-mtok 3 # dollar estimates at $3 per million input tokens
|
|
112
|
+
agentwaste --json > waste.json # machine-readable, for scripts and dashboards
|
|
113
|
+
agentwaste --demo # try it on synthetic sessions
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Full reference: [CLI](https://nikghodki.github.io/agentwaste/reference/cli/) ·
|
|
117
|
+
[JSON output](https://nikghodki.github.io/agentwaste/reference/json-output/)
|
|
118
|
+
|
|
119
|
+
## Private by design
|
|
120
|
+
|
|
121
|
+
- **Local and read-only.** No network requests, nothing uploaded, your logs are never changed.
|
|
122
|
+
- **No dependencies.** Plain Python 3.10+, so there's nothing hidden to audit.
|
|
123
|
+
- **Honest numbers.** Costs are in [token-equivalents](https://nikghodki.github.io/agentwaste/how-it-works/#token-equivalents)
|
|
124
|
+
that weight cache writes, cache reads and fresh input the way they're actually
|
|
125
|
+
billed. Self-hosted models are reported separately, since their cost is GPU
|
|
126
|
+
time, not tokens.
|
|
127
|
+
|
|
128
|
+
## Roadmap
|
|
129
|
+
|
|
130
|
+
- [x] Claude Code support, six detectors, report, JSON, shareable card
|
|
131
|
+
- [ ] Codex support
|
|
132
|
+
- [ ] `pip install agentwaste` / `uvx agentwaste` from PyPI
|
|
133
|
+
- [ ] Live warnings while you work ("your cache expires in 1 minute")
|
|
134
|
+
- [ ] Before/after comparison: did the fix actually help?
|
|
135
|
+
|
|
136
|
+
Ideas and votes welcome in [issues](https://github.com/nikghodki/agentwaste/issues).
|
|
137
|
+
|
|
138
|
+
## Contributing
|
|
139
|
+
|
|
140
|
+
Contributions are very welcome, especially **new log sources** (Codex, Gemini
|
|
141
|
+
CLI, OpenCode) and **new detectors**. Start with [CONTRIBUTING.md](https://github.com/nikghodki/agentwaste/blob/main/CONTRIBUTING.md):
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
git clone https://github.com/nikghodki/agentwaste && cd agentwaste
|
|
145
|
+
python3 -m venv .venv && .venv/bin/pip install -e ".[dev]" && .venv/bin/pytest
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
The original AgentSight SDK lives on in [`legacy/agentsight`](https://github.com/nikghodki/agentwaste/tree/main/legacy/agentsight).
|
|
149
|
+
|
|
150
|
+
## License
|
|
151
|
+
|
|
152
|
+
[MIT](https://github.com/nikghodki/agentwaste/tree/main/LICENSE)
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# agentwaste
|
|
4
|
+
|
|
5
|
+
**Your AI coding agent is wasting tokens. Find out where, and how to stop it.**
|
|
6
|
+
|
|
7
|
+
[](https://github.com/nikghodki/agentwaste/actions/workflows/ci.yml)
|
|
8
|
+
[](https://nikghodki.github.io/agentwaste/)
|
|
9
|
+
[](https://www.python.org/)
|
|
10
|
+
[](https://github.com/nikghodki/agentwaste/tree/main/LICENSE)
|
|
11
|
+
|
|
12
|
+
[**Documentation**](https://nikghodki.github.io/agentwaste/) ·
|
|
13
|
+
[Quickstart](https://nikghodki.github.io/agentwaste/quickstart/) ·
|
|
14
|
+
[How it works](https://nikghodki.github.io/agentwaste/how-it-works/) ·
|
|
15
|
+
[Contributing](https://github.com/nikghodki/agentwaste/blob/main/CONTRIBUTING.md)
|
|
16
|
+
|
|
17
|
+
<img src="https://raw.githubusercontent.com/nikghodki/agentwaste/main/assets/report.png" alt="agentwaste report: 41% waste, grade D, with re-caching after idle breaks as the top finding and a fix for each pattern" width="820">
|
|
18
|
+
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
## Try it in 10 seconds
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
uvx --from git+https://github.com/nikghodki/agentwaste agentwaste
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
That's it: no install, no account, no config. It reads the Claude Code logs
|
|
28
|
+
already on your machine and prints a report. No history yet? Add `--demo`.
|
|
29
|
+
|
|
30
|
+
Want the `agentwaste` command permanently? Install it once:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
uv tool install git+https://github.com/nikghodki/agentwaste # or: pipx install git+https://github.com/nikghodki/agentwaste
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
The examples below use the installed command. Without installing, put
|
|
37
|
+
`uvx --from git+https://github.com/nikghodki/agentwaste` in front of them.
|
|
38
|
+
|
|
39
|
+
## Why
|
|
40
|
+
|
|
41
|
+
Usage trackers tell you **how much** you used. agentwaste tells you **why**,
|
|
42
|
+
and how much of it was avoidable.
|
|
43
|
+
|
|
44
|
+
On one developer's month of Claude Code use, **about a third of all input cost
|
|
45
|
+
was re-caching the conversation after stepping away for more than five
|
|
46
|
+
minutes.** Nobody noticed, because nothing showed it.
|
|
47
|
+
|
|
48
|
+
Whether you pay per token or hit subscription limits, that's waste you can fix
|
|
49
|
+
in minutes once you can see it.
|
|
50
|
+
|
|
51
|
+
## What it finds
|
|
52
|
+
|
|
53
|
+
| | Pattern | What's happening | The fix |
|
|
54
|
+
|---|---|---|---|
|
|
55
|
+
| ⏸️ | **Idle cache rebuild** | You step away, the 5-minute prompt cache expires, and the next message re-writes the whole context at 1.25x | `/compact` before a break, or the 1-hour cache |
|
|
56
|
+
| 🔁 | **Uncached context** | Every turn re-sends the conversation without caching, often because a proxy drops cache markers | Fix the proxy so caching survives |
|
|
57
|
+
| 📄 | **Re-read** | The agent re-reads a file it already read, with no change in between | Put the facts in `CLAUDE.md` |
|
|
58
|
+
| 🔍 | **Duplicate call** | The same search or fetch runs again with nothing changed | Reuse results, search more precisely |
|
|
59
|
+
| 📦 | **Huge result** | One 10k+ token output, carried in every later message | `head`, filters, ranged reads |
|
|
60
|
+
| 💥 | **Error thrash** | The same tool fails 3+ times in a row | Give the agent the missing context |
|
|
61
|
+
|
|
62
|
+
Every finding comes with its cost, the worst offenders and a specific fix.
|
|
63
|
+
[Exact definitions →](https://nikghodki.github.io/agentwaste/detectors/overview/)
|
|
64
|
+
|
|
65
|
+
## Share your grade
|
|
66
|
+
|
|
67
|
+
<img src="https://raw.githubusercontent.com/nikghodki/agentwaste/main/assets/card.png" alt="Shareable agentwaste card: grade D, 41% of input tokens wasted, top categories re-caching after idle breaks, huge tool outputs and uncached context" width="300" align="right">
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
agentwaste --card my-card.html
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
A one-file card with your grade and top waste categories, ready to screenshot
|
|
74
|
+
and post. It contains **aggregates only**: no paths, project names, commands
|
|
75
|
+
or code. A test enforces that on every change.
|
|
76
|
+
|
|
77
|
+
<br clear="right">
|
|
78
|
+
|
|
79
|
+
## More options
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
agentwaste --days 7 # last week only (default 30; 0 = everything)
|
|
83
|
+
agentwaste --usd-per-mtok 3 # dollar estimates at $3 per million input tokens
|
|
84
|
+
agentwaste --json > waste.json # machine-readable, for scripts and dashboards
|
|
85
|
+
agentwaste --demo # try it on synthetic sessions
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Full reference: [CLI](https://nikghodki.github.io/agentwaste/reference/cli/) ·
|
|
89
|
+
[JSON output](https://nikghodki.github.io/agentwaste/reference/json-output/)
|
|
90
|
+
|
|
91
|
+
## Private by design
|
|
92
|
+
|
|
93
|
+
- **Local and read-only.** No network requests, nothing uploaded, your logs are never changed.
|
|
94
|
+
- **No dependencies.** Plain Python 3.10+, so there's nothing hidden to audit.
|
|
95
|
+
- **Honest numbers.** Costs are in [token-equivalents](https://nikghodki.github.io/agentwaste/how-it-works/#token-equivalents)
|
|
96
|
+
that weight cache writes, cache reads and fresh input the way they're actually
|
|
97
|
+
billed. Self-hosted models are reported separately, since their cost is GPU
|
|
98
|
+
time, not tokens.
|
|
99
|
+
|
|
100
|
+
## Roadmap
|
|
101
|
+
|
|
102
|
+
- [x] Claude Code support, six detectors, report, JSON, shareable card
|
|
103
|
+
- [ ] Codex support
|
|
104
|
+
- [ ] `pip install agentwaste` / `uvx agentwaste` from PyPI
|
|
105
|
+
- [ ] Live warnings while you work ("your cache expires in 1 minute")
|
|
106
|
+
- [ ] Before/after comparison: did the fix actually help?
|
|
107
|
+
|
|
108
|
+
Ideas and votes welcome in [issues](https://github.com/nikghodki/agentwaste/issues).
|
|
109
|
+
|
|
110
|
+
## Contributing
|
|
111
|
+
|
|
112
|
+
Contributions are very welcome, especially **new log sources** (Codex, Gemini
|
|
113
|
+
CLI, OpenCode) and **new detectors**. Start with [CONTRIBUTING.md](https://github.com/nikghodki/agentwaste/blob/main/CONTRIBUTING.md):
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
git clone https://github.com/nikghodki/agentwaste && cd agentwaste
|
|
117
|
+
python3 -m venv .venv && .venv/bin/pip install -e ".[dev]" && .venv/bin/pytest
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
The original AgentSight SDK lives on in [`legacy/agentsight`](https://github.com/nikghodki/agentwaste/tree/main/legacy/agentsight).
|
|
121
|
+
|
|
122
|
+
## License
|
|
123
|
+
|
|
124
|
+
[MIT](https://github.com/nikghodki/agentwaste/tree/main/LICENSE)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
[
|
|
2
|
+
{ "label": "Get started", "items": ["quickstart", "how-it-works"] },
|
|
3
|
+
{
|
|
4
|
+
"label": "Detectors",
|
|
5
|
+
"items": [
|
|
6
|
+
"detectors/overview",
|
|
7
|
+
"detectors/idle-cache-rebuild",
|
|
8
|
+
"detectors/uncached-context",
|
|
9
|
+
"detectors/reread",
|
|
10
|
+
"detectors/duplicate-call",
|
|
11
|
+
"detectors/huge-result",
|
|
12
|
+
"detectors/error-thrash"
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
{ "label": "Guides", "items": ["guides/sharing-your-card", "guides/reducing-waste"] },
|
|
16
|
+
{ "label": "Reference", "items": ["reference/cli", "reference/json-output", "privacy", "faq"] },
|
|
17
|
+
{ "label": "Project", "items": ["contributing"] }
|
|
18
|
+
]
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Contributing"
|
|
3
|
+
description: "How to add a detector, a log source, or a fix."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
agentwaste is MIT-licensed and contributions are welcome. The full guide is
|
|
7
|
+
[CONTRIBUTING.md](https://github.com/nikghodki/agentwaste/blob/main/CONTRIBUTING.md); the
|
|
8
|
+
short version:
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
git clone https://github.com/nikghodki/agentwaste
|
|
12
|
+
cd agentwaste
|
|
13
|
+
python3 -m venv .venv && .venv/bin/pip install -e ".[dev]"
|
|
14
|
+
.venv/bin/pytest
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Good first contributions
|
|
18
|
+
|
|
19
|
+
- **A new log source.** Codex, Gemini CLI, OpenCode and others each need a reader in
|
|
20
|
+
`src/agentwaste/sources/` that returns `Stream` objects. Detectors then work unchanged.
|
|
21
|
+
- **A new detector.** Add it to `src/agentwaste/detectors.py`, document it in
|
|
22
|
+
`docs/src/content/docs/detectors/`, and add it to the overview table. The docs tests
|
|
23
|
+
check that every detector key is documented.
|
|
24
|
+
- **Better fixes.** If you know a better way to avoid a pattern, improve its fix text.
|
|
25
|
+
|
|
26
|
+
## Rules of the road
|
|
27
|
+
|
|
28
|
+
- Tests use **synthetic transcripts only**. Never commit real logs.
|
|
29
|
+
- The shareable card must never contain paths, project names, commands or content.
|
|
30
|
+
- Numbers quoted in the docs must match the code. `tests/test_docs.py` enforces this.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Duplicate call"
|
|
3
|
+
description: "Running the same search or fetch twice."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
**Key:** `duplicate_call`
|
|
7
|
+
|
|
8
|
+
## What it is
|
|
9
|
+
|
|
10
|
+
The agent repeats an identical read-only lookup, such as the same search or the same
|
|
11
|
+
web fetch, when nothing could have changed the answer.
|
|
12
|
+
|
|
13
|
+
## How it's detected
|
|
14
|
+
|
|
15
|
+
A call to `Grep`, `Glob`, `LS`, `WebFetch` or `WebSearch` is flagged when an
|
|
16
|
+
identical call (same tool, same input) already ran in the stream, with no `Edit`,
|
|
17
|
+
`Write`, `MultiEdit`, `NotebookEdit` or `Bash` call in between.
|
|
18
|
+
|
|
19
|
+
`Bash` commands are never counted as duplicates. Running `pytest` twice is usually
|
|
20
|
+
deliberate.
|
|
21
|
+
|
|
22
|
+
**Waste** = result tokens x 1.25.
|
|
23
|
+
|
|
24
|
+
## How to fix it
|
|
25
|
+
|
|
26
|
+
- Ask the agent to reuse earlier results.
|
|
27
|
+
- Make the first search more specific so it doesn't need repeating.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Error thrash"
|
|
3
|
+
description: "Retrying a failing command over and over."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
**Key:** `error_thrash`
|
|
7
|
+
|
|
8
|
+
## What it is
|
|
9
|
+
|
|
10
|
+
The agent keeps calling a tool that keeps failing, usually the same command with
|
|
11
|
+
small variations, without the information it needs to fix the cause.
|
|
12
|
+
|
|
13
|
+
## How it's detected
|
|
14
|
+
|
|
15
|
+
An episode starts when the same tool fails **3** times in a row within a stream. Any
|
|
16
|
+
success of that tool ends the run.
|
|
17
|
+
|
|
18
|
+
**Waste** = the priced input of the model calls that issued the 3rd and later failing
|
|
19
|
+
attempts.
|
|
20
|
+
|
|
21
|
+
## How to fix it
|
|
22
|
+
|
|
23
|
+
- Interrupt, and give the agent the missing context (an env var, a service that isn't
|
|
24
|
+
running, the right command).
|
|
25
|
+
- Put the fix in `CLAUDE.md` so it doesn't happen again.
|
|
26
|
+
- Add a hook that stops after repeated failures.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Huge result"
|
|
3
|
+
description: "One big output, paid for on every later message."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
**Key:** `huge_result`
|
|
7
|
+
|
|
8
|
+
## What it is
|
|
9
|
+
|
|
10
|
+
A tool returns a very large output: a recursive grep, a whole log file, a big JSON
|
|
11
|
+
response. It's written into the cache once, then read again on every later message
|
|
12
|
+
in the session. A single oversized result can cost more than the rest of the session
|
|
13
|
+
combined.
|
|
14
|
+
|
|
15
|
+
## How it's detected
|
|
16
|
+
|
|
17
|
+
A tool result is flagged when it's larger than **10,000** tokens. The first
|
|
18
|
+
**2,000** tokens are treated as reasonable; only the excess counts.
|
|
19
|
+
|
|
20
|
+
**Waste** = (tokens - 2,000) x (1.25 + 0.1 x number of later calls in the stream).
|
|
21
|
+
|
|
22
|
+
## How to fix it
|
|
23
|
+
|
|
24
|
+
- Pipe command output through `head`, `tail` or `grep`.
|
|
25
|
+
- Add limits and filters to API and database queries.
|
|
26
|
+
- Read large files in ranges.
|
|
27
|
+
- Use a code-search tool instead of recursive `grep -r`.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Idle cache rebuild"
|
|
3
|
+
description: "Paying to re-cache the whole conversation after a break."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import { Aside } from '@astrojs/starlight/components';
|
|
7
|
+
|
|
8
|
+
**Key:** `idle_cache_rebuild`
|
|
9
|
+
|
|
10
|
+
## What it is
|
|
11
|
+
|
|
12
|
+
Claude's prompt cache keeps your conversation for **5 minutes** after its last use
|
|
13
|
+
(or 1 hour with the extended cache). Come back later and the next message has to
|
|
14
|
+
write the whole context into the cache again, at 1.25x the input price, instead of
|
|
15
|
+
reading it at 0.1x.
|
|
16
|
+
|
|
17
|
+
On long sessions with large contexts, this is often the biggest single source of
|
|
18
|
+
waste. On the author's own logs it was about a third of all priced input.
|
|
19
|
+
|
|
20
|
+
## How it's detected
|
|
21
|
+
|
|
22
|
+
A model call is flagged when:
|
|
23
|
+
|
|
24
|
+
1. it writes at least **20,000** tokens to the cache, and
|
|
25
|
+
2. the previous call in the same stream was more than **300 seconds** earlier, or
|
|
26
|
+
more than **3,600 seconds** if the call used the 1-hour cache.
|
|
27
|
+
|
|
28
|
+
**Waste** = tokens written x (write weight - read weight): the extra cost over
|
|
29
|
+
reading the same context from a warm cache.
|
|
30
|
+
|
|
31
|
+
## How to fix it
|
|
32
|
+
|
|
33
|
+
- Run `/compact` before a break, so the context you come back to is small.
|
|
34
|
+
- Use `/clear` when you switch tasks, instead of continuing a huge session.
|
|
35
|
+
- For long sessions with breaks, use the 1-hour cache: writes cost more (2x) but
|
|
36
|
+
survive the break.
|
|
37
|
+
- Finish a thought before stepping away rather than leaving the agent mid-task.
|
|
38
|
+
|
|
39
|
+
<Aside>
|
|
40
|
+
Some rebuilds can't be avoided, such as the first message after compaction or a
|
|
41
|
+
model switch. Treat the number as an upper bound.
|
|
42
|
+
</Aside>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Detectors overview"
|
|
3
|
+
description: "The six waste patterns agentwaste looks for."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Each detector looks for one pattern within a [stream](/agentwaste/how-it-works/#where-the-data-comes-from)
|
|
7
|
+
and estimates its avoidable cost in [token-equivalents](/agentwaste/how-it-works/#token-equivalents).
|
|
8
|
+
|
|
9
|
+
| Detector | Key | What it finds | Counted in grade |
|
|
10
|
+
| --- | --- | --- | --- |
|
|
11
|
+
| [Idle cache rebuild](/agentwaste/detectors/idle-cache-rebuild/) | `idle_cache_rebuild` | The cache expired during a break and the context was re-written | Yes |
|
|
12
|
+
| [Uncached context](/agentwaste/detectors/uncached-context/) | `uncached_context` | Claude conversations re-sent without prompt caching | Yes |
|
|
13
|
+
| [Uncached context, self-hosted](/agentwaste/detectors/uncached-context/#self-hosted-models) | `uncached_context_self_hosted` | The same on non-Claude models | No (informational) |
|
|
14
|
+
| [Re-read](/agentwaste/detectors/reread/) | `reread` | A file read again with no change in between | Yes |
|
|
15
|
+
| [Duplicate call](/agentwaste/detectors/duplicate-call/) | `duplicate_call` | An identical search or fetch repeated | Yes |
|
|
16
|
+
| [Huge result](/agentwaste/detectors/huge-result/) | `huge_result` | A tool output over 10k tokens, carried in every later message | Yes |
|
|
17
|
+
| [Error thrash](/agentwaste/detectors/error-thrash/) | `error_thrash` | The same tool failing 3+ times in a row | Yes |
|
|
18
|
+
|
|
19
|
+
The key is how each detector appears in the [JSON output](/agentwaste/reference/json-output/).
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Re-read"
|
|
3
|
+
description: "Reading a file again when nothing changed."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
**Key:** `reread`
|
|
7
|
+
|
|
8
|
+
## What it is
|
|
9
|
+
|
|
10
|
+
The agent reads a file it already read earlier in the session, although the file
|
|
11
|
+
hasn't changed. Each re-read adds the same content to the context again.
|
|
12
|
+
|
|
13
|
+
## How it's detected
|
|
14
|
+
|
|
15
|
+
A `Read` call is flagged when the same file was already read in the stream, with no
|
|
16
|
+
`Edit`, `Write`, `MultiEdit` or `NotebookEdit` of that file and no `Bash` call in
|
|
17
|
+
between. Any `Bash` call resets tracking, because a shell command may have changed
|
|
18
|
+
the file.
|
|
19
|
+
|
|
20
|
+
Reading a different range of the same file still counts.
|
|
21
|
+
|
|
22
|
+
**Waste** = result tokens x 1.25, the cost of writing that content into the cache
|
|
23
|
+
again.
|
|
24
|
+
|
|
25
|
+
## How to fix it
|
|
26
|
+
|
|
27
|
+
- Put facts the agent keeps looking up (config values, key paths, conventions) in
|
|
28
|
+
`CLAUDE.md`.
|
|
29
|
+
- Ask the agent to note what it learned from a file rather than re-open it.
|
|
30
|
+
- The report lists the most re-read files; those are the best candidates.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Uncached context"
|
|
3
|
+
description: "Re-sending the whole conversation every turn."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
**Keys:** `uncached_context` (Claude models), `uncached_context_self_hosted` (other models)
|
|
7
|
+
|
|
8
|
+
## What it is
|
|
9
|
+
|
|
10
|
+
When prompt caching is working, each turn reads most of the conversation from the
|
|
11
|
+
cache at 0.1x. When it isn't, every turn re-sends the whole conversation as fresh
|
|
12
|
+
input at full price.
|
|
13
|
+
|
|
14
|
+
## How it's detected
|
|
15
|
+
|
|
16
|
+
A model call is flagged when it isn't the first call in its stream and has at least
|
|
17
|
+
**20,000** fresh (uncached) input tokens.
|
|
18
|
+
|
|
19
|
+
**Waste** = fresh tokens x (1 - 0.1): what caching would have saved.
|
|
20
|
+
|
|
21
|
+
## Claude models
|
|
22
|
+
|
|
23
|
+
Counted in the waste total and grade. The usual cause is a proxy or gateway between
|
|
24
|
+
the agent and the API (LiteLLM, Bedrock, a custom base URL) that drops the
|
|
25
|
+
`cache_control` markers, or a model where caching isn't enabled.
|
|
26
|
+
|
|
27
|
+
**Fix:** make sure your proxy passes prompt-caching markers through, and that
|
|
28
|
+
caching is enabled for the model you use.
|
|
29
|
+
|
|
30
|
+
## Self-hosted models
|
|
31
|
+
|
|
32
|
+
Reported as **informational** and not counted in the grade. For a model you run
|
|
33
|
+
yourself, re-processing context costs GPU prefill time and latency rather than
|
|
34
|
+
Claude-priced tokens, so pricing it with Claude's weights would mislead.
|
|
35
|
+
|
|
36
|
+
The fix quotes the measured share of this model's input served from its prefix
|
|
37
|
+
cache. To raise it:
|
|
38
|
+
|
|
39
|
+
- check prefix caching is on in your server (it's the default in recent vLLM;
|
|
40
|
+
SGLang uses RadixAttention),
|
|
41
|
+
- leave enough free KV-cache memory that cached prefixes aren't evicted,
|
|
42
|
+
- route all requests from one session to the same replica.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "FAQ"
|
|
3
|
+
description: "Common questions."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<details>
|
|
7
|
+
<summary>I'm on a subscription, does this matter?</summary>
|
|
8
|
+
|
|
9
|
+
Yes. Waste doesn't show up as a bill, but it uses up your plan's limits, so you hit them
|
|
10
|
+
sooner. The patterns and fixes are the same.
|
|
11
|
+
</details>
|
|
12
|
+
|
|
13
|
+
<details>
|
|
14
|
+
<summary>Why token-equivalents instead of dollars?</summary>
|
|
15
|
+
|
|
16
|
+
Prices and plans change, and cache reads, cache writes and fresh input are all priced
|
|
17
|
+
differently. Token-equivalents compare them fairly. Add `--usd-per-mtok` for a dollar
|
|
18
|
+
estimate. See [How it works](/agentwaste/how-it-works/#token-equivalents).
|
|
19
|
+
</details>
|
|
20
|
+
|
|
21
|
+
<details>
|
|
22
|
+
<summary>Is the waste figure exact?</summary>
|
|
23
|
+
|
|
24
|
+
No. It's an estimate of what each pattern cost, and some of it can't be avoided. Each
|
|
25
|
+
detector page explains exactly how it's computed.
|
|
26
|
+
</details>
|
|
27
|
+
|
|
28
|
+
<details>
|
|
29
|
+
<summary>Why is my self-hosted model "not counted"?</summary>
|
|
30
|
+
|
|
31
|
+
Its cost is GPU time and latency, not Claude-priced tokens. agentwaste still shows the
|
|
32
|
+
finding and your measured prefix-cache hit rate. See
|
|
33
|
+
[Uncached context](/agentwaste/detectors/uncached-context/#self-hosted-models).
|
|
34
|
+
</details>
|
|
35
|
+
|
|
36
|
+
<details>
|
|
37
|
+
<summary>Which agents are supported?</summary>
|
|
38
|
+
|
|
39
|
+
Claude Code today. Codex is next. Each source turns its logs into the same session
|
|
40
|
+
model, so the detectors work unchanged. Want another agent supported? See
|
|
41
|
+
[Contributing](/agentwaste/contributing/).
|
|
42
|
+
</details>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reducing waste"
|
|
3
|
+
description: "The habits that make the biggest difference."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
In order of typical impact:
|
|
7
|
+
|
|
8
|
+
1. **Compact or clear before a break.** The prompt cache lasts 5 minutes. Running
|
|
9
|
+
`/compact` before you step away means the context you come back to is small, so
|
|
10
|
+
re-caching it is cheap. Use `/clear` when you switch tasks. See
|
|
11
|
+
[Idle cache rebuild](/agentwaste/detectors/idle-cache-rebuild/).
|
|
12
|
+
2. **Check your proxy passes cache markers.** If you reach Claude through a gateway,
|
|
13
|
+
make sure prompt caching survives the hop. See
|
|
14
|
+
[Uncached context](/agentwaste/detectors/uncached-context/).
|
|
15
|
+
3. **Keep tool output small.** Limit command output with `head`, filter queries, and
|
|
16
|
+
read big files in ranges. See [Huge result](/agentwaste/detectors/huge-result/).
|
|
17
|
+
4. **Write things down in `CLAUDE.md`.** Facts the agent keeps re-reading, and fixes for
|
|
18
|
+
errors it keeps hitting, belong there. See [Re-read](/agentwaste/detectors/reread/)
|
|
19
|
+
and [Error thrash](/agentwaste/detectors/error-thrash/).
|
|
20
|
+
|
|
21
|
+
Re-run agentwaste a week later with `--days 7` to see whether it worked.
|