[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M75DN5XWKAR5WX60Q2DQ3JSQ":3,"skill-same:01M75DN5XWKAR5WX60Q2DQ3JSQ":46},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":23,"commitSha":24,"skillDirectory":25,"forksCount":26,"repositoryHtmlUrl":27,"repositoryHomepageUrl":28,"ownerHtmlUrl":29,"ownerBlogUrl":30,"ownerDescription":6,"updatedAt":31,"install":32,"resources":45},"01M75DN5XWKAR5WX60Q2DQ3JSQ","cost_bounded_agent_looping",null,"LongLeo287\u002FSEOSONA-OS","LongLeo287","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F141803367?v=4","01M6JK75C62VCNZKR5BRZ386YV","LongLeo","01M75CK60XQGYJY3YDGGFJQDYT",2,"MIT","https:\u002F\u002Fgithub.com\u002FLongLeo287\u002FSEOSONA-OS\u002Fblob\u002Fmain\u002F2_KNOWLEDGE\u002Fframeworks\u002Fagentic_workflows\u002Fcost_bounded_agent_looping\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\n\nname: cost-bounded-agent-looping\nversion: 1.0.0\ndescription: \"Control costs in autonomous agent loops by enforcing ceilings on iterations, spending, and time.\"\n  Enforce cost, iteration, and time ceilings on agent loops to prevent\n  runaway token spending. Provides a cost_tracker.js module for tracking\n  token usage per-iteration, detecting diminishing returns, and generating\n  session reports. Integrates with SEOSONA CLI via `seosona cost`.\nlicense: MIT\ncompatibility: claude-code opencode antigravity\nallowed-tools:\n  - Read\n  - Exec\n  - Grep\n---\n\n# Cost-Bounded Agent Looping\n\nControl costs in autonomous agent loops by enforcing ceilings on iterations, spending, and time.\n\n## Quick Start\n\n```javascript\nconst ct = require('~\u002F.seosona\u002F1_CORE\u002Fscripts\u002Fcost_tracker');\n\n\u002F\u002F Create tracker with preset\nconst tracker = ct.createTracker({ taskType: 'standard' });\n\n\u002F\u002F In your agent loop:\nwhile (ct.shouldContinue(tracker)) {\n    const result = doWork();\n    const iterResult = ct.recordIteration(tracker, {\n        input: result.inputTokens,\n        output: result.outputTokens\n    }, result.qualityScore);\n\n    if (iterResult.stopped) {\n        console.log(`Loop stopped: ${iterResult.reason}`);\n        break;\n    }\n    if (iterResult.warnings.length) {\n        console.warn(iterResult.warnings.join('; '));\n    }\n}\n\n\u002F\u002F Save session and get report\nconst report = ct.saveSession(tracker);\nconsole.log(`Total: $${report.totalCost} over ${report.iterations} iterations`);\n```\n\n## CLI Commands\n\n```bash\nseosona cost estimate \"Refactor the authentication module\"\nseosona cost report\nseosona cost models\nseosona cost ceilings\n```\n\n## Loop Design Rules\n\n### Rule 1: Always Set max_iterations\nNever allow unbounded loops. Even \"unlimited\" preset caps at 100 iterations.\n\n### Rule 2: Track Cumulative Cost\nNot just per-iteration — total cumulative cost matters. The tracker enforces a `costCeiling` in USD.\n\n### Rule 3: Implement Exponential Backoff\nOn retries, increase wait time. Don't hammer the API with rapid retry loops.\n\n### Rule 4: Log Every Iteration\nThe tracker records every iteration's tokens, cost, and timestamp for post-mortem analysis. Sessions are saved to `~\u002F.seosona\u002F3_MEMORY\u002Flogs\u002Fcost_tracker_sessions.jsonl`.\n\n### Rule 5: Exit Early on Diminishing Returns\nIf `qualityScore` plateaus across 3 consecutive iterations (delta \u003C threshold), the loop stops automatically.\n\n## Ceiling Presets\n\n| Type | Max Iters | Ceiling | Timeout | Use Case |\n|---|---|---|---|---|\n| `quick` | 3 | $0.10 | 60s | Simple fixes, formatting |\n| `standard` | 10 | $1.00 | 5min | Normal development |\n| `deep` | 25 | $5.00 | 10min | Complex refactoring |\n| `research` | 50 | $10.00 | 30min | UAP triage, analysis |\n| `unlimited` | 100 | $50.00 | 60min | Full audit, overnight |\n\n## Decision Tree: Choosing a Ceiling\n\n```\nIs this a one-shot task?\n├── Yes → 'quick' (3 iters, $0.10)\n└── No → Does it involve multiple files?\n    ├── No → 'standard' (10 iters, $1.00)\n    └── Yes → Is it exploratory\u002Fresearch?\n        ├── No → 'deep' (25 iters, $5.00)\n        └── Yes → 'research' (50 iters, $10.00)\n```\n\n## Model Pricing\n\nThe tracker embeds current pricing for 15+ models:\n- **Anthropic**: Claude Sonnet 4, Opus 4, Haiku\n- **Google**: Gemini 2.5 Pro\u002FFlash, 2.0 Flash\n- **OpenAI**: GPT-4o, 4.1, o3, o4-mini\n\n## Integration Points\n\n- **Module**: `~\u002F.seosona\u002F1_CORE\u002Fscripts\u002Fcost_tracker.js`\n- **CLI**: `seosona cost estimate|report|models|ceilings`\n- **Session logs**: `~\u002F.seosona\u002F3_MEMORY\u002Flogs\u002Fcost_tracker_sessions.jsonl`\n- **SOP**: `~\u002F.seosona\u002F2_KNOWLEDGE\u002Fsops\u002Fagent_loop_design_sop.md`\n","# Cost-Bounded Agent Looping\n\nControl costs in autonomous agent loops by enforcing ceilings on iterations, spending, and time.\n\n## Quick Start\n\n```javascript\nconst ct = require('~\u002F.seosona\u002F1_CORE\u002Fscripts\u002Fcost_tracker');\n\n\u002F\u002F Create tracker with preset\nconst tracker = ct.createTracker({ taskType: 'standard' });\n\n\u002F\u002F In your agent loop:\nwhile (ct.shouldContinue(tracker)) {\n    const result = doWork();\n    const iterResult = ct.recordIteration(tracker, {\n        input: result.inputTokens,\n        output: result.outputTokens\n    }, result.qualityScore);\n\n    if (iterResult.stopped) {\n        console.log(`Loop stopped: ${iterResult.reason}`);\n        break;\n    }\n    if (iterResult.warnings.length) {\n        console.warn(iterResult.warnings.join('; '));\n    }\n}\n\n\u002F\u002F Save session and get report\nconst report = ct.saveSession(tracker);\nconsole.log(`Total: $${report.totalCost} over ${report.iterations} iterations`);\n```\n\n## CLI Commands\n\n```bash\nseosona cost estimate \"Refactor the authentication module\"\nseosona cost report\nseosona cost models\nseosona cost ceilings\n```\n\n## Loop Design Rules\n\n### Rule 1: Always Set max_iterations\nNever allow unbounded loops. Even \"unlimited\" preset caps at 100 iterations.\n\n### Rule 2: Track Cumulative Cost\nNot just per-iteration — total cumulative cost matters. The tracker enforces a `costCeiling` in USD.\n\n### Rule 3: Implement Exponential Backoff\nOn retries, increase wait time. Don't hammer the API with rapid retry loops.\n\n### Rule 4: Log Every Iteration\nThe tracker records every iteration's tokens, cost, and timestamp for post-mortem analysis. Sessions are saved to `~\u002F.seosona\u002F3_MEMORY\u002Flogs\u002Fcost_tracker_sessions.jsonl`.\n\n### Rule 5: Exit Early on Diminishing Returns\nIf `qualityScore` plateaus across 3 consecutive iterations (delta \u003C threshold), the loop stops automatically.\n\n## Ceiling Presets\n\n| Type | Max Iters | Ceiling | Timeout | Use Case |\n|---|---|---|---|---|\n| `quick` | 3 | $0.10 | 60s | Simple fixes, formatting |\n| `standard` | 10 | $1.00 | 5min | Normal development |\n| `deep` | 25 | $5.00 | 10min | Complex refactoring |\n| `research` | 50 | $10.00 | 30min | UAP triage, analysis |\n| `unlimited` | 100 | $50.00 | 60min | Full audit, overnight |\n\n## Decision Tree: Choosing a Ceiling\n\n```\nIs this a one-shot task?\n├── Yes → 'quick' (3 iters, $0.10)\n└── No → Does it involve multiple files?\n    ├── No → 'standard' (10 iters, $1.00)\n    └── Yes → Is it exploratory\u002Fresearch?\n        ├── No → 'deep' (25 iters, $5.00)\n        └── Yes → 'research' (50 iters, $10.00)\n```\n\n## Model Pricing\n\nThe tracker embeds current pricing for 15+ models:\n- **Anthropic**: Claude Sonnet 4, Opus 4, Haiku\n- **Google**: Gemini 2.5 Pro\u002FFlash, 2.0 Flash\n- **OpenAI**: GPT-4o, 4.1, o3, o4-mini\n\n## Integration Points\n\n- **Module**: `~\u002F.seosona\u002F1_CORE\u002Fscripts\u002Fcost_tracker.js`\n- **CLI**: `seosona cost estimate|report|models|ceilings`\n- **Session logs**: `~\u002F.seosona\u002F3_MEMORY\u002Flogs\u002Fcost_tracker_sessions.jsonl`\n- **SOP**: `~\u002F.seosona\u002F2_KNOWLEDGE\u002Fsops\u002Fagent_loop_design_sop.md`\n",{},"main","4fd50b1281e8cd978866b6b4556242605cabf708","2_KNOWLEDGE\u002Fframeworks\u002Fagentic_workflows\u002Fcost_bounded_agent_looping",1,"https:\u002F\u002Fgithub.com\u002FLongLeo287\u002FSEOSONA-OS","https:\u002F\u002Fseosona-os.vercel.app","https:\u002F\u002Fgithub.com\u002FLongLeo287","https:\u002F\u002Fwww.facebook.com\u002FResourceRookie2023","2026-10-09 15:14:13",{"source":7,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add LongLeo287\u002FSEOSONA-OS --skill cost_bounded_agent_looping",{"tool":38,"command":39},"bunx","bunx skills add LongLeo287\u002FSEOSONA-OS --skill cost_bounded_agent_looping",{"tool":41,"command":42},"pnpm","pnpm dlx skills add LongLeo287\u002FSEOSONA-OS --skill cost_bounded_agent_looping","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FLongLeo287\u002FSEOSONA-OS\u002Fblob\u002Fmain\u002F2_KNOWLEDGE\u002Fframeworks\u002Fagentic_workflows\u002Fcost_bounded_agent_looping\u002FSKILL.md",true,[],[47,54,61,68,75,82],{"skillNo":48,"name":49,"nameZh":6,"description":50,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":51,"categories":52,"keywords":53,"publishedAt":18},"01M75F0T3V3W7JQQ05X26NNN2T","web_crawler_katana","High-speed web crawling using Katana patterns for deep site mapping, URL discovery, and content extraction.","https:\u002F\u002Fgithub.com\u002FLongLeo287\u002FSEOSONA-OS\u002Fblob\u002Fmain\u002F2_KNOWLEDGE\u002Fskills\u002Fseo_technical\u002Fweb_crawler_katana\u002FSKILL.md",[],[],{"skillNo":55,"name":56,"nameZh":6,"description":57,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":58,"categories":59,"keywords":60,"publishedAt":18},"01M75F0Q2QJXDGAFKC7D84GT88","server_log_analyzer","Analyzes Nginx\u002FApache server logs to identify Googlebot crawl patterns, errors, and performance bottlenecks.","https:\u002F\u002Fgithub.com\u002FLongLeo287\u002FSEOSONA-OS\u002Fblob\u002Fmain\u002F2_KNOWLEDGE\u002Fskills\u002Fseo_technical\u002Fserver_log_analyzer\u002FSKILL.md",[],[],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":18},"01M75F0KZP6D8R8XPN2YT35BAJ","schema_markup_generator","Auto-generates JSON-LD structured data for any page type (Article, Product, FAQ, LocalBusiness, etc.).","https:\u002F\u002Fgithub.com\u002FLongLeo287\u002FSEOSONA-OS\u002Fblob\u002Fmain\u002F2_KNOWLEDGE\u002Fskills\u002Fseo_technical\u002Fschema_markup_generator\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":18},"01M75F0G3KX4Y86AXJXTKXVEVA","internal_linking_optimizer","Analyzes and optimizes the internal link graph of a website for SEO authority distribution.","https:\u002F\u002Fgithub.com\u002FLongLeo287\u002FSEOSONA-OS\u002Fblob\u002Fmain\u002F2_KNOWLEDGE\u002Fskills\u002Fseo_technical\u002Finternal_linking_optimizer\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":18},"01M75F0CS1RYX4YPJC7N6RAAQJ","google_trends_analyzer","Detects trending topics and seasonal patterns using Google Trends data for content planning and keyword strategy.","https:\u002F\u002Fgithub.com\u002FLongLeo287\u002FSEOSONA-OS\u002Fblob\u002Fmain\u002F2_KNOWLEDGE\u002Fskills\u002Fseo_technical\u002Fgoogle_trends_analyzer\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":18},"01M75F0ASMQ1GKPFX82D19SRTN","brand_context_analyzer","Tracks brand mentions, sentiment, and online reputation across web sources.","https:\u002F\u002Fgithub.com\u002FLongLeo287\u002FSEOSONA-OS\u002Fblob\u002Fmain\u002F2_KNOWLEDGE\u002Fskills\u002Fseo_technical\u002Fbrand_context_analyzer\u002FSKILL.md",[],[]]