Skip to content

moonlight-lupin/agent-skills / agent-ops/input-token-overheads

input-token-overheads

Verified

Use when the context window fills too fast, per-turn input token cost is too high, or the aggregate input token bill needs explaining and fixing. Two audits: (1) overhead — tool schemas, skills index, system fixed text, user profile, memory recall measured live, ranked, reduced; (2) cost accounting — total input token volume across sessions, cron fires, and tool traffic, with cache-aware interpretation, pre-checked config levers, and scheduled delta checks. scripts/audit_overheads.py for per-turn overhead, scripts/audit.py for totals.

FileKindSize
SKILL.mdskill md25.3 KB
evals/routing-fixtures.jsonconfig583 B
scripts/audit.pyscript9.9 KB
scripts/audit_overheads.pyscript17.8 KB
tests/test_audit_overheads.pyscript2.0 KB

tests/test_audit_overheads.py

View on GitHub
"""Unit tests for the input-token-overheads audit script (stdlib only, no network)."""
import importlib.util
import tempfile
import unittest
from pathlib import Path

SCRIPT = Path(__file__).resolve().parent.parent / "scripts" / "audit_overheads.py"
_spec = importlib.util.spec_from_file_location("audit_overheads", SCRIPT)
mod = importlib.util.module_from_spec(_spec)
_spec.loader.exec_module(mod)


class HealthRatio(unittest.TestCase):
    def test_ratings(self):
        def rating(tokens):
            pct, r = mod.health_ratio(tokens)
            return r
        self.assertEqual(rating(9_000), "excellent")
        self.assertEqual(rating(29_000), "healthy")
        self.assertEqual(rating(31_000), "acceptable")
        self.assertEqual(rating(51_000), "unhealthy")


class CheckFile(unittest.TestCase):
    def test_status_by_cap(self):
        with tempfile.TemporaryDirectory() as d:
            p = Path(d) / "USER.md"
            p.write_text("x" * 2999)
            self.assertEqual(mod.check_file(str(p), 3000, "u")["status"], "OK")
            p.write_text("x" * 3001)
            self.assertEqual(mod.check_file(str(p), 3000, "u")["status"],
                             "TRUNCATED")
            self.assertEqual(mod.check_file(str(Path(d) / "nope"), 3000,
                                            "u")["status"], "MISSING")


class InjectedFiles(unittest.TestCase):
    def test_profile_scan_respects_envless_default(self):
        with tempfile.TemporaryDirectory() as d:
            old = mod.HERMES
            try:
                mod.HERMES = d
                for p in (d, Path(d) / "memories"):
                    Path(p).mkdir(parents=True, exist_ok=True)
                (Path(d) / "memories" / "USER.md").write_text("y" * 100)
                out = mod.audit_injected_files()
                rows = {f["file"]: f for f in out}
                self.assertIn("user profile", rows)
                self.assertEqual(rows["user profile"]["status"], "OK")
            finally:
                mod.HERMES = old


if __name__ == "__main__":
    unittest.main(verbosity=2)
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall