openclaw-token-optimizer
ยท v3.0.0
Reduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only โ no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
โ ๏ธ Hazard Flags
๐ Capabilities
Execution
- โ Shell execution
- โ Code execution
- โ Install dependencies
- โ Persistence
- Privilege: user
Filesystem
- โ Read workspace
- โ Write workspace
- โ Read home
- โ Write home
- โ Read system
- โ Delete
Network
- Egress: any
- โ Ingress
Credentials
- โ Environment vars
- โ Credential files
- โ Browser data
- โ Keychain
Actions
๐ Containment
Level: maximum
- SANDBOX_CONTAINER: Code execution capability
- LOG_ACTIONS: Audit trail for all actions
โก Risks
Mitigation: Review SKILL.md for hidden instructions. Do not use with untrusted input.
Mitigation: Use pre-built packages or vendored dependencies instead of cloning repos
Mitigation: Provide clear, detailed description of skill functionality
Mitigation: Minimize access to environment variables
Want a deeper analysis?
This report was generated by static analysis. Get an LLM-powered deep review with behavioral reasoning and attack surface mapping.
๐ง Deep Analysis โ $5.00๐จ Incident Response
Kill switch: Stop the agent process
Containment: Review logs for unexpected actions
Recovery: Depends on skill capabilities
๐ Raw SSDS JSON click to expand
{
"meta": {
"document_id": "ssds:auto:token-optimizer:3.0.0",
"ssds_version": "0.2.0",
"scanner_version": "0.4.0+fe6fd9123d50",
"created_at": "2026-03-05T02:23:13.438Z",
"created_by": {
"agent": "safeagentskills-cli/generate-ssds"
},
"language": "en",
"notes": "Auto-generated SSDS. Manual review recommended."
},
"skill": {
"name": "openclaw-token-optimizer",
"version": "3.0.0",
"format": "agent_skill",
"description": "Reduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only โ no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.",
"publisher": "ClawHub",
"source": {
"channel": "local"
},
"artifact": {
"sha256": "851a8680c399cd38ac614d586ce2393e310043c11cf23ae54b1b593e7e15b75e",
"hash_method": "files_sorted"
}
},
"capabilities": {
"execution": {
"can_exec_shell": true,
"can_exec_code": false,
"privilege_level": "user",
"can_install_deps": false,
"can_persist": false
},
"filesystem": {
"reads_workspace": true,
"reads_user_home": true,
"reads_system": false,
"writes_workspace": true,
"writes_user_home": true,
"writes_system": false,
"can_delete": true
},
"network": {
"egress": "any",
"ingress": false
},
"credentials": {
"reads_env_vars": true,
"reads_credential_files": true,
"reads_browser_data": false,
"reads_keychain": false
},
"services": [],
"actions": {
"can_send_messages": false,
"can_post_public": false,
"can_purchase": false,
"can_transfer_money": false,
"can_deploy": false,
"can_delete_external": false
},
"prompt_injection_surfaces": [
"web",
"documents"
],
"content_types": [
"general"
]
},
"hazards": {
"hdac": {
"H": 3,
"D": 4,
"A": 1,
"C": 1
},
"flags": [
"EXEC",
"FS_READ_WORKSPACE",
"FS_READ_USER",
"FS_WRITE_WORKSPACE",
"FS_WRITE_USER",
"FS_DELETE",
"NET_EGRESS_ANY",
"CREDS_ENV",
"CREDS_FILES",
"PI_WEB",
"PI_DOCUMENTS"
],
"custom_flags": [
{
"code": "PROMPT_INJECTION",
"name": "Prompt Injection Risk",
"description": "Contains prompt injection patterns in: scripts/context_optimizer.py"
},
{
"code": "FILE_DELETE",
"name": "File Deletion",
"description": "Can delete files in: scripts/heartbeat_optimizer.py"
},
{
"code": "TOOL_ABUSE",
"name": "Unauthorized Tool Use",
"description": "INSTRUCTED_GIT_CLONE_AND_BUILD, MCP_SYS_CRITICAL_ACCESS: Instructs agent to clone and potentially build from source"
},
{
"code": "SOCIAL_ENGINEERING",
"name": "Social Engineering Risk",
"description": "SOCIAL_ENG_VAGUE_DESCRIPTION, SOCIAL_ENG_ANTHROPIC_IMPERSONATION: Skill description is too vague or missing"
},
{
"code": "DATA_EXFILTRATION",
"name": "Data Exfiltration Risk",
"description": "DATA_EXFIL_ENV_VARS, MCP_EXFIL_CONVERSATION: Reading environment variables that may contain secrets"
}
],
"confidence": {
"level": "medium",
"basis": [
"static_analysis"
],
"notes": "Detected 5 security patterns (6 vendored rule hits). Review recommended."
},
"rationale": {
"H": "H3: Shell/code execution or persistence detected",
"D": "D4: Critical: Credential theft or data exfiltration",
"A": "A1: Local side effects only",
"C": "C1: General content"
}
},
"containment": {
"level": "maximum",
"required": [
{
"control": "SANDBOX_CONTAINER",
"reason": "Code execution capability"
}
],
"recommended": [
{
"control": "LOG_ACTIONS",
"reason": "Audit trail for all actions"
}
],
"uncontained_risk": "Risk level depends on manual review of actual capabilities."
},
"risks": {
"risks": [
{
"risk": "Prompt injection patterns detected in: scripts/context_optimizer.py",
"severity": "high",
"mitigation": "Review SKILL.md for hidden instructions. Do not use with untrusted input."
},
{
"risk": "Unauthorized tool use: INSTRUCTED_GIT_CLONE_AND_BUILD, MCP_SYS_CRITICAL_ACCESS",
"severity": "high",
"mitigation": "Use pre-built packages or vendored dependencies instead of cloning repos"
},
{
"risk": "Social engineering indicators: SOCIAL_ENG_VAGUE_DESCRIPTION, SOCIAL_ENG_ANTHROPIC_IMPERSONATION",
"severity": "low",
"mitigation": "Provide clear, detailed description of skill functionality"
},
{
"risk": "Data exfiltration patterns: DATA_EXFIL_ENV_VARS, MCP_EXFIL_CONVERSATION",
"severity": "high",
"mitigation": "Minimize access to environment variables"
}
],
"limitations": [
"Static analysis only - runtime behavior not verified"
]
},
"incident_response": {
"kill_switch": [
"Stop the agent process"
],
"containment": [
"Review logs for unexpected actions"
],
"recovery": [
"Depends on skill capabilities"
]
},
"evidence": [
{
"evidence_id": "EV:file-1",
"type": "file_excerpt",
"title": "_meta.json",
"file_path": "_meta.json"
},
{
"evidence_id": "EV:file-2",
"type": "file_excerpt",
"title": "README.md",
"file_path": "README.md"
},
{
"evidence_id": "EV:file-3",
"type": "file_excerpt",
"title": "scripts/context_optimizer.py",
"file_path": "scripts/context_optimizer.py"
},
{
"evidence_id": "EV:file-4",
"type": "file_excerpt",
"title": "scripts/heartbeat_optimizer.py",
"file_path": "scripts/heartbeat_optimizer.py"
},
{
"evidence_id": "EV:file-5",
"type": "file_excerpt",
"title": "scripts/model_router.py",
"file_path": "scripts/model_router.py"
},
{
"evidence_id": "EV:file-6",
"type": "file_excerpt",
"title": "scripts/optimize.sh",
"file_path": "scripts/optimize.sh"
},
{
"evidence_id": "EV:file-7",
"type": "file_excerpt",
"title": "scripts/token_tracker.py",
"file_path": "scripts/token_tracker.py"
},
{
"evidence_id": "EV:file-8",
"type": "file_excerpt",
"title": "SKILL.md",
"file_path": "SKILL.md"
},
{
"evidence_id": "EV:cisco-1",
"type": "file_excerpt",
"title": "INSTRUCTED_GIT_CLONE_AND_BUILD [MEDIUM] README.md:25: git clone https://github.com/Asif2BD/OpenClaw-Token-Optimizer.git \\",
"file_path": "README.md"
},
{
"evidence_id": "EV:cisco-2",
"type": "file_excerpt",
"title": "DATA_EXFIL_ENV_VARS [MEDIUM] scripts/model_router.py:20: if os.environ.get(\"ANTHROPIC_API_KEY\"):",
"file_path": "scripts/model_router.py"
},
{
"evidence_id": "EV:cisco-3",
"type": "file_excerpt",
"title": "MCP_SYS_CRITICAL_ACCESS [HIGH] scripts/optimize.sh:1: #!/bin/bash",
"file_path": "scripts/optimize.sh"
},
{
"evidence_id": "EV:cisco-4",
"type": "file_excerpt",
"title": "SOCIAL_ENG_VAGUE_DESCRIPTION [LOW] SKILL.md:1: ---",
"file_path": "SKILL.md"
},
{
"evidence_id": "EV:cisco-5",
"type": "file_excerpt",
"title": "SOCIAL_ENG_ANTHROPIC_IMPERSONATION [MEDIUM] SKILL.md:49: # Single-provider Anthropic setup: Use Sonnet, not Opus",
"file_path": "SKILL.md"
},
{
"evidence_id": "EV:cisco-6",
"type": "file_excerpt",
"title": "MCP_EXFIL_CONVERSATION [HIGH] SKILL.md:533: # 1. User sends message",
"file_path": "SKILL.md"
}
]
}