Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add skills/humanerd-drew/opencode-drewgent/cost-optimization-background-llmnpx skills add humanerd-drew/opencode-drewgent --skill cost-optimization-background-llmgit clone --depth 1 https://github.com/humanerd-drew/opencode-drewgentWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/humanerd-drew/opencode-drewgent/cost-optimization-background-llm)<a href="https://agentmods.dev/skills/humanerd-drew/opencode-drewgent/cost-optimization-background-llm"><img src="https://agentmods.dev/badge/skills/humanerd-drew/opencode-drewgent/cost-optimization-background-llm.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00050 | $0.03579 |
| Opus 5 | $0.00025 | $0.01790 |
| Sonnet 5 | $0.00010 | $0.00716 |
| Haiku 4.5 | $0.00005 | $0.00358 |
Grade A, and why
cost-optimization-background-llm scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Runs shell commandslowCapability
Expected in a hook, worth knowing in a rule or an instructions file.
And add a `_run_script_subprocess()` helper that calls `subprocess.run()` How it starts
The opening of the file, as written. The whole thing — 324 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Cost Optimization — Background LLM Calls
Reduce LLM token spend on background/scheduled work in {{AGENT_NAME}} without touching the user-facing interactive path (CLI / ACP / Discord messages). Terminal-direct calls are off-scope by user preference.
Related skills
hermes-model-routing— broader framework for model selection across all 4 routing levels (main/delegation/auxiliary/provider_routing). This skill focuses on the cost dimension; the routing skill covers the complete selection framework.
When to use
Trigger words from user: "cost optimization", "background LLM", "cron LLM", "token cost", "cheap model", "스케줄 작업과 백그라운드".
Decision tree
Background LLM call site discovered
│
├── (1) Is the LLM call essential?
│ │
│ ├── Yes (report synthesis, MCP query, instruction) → keep LLM
│ │ but route to cheaper model via config.yaml
│ │
│ └── No (simple shell interpretation) → make deterministic
│
├── (2) What cost lever is available?
│ │
│ ├── Smart-routing cheap_model != main model
│ │ → config.yaml smart_model_routing.cheap_model.{provider,model}
│ │
│ ├── Auxiliary task model override
│ │ → config.yaml auxiliary.{task}.{provider,model}
│ │ tasks: vision, web_extract, compression, session_search,
│ │ skills_hub, approval, mcp, flush_memories
│ │
│ ├── Script-based fast path (cron)
│ │ → jobs.json add `script:` field + scheduler.py branch
│ │
│ └── Task body classification (kanban worker)
│ → classify first non-empty line; shell-prefix → subprocess
│
└── (3) Verify with hard evidence, not just "Done ✅" claims.
Procedure (5 phases)
Phase 1 — Inventory
# 1a) Cron jobs: list all jobs
jq '.jobs[] | {id, name, enabled, schedule, last_status, last_run_at}' \
~/.{{AGENT_NAME_LOWER}}/cron/jobs.json
# 1b) Find scheduler entry point
grep -n "run_job\|run_conversation\|AIAgent" \
~/.{{AGENT_NAME_LOWER}}/source/{{AGENT_NAME_LOWER}}-agent/cron/scheduler.py
# 1c) Background threads / fire-and-forget
grep -rn "threading.Thread\|daemon=True" \
~/.{{AGENT_NAME_LOWER}}/source/{{AGENT_NAME_LOWER}}-agent/ | grep -v test_
# 1d) Kanban worker LLM path
grep -n "AIAgent\|agent.chat\|run_conversation" \
~/.{{AGENT_NAME_LOWER}}/scripts/run_kanban_worker.py
# 1e) Auxiliary task consumers
grep -rn "call_llm\|async_call_llm" \
~/.{{AGENT_NAME_LOWER}}/source/{{AGENT_NAME_LOWER}}-agent/agent/ | grep -v test_
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 2d ago First seen · 324 lines · 50 tokens per session scan A 4b305e15cea6
cost-optimization-background-llm is a skill published in the GitHub repository humanerd-drew/opencode-drewgent (2 stars, last pushed 1mo ago), licensed MIT. It adds 50 tokens to every session and 3,579 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 1 finding (runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.
Other skills, from other repositories
ml-training-recipes
Battle-tested PyTorch training recipes for all domains — LLMs, vision, diffusion, medical imaging, protein/drug discovery, spatial omics, genomics. Covers training loops, optimizer selection (AdamW, Muon), LR scheduling, mixed precision, debugging, and systematic experimentation. Use when training or fine-tuning…
map
Build and commit a Cortex function knowledge graph — maps structural dependencies and domain intent relationships across all AI functions in the project. Supports --reduce (default on) for transitive reduction of the dependency graph.
context-add
Guided wizard to capture or update organizational Snowflake/Cortex standards into .cocoplus/context/ .md. Presents a menu of 6 standard types, collects answers via multi-turn dialogue, and commits the file.
cocolean
CocoLean — minimum viable Cortex surface discipline. Pre-build decision ladder and intensity mode management. Invoke with $lean, $lean lite, $lean full, or $lean ultra.
test
Enter the Test phase of CocoBrew. Reads spec.md test requirements, generates test cases, executes SQL validation and quality checks, records results in test.md. Can be re-run without full rebuild. Requires Build phase completion.
map-diff
Analyze the impact of staged git changes against the committed Cortex function knowledge graph — shows which downstream functions are affected before you commit.