← 返回
未分类 中文

Cron Cost Guard

Audit AI agent cron jobs for token cost risks, model-switch loops, and session isolation failures. Use when setting up new cron jobs, debugging unexpected to...
审计 AI 代理 cron 任务中的代币成本风险、模型切换循环和会话隔离失败。用于设置新 cron 任务或调试意外情况。
pouria3
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 312
下载
💾 0
安装
1
版本
#latest

概述

Cron Cost Guard

Prevent silent token budget burns from misconfigured AI agent cron jobs.

Quick Audit

Run this checklist on every cron setup or when investigating a cost spike:

1. Session Isolation (Critical)

Check every cron job for session binding conflicts:

cron list (includeDisabled: true)

Red flags:

  • sessionKey: "agent:main:main" with sessionTarget: "isolated" → stale binding, will cause model conflicts
  • agentId pointing to a different agent than the session owner → cross-agent model contamination
  • consecutiveErrors >= 3 → likely stuck in a retry loop
  • lastError containing LiveSessionModelSwitchError → model-switch loop confirmed

Fix: Remove and recreate the job without sessionKey. Set sessionTarget: "isolated".

2. Model Conflicts

In multi-agent setups (e.g., Agent A on Claude, Agent B on GPT), each agent's crons must be scoped to that agent only.

  • Set agentId explicitly on every cron job
  • Set model explicitly in the payload when available
  • Never let Agent B's cron inherit Agent A's session model

3. System Prompt Size

Audit injected workspace files:

wc -c MEMORY.md SOUL.md AGENTS.md TOOLS.md USER.md QUEUE.md

Target: < 20KB total injected. Move large files (playbooks, heartbeat templates, reference docs) to references/ for on-demand reading.

SizeStatus
--------------
< 20KBHealthy
20-40KBTrim soon
> 40KBTrim now — every API call is bloated

4. Cost Monitoring

sessions_list (limit: 10, messageLimit: 1)

Look for sessions with high estimatedCostUsd but low output tokens — that's a retry loop signature.

MetricHealthyWarningCritical
------------------------------------
Cron consecutive errors01-2≥3
Session cost (cron)< $0.50$0.50-2.00> $2.00
Model switch retries01-2≥3

Diagnosis: Token Spike

For detailed diagnosis steps and post-incident checklist, read references/diagnosis.md.

Prevention Rules

  1. Every cron job: sessionTarget: "isolated", no stale sessionKey
  2. Every cron job: explicit timeoutSeconds (never unlimited)
  3. Multi-agent: explicit agentId matching the agent that should run it
  4. After changing default model: audit all cron jobs for conflicts
  5. Weekly: check consecutiveErrors across all jobs — anything ≥ 3 needs investigation

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-07 12:11 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-intelligence

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,350 📥 317,750
ai-intelligence

self-improving agent

pskoett
捕获经验教训、错误和纠正,以实现持续改进。使用时机:(1)命令或操作意外失败;(2)用户纠正……
★ 4,056 📥 796,412
developer-tools

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 668 📥 323,845