# Self-Tuning Controls

> A production-ready registry for safe agent self-tuning, budget enforcement, and role-based parameter access.

Self-Tuning Controls is a paid AI agent skill on Agensi by Phil Marcus, in Agents & Orchestration. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $10 (one-time purchase)
- Creator: [Phil Marcus](https://www.agensi.io/creators/phil-marcus)
- Category: [Agents & Orchestration](https://www.agensi.io/skills/agents-orchestration)
- Version: 1.0
- Last updated: 2026-10-19
- Security: scan passed (2026-10-19); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/self-tuning-controls
- Tags: ai-agents, python, llm-ops, automation, cost-control

## About this skill

Letting an agent adjust its own parameters is the most efficient path to self-improvement, but often leads to uncontrolled cost blowouts or unstable behaviors. This skill provides a production-hardened controls registry that allows agents to tune their runtime safely. It enforces strict boundaries, typed validation, and role-based permissions to ensure the agent only modifies what it should.

### What it does
- **Typed Controls** provides a registry for float, int, str, bool, and model-weight types with strict min/max bounds and validation.
- **Role-Based Access** separates tunables by audience (agent, accountant, operator) to hide sensitive budget or safety knobs from the planner.
- **Temporary Overrides** manages experimental changes that automatically revert after a specified number of cycles.
- **Budget Ledger** tracks real-time spend across different models, including specific pricing for cached tokens.
- **Accountant Model** uses a cheap secondary model to enforce coherence rules and cost cadence without jittering parameters.
- **Change Provenance** maintains a detailed log of who moved which knob and why for auditing and debugging.

### How it works
1. **Initialize Registry** by defining controls with audiences, bounds, and default values in a Python script.
2. **Inject Context** into each agent cycle by rendering the permitted control blocks directly into the system prompt.
3. **Handle Updates** by processing the agent's requested changes through validation and permission checks.
4. **Run Accountant** as a pre-cycle step to enforce budget-related levers and snap controls to coherent ratios.

### Frameworks & tools
This tool is provider-neutral and written in pure Python 3.9+ using only the standard library. It integrates with any LLM provider (OpenAI, Anthropic, Ollama) via simple tool-wiring patterns.

### Why this beats prompting it yourself
Prompting an agent to "stay under budget" is unreliable and prone to drift. This skill provides hard constraints, persistence, and a secondary "accountant" logic layer that protects your infrastructure even if the main planner malfunctions.

### Use cases
- **Dynamic Cadence** for agents that need to increase or decrease interaction frequency based on task urgency.
- **Model Pool Routing** to swap between expensive and cheap models based on current budget remaining and task complexity.
- **Self-Optimizing Memory** where the agent tunes its own context window and retrieval depth parameters.
- **Runtime Experiments** to test new parameters for a fixed duration before reverting to safe defaults.

### Known limitations
This logic is designed for cycle-based agents and requires external persistence (like a JSON file) between cycles. It does not include built-in model API clients.

## Requires

- Python 3.9+

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the Self-Tuning Controls skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### How does this skill prevent an agent from accidentally spending too much money?

This skill acts as a safety layer that prevents agents from causing cost overruns or unstable behaviors by enforcing strict bounds, budget ledgers, and role-based permissions on all self-tuning actions.

### Can I use this registry with different LLM providers or custom-built agents?

Yes, it is provider-neutral and written in pure Python 3.9+, making it compatible with any LLM (like OpenAI or Anthropic) and any agentic framework that supports tool-wiring.

### What exactly is included in the download package?

Four standard-library Python modules: controls.py (the typed, bounded ControlRegistry with audiences, locks, change log, temporary overrides, per-audience prompt blocks and tool specs), budget.py (the DailyBudget ledger with cached-token pricing and same-day restore), accountant.py (levers, coherence rules and the cheap-model Accountant loop with its oscillation guard) and example_registry.py (twenty starter controls with audiences assigned, meant to be edited). Plus an 11-test offline suite and three reference docs: the design notes and failure modes, the full accountant prompt, and tool wiring for Anthropic, OpenAI and Gemini.

### How difficult is it to integrate the registry into an existing agent workflow?

Setting up involves defining your controls (such as min/max bounds and default values) in a Python script and connecting your preferred persistence layer, like a JSON file or database.

### What is the purpose of the 'Accountant Model' mentioned in the description?

The accountant is a second, cheap or local model that runs every cycle before the planner and owns the cost and cadence controls (sentry interval, wake target, model pools). It sees the budget ledger and a cost projection, proposes changes along a conservation-ordered list of levers, and its changes pass an oscillation guard (moves under 10 percent are dropped) and coherence rules that snap related controls into valid ratios. The planner never sees those knobs; its own requests are validated by the registry, not by the accountant.

### Is there a way to test parameter changes without permanently modifying my agent's configuration?

The skill includes a 'Temporary Overrides' feature that allows agents to test new parameters for a set number of cycles, after which the system automatically reverts to your safe default settings.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
