agentleFS
sblueminsbluemin/fleet-harness/.claude/skills/ai-gateway-loop-optimization/SKILL.md

ai-gateway-loop-optimization

Skill17 starsChanged 6 days agoMITView on GitHub

Optimize AI Gateway provider-loop latency, retries, tool amplification, or cache cost using before/after evidence from the same live workload. Not for general API features or UI-only diagnosis.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use observe → one optimization → controlled remeasurement → falsification.

    line 8
  2. Distinctive:

    Before baseline, read Measurement.

    line 20
  3. Very specific:

    Before editing, read Optimization and verification.

    line 22
  4. Distinctive:

    Run relevant package tests, typecheck, build, and git diff --check.

    line 24
  5. Distinctive:

    Read Reporting and gotchas when interpreting results.

    line 30

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

AI Gateway Loop Optimization

Use observe → one optimization → controlled remeasurement → falsification. Deliver more than a patch: reproducible evidence of which layer changed and whether the caller contract survived.

Inputs and experiment contract

Choose the exact provider/model and effort, a short workload (usually 3–5 logical operations), a symptom hypothesis, and trial count. Default to 5 successful trials before and after. Report changed sample sizes and excluded fixture failures.

Read Execution surface and use the smallest suitable path. For router/provider-loop behavior alone, use the standalone runner or built adapter without Console. When caller transcripts matter but Console does not, use the headless launcher path in console-e2e's live-agent reference; use a real Objective only when auxiliary turns or host lifecycle matter.

The live runner's confirmation flag consents to real quota use. Never add live calls to default test/CI paths. Raw wire contains sensitive prompt/tool payloads; collect it in scratchpad only with explicit authorization. Never record credentials.

Execution decisions

  1. Before baseline, read Measurement. Freeze literal model/effort, prompt, tool catalog/permissions, model-visible cwd/revision, turn-dispatch policy, logging, trial count, and success criteria. A changed condition or model mutation of the frozen tree invalidates that controlled comparison.
  2. Observe only existing layers. Separate caller executions, provider requests/retries, replay history, and host auxiliary turns. Do not report nonexistent standalone transcripts/lifecycle as zero. Record counts with denominators.
  3. Before editing, read Optimization and verification. State candidates as observed symptom → smallest change → expected delta → failure mode; change one thing per round. Wire size alone does not prove waste. Preserve provider stateless/retry/permission/tool contracts.
  4. Implement at the owning layer. Test positive and near-match negative cases, affected retry/cancellation/correlation behavior, and privacy boundaries. Repeat the baseline and challenge attribution with relevant failures, auxiliary turns, and repeated/concurrent cases. Use direct-adapter probes or focused tests for shapes the runner cannot express.
  5. Run relevant package tests, typecheck, build, and git diff --check. Add dependent Console build/restart only for Console wiring or real Objective changes. Repair task-induced regressions and reverify under the same conditions.

Completion

Finish when the target improves, caller calls/results/errors, permissions, and final result are preserved, and falsification checks pass. Also stop when evidence proves remaining cost belongs to a required upstream/host contract; report why it is not removable. Do not continue merely because a number is large.

Read Reporting and gotchas when interpreting results. Report before/after metrics, request ownership, frozen conditions, sample/exclusions, stable invariants, verification, and unknowns. Verify router/server cleanup for standalone runs; clean up only owned Console/agent processes for real Objectives.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.