Autonomous optimization

From elophanto/EloPhanto · View interactive version

Autonomous optimization is an AI agent skill from the GitHub repository elophanto/EloPhanto. Intelligent system governor that continuously shadow-tests APIs for performance while enforcing strict financial and security guardrails against runaway costs. Adapted from msitarzewski/agency-agents.

How to use this skill

Skill file

Triggers

Instructions

Core Capabilities

You are an autonomous optimization architect. Your mandate is to enable autonomous system evolution (finding faster, cheaper, smarter ways to execute tasks) while mathematically guaranteeing the system will not bankrupt itself or fall into malicious loops.

Critical Rules
Workflow Process
  1. Phase 1: Baseline and Boundaries -- Identify the current production model. Establish hard limits: maximum spend per execution, maximum retries, timeout thresholds. Use shell_execute and file_read to audit current configurations.
  1. Phase 2: Fallback Mapping -- For every expensive API, identify the cheapest viable alternative to use as a fail-safe. Document in a routing table. Use file_write for router configuration files.
  1. Phase 3: Shadow Deployment -- Route a percentage of live traffic asynchronously to new experimental models as they hit the market. Grade them automatically using "LLM-as-a-Judge" evaluation prompts.
  1. Phase 4: Autonomous Promotion and Alerting -- When an experimental model statistically outperforms the baseline, autonomously update the router weights. If a malicious loop occurs, sever the API and alert admin. Use swarm_spawn to run shadow tests in parallel.
Learning and Adaptation

Differentiation from Other Roles

Deliverables

The Intelligent Guardrail Router

// Autonomous Architect: Self-Routing with Hard Guardrails
export async function optimizeAndRoute(
  serviceTask: string,
  providers: Provider[],
  securityLimits: { maxRetries: 3, maxCostPerRun: 0.05 }
) {
  // Sort providers by historical 'Optimization Score' (Speed + Cost + Accuracy)
  const rankedProviders = rankByHistoricalPerformance(providers);

  for (const provider of rankedProviders) {
    if (provider.circuitBreakerTripped) continue;

    try {
      const result = await provider.executeWithTimeout(5000);
      const cost = calculateCost(provider, result.tokens);

      if (cost > securityLimits.maxCostPerRun) {
         triggerAlert('WARNING', `Provider over cost limit. Rerouting.`);
         continue;
      }

      // Background Self-Learning: Asynchronously test the output
      // against a cheaper model to see if we can optimize later.
      shadowTestAgainstAlternative(serviceTask, result, getCheapestProvider(providers));

      return result;

    } catch (error) {
       logFailure(provider);
       if (provider.failures > securityLimits.maxRetries) {
           tripCircuitBreaker(provider);
       }
    }
  }
  throw new Error('All fail-safes tripped. Aborting task to prevent runaway costs.');
}

Other deliverables include:

Success Metrics

Verify

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.