agent-cost-guard
Use when monitoring token cost per loop, detecting token maxing, or limiting parallel subagents to control cost and context pressure.
- License 许可
- MIT
- 最近更新
- 2026-11-15
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- agent-cost-guard
- triggers
- [ "user", "model" ]
- description
- Use when monitoring token cost per loop, detecting token maxing, or limiting parallel subagents to control cost and context pressure.
03 SKILL.md 正文
Agent Cost Guard
Monitors token cost and agent parallelism to prevent runaway spending. Enforces the 1-3 subagent limit and alerts when a loop or task is consuming excessive tokens.
When to use
- When a task involves loops, retries, or polling.
- When multiple subagents are being dispatched.
- When the conversation is long and context is tight.
- When the user asks about cost or token usage.
Limits
| Limit | Action |
|---|---|
| 1-3 subagents | Default maximum. Alert if more are requested. |
| >3 subagents | Require explicit user approval. |
| Token maxing | Detect when effort is disproportionate to task difficulty. |
| Loop cost | Bound retries and polling; each iteration multiplies cost. |
What to check
- Subagent count. Are more than 3 subagents being dispatched at once? The PreToolUse hook
scripts/validate-tool-args.pyenforcesrun_subagentmax_parallel <= 3and requiresmax_parallelto be an integer. - Loop bounds. Are retries, polling, or verification loops bounded?
- Token cost. Is the effort level appropriate for the task difficulty?
- Context pressure. Is the active context approaching the threshold?
Process
Before dispatching subagents or starting a loop
→ Check subagent count (limit: 3)
→ Check loop bounds (max retries, max polls)
→ Check effort level (match to task difficulty)
→ If any limit exceeded: alert user or split into batches
Example
# Bad: unbounded retry loop
while not success:
retry() # costs tokens each iteration
# Good: bounded retry with max attempts
for attempt in range(3):
if success:
break
retry()
Anti-patterns
- Dispatching >3 subagents without approval.
- Unbounded retry or polling loops.
- Using maximum effort for trivial tasks.
- Ignoring token cost when the parent model is paid.
Dispatch budgets (opt-in)
validate-tool-args.py enforces optional caps when
<devin-home>/state/subagent-budget.json exists (absent = uncapped):
| Knob | Effect |
|---|---|
max_dispatches |
Block dispatch when session's recorded dispatches reach cap. |
session_max_minutes |
Block new dispatches when minutes since session's first dispatch exceed cap. |
max_cost_usd + spent_usd |
Block when spent_usd >= max_cost_usd. spent_usd must be updated by an external recorder — the hook cannot observe token spend. |
Every dispatch appends to state/subagent-ledger.jsonl (ts, session_id,
profile, title) once a policy exists. Override the state dir with
DEVIN_STATE_DIR (used by tests).
Honest limits: no per-agent wall-clock kill (hooks see no subagent lifecycle events), no real-time cost (no token telemetry) — enforcement is at dispatch time only.
Cross-skills
effort-calibration- chooses the right effort level for the task.cost-optimization- broader cost guidance (models, cache, MCPs).context-window-hygiene- context pressure and clear/compact decisions.dispatching-parallel-agents- parallel work, but bounded by this guard.
04 同仓库更多 Skills
montador-de-ideias
Use when assembling, expanding, or elevating a raw project idea or initial prompt into an ultra-detailed, first-principles dossier and compiled master prompt with journalistic OSINT market research, Tech Lead and Staff Architect justifications, atomic and modular hardening/optimization, and high-impact contact surfaces.
git-github-adaptive-engineering
Use when any task touches git history, GitHub issues/PRs/releases/CI, repo governance, or branch and merge decisions. Runs the Fase Zero situational-awareness battery, picks one of five delivery flows via the adaptive decision engine, and enforces commit/PR information-density standards. Orchestrates the gh, git-workflows, github-actions, pr, and debug/finish skills.
adaptive-agenda-calendar-routine-engine
Use when planning or executing work across hours, days, weeks, or sprints. Turns the calendar into a strict time-blocked agenda (HH:MM-HH:MM blocks carrying a routine profile, expected inputs, and a handoff output artifact), runs the 5-stage cognitive flow (Radar and Hunt -> Triage plus Steve Jobs conception -> workbench manifest -> >=32-cycle loop -> Close plus Open-Minded Scrum), and unfolds macro calendar milestones into micro agenda blocks through extensions/gcal/wrapper.py.
demo
Use when demonstrating a skill in a fixture project.
duplicate-skill
Use when testing duplicate skill name detection.
duplicate-skill
Use when testing duplicate skill name detection.