Skip to main content
Each cost playbook takes one kind of waste from a Switch Trust optimization to a verified fix. The last playbook fixes issues in your code without degrading evaluation results. Your coding agent reads the evidence through the Switch Trust MCP server, and you make the change in the agent’s own code or configuration. To set up the server, see Connect your coding agent. For a worked example, see Optimize agents. Record a baseline before running any playbook. Ask your coding agent for the agent’s latest evaluation results, and save the custom Metric score for task quality and the built-in evaluation results for safety. Evaluation results hold means both stay at that baseline after your change. See Connect an agent and run evaluations to set up both.
Prompts, responses, and input previews can contain secrets, customer data, or other sensitive content. Share numbers and short summaries in pull requests and tickets, not copied prompts or responses.
This page covers: A session groups the turns from one conversation or task. A turn, also called an interaction, is one prompt to the model behind your agent and the response to it. An issue is a problem Switch Trust found in your code, grouped by rule and severity, and each place it occurs is a finding.

Optimizations

Switch ROI, a Switch Trust capability, analyzes each agent’s recent traffic for cost waste and recommends optimizations for it. Each optimization is a short write-up for that agent, with a confidence level and, usually, an estimated savings in dollars over 30 days. On the Improvements tab, Verbosity shows Yes or No for whether the agent is a candidate, in place of a dollar figure. Weigh the confidence level before acting on a dollar figure. For context and retry optimizations, it’s lower when few sessions back the finding. Switch ROI re-runs each analysis about once a day, over the agent’s last 90 days of traffic. Traffic from before your change stays in that window for a while, so a later result reflects the fix gradually. When the waste is gone, the optimization’s write-up says so and it shows no savings. In Switch Trust, an agent’s optimizations appear on its Improvements tab. Switch ROI recommends each optimization, and you decide whether to apply it. Costs and savings are estimates, based on each model’s published price or the rate your organization has set for it. Tools: get_latest_roi_analyses for an agent’s current optimizations, list_roi_analyses for past results, get_roi_analysis for one in full, and list_roi_interactions for the traffic behind them.

Reduce context and token growth

Start from the agent’s context and verbosity optimizations.
To see the pattern in a real session, ask for the input, output, and cached tokens of each turn in the agent’s most expensive session. Input tokens that grow every turn, or cached tokens near zero, are the same patterns at turn level. Verify: tokens and cost per session fall for comparable work, and evaluation results hold. Tools: get_latest_roi_analyses, list_llm_sessions, get_llm_session, get_interaction.

Reduce model cost

Start from the agent’s model optimization, then check it against real traffic.
Fix: use the cheaper model the optimization names for the work it identifies. Verify: cost per session falls, and evaluation results hold. Tools: get_latest_roi_analyses, list_roi_interactions.

Reduce unnecessary tool calls

Start from the agent’s tool optimization, then compare the tools offered with the tools called.
Fix: remove the unused tool definitions the optimization lists. The analysis covers a window of recent traffic, so check that a tool isn’t needed for rarer tasks before you remove it. Verify: tokens per session fall, because fewer tool definitions go into every prompt, and evaluation results hold. Tools: get_latest_roi_analyses, list_roi_interactions.

Reduce retries and repeated calls

Start from the agent’s retry optimization, then find the sessions it describes.
Verify: turns and duration per session fall, and evaluation results hold. Tools: get_latest_roi_analyses, list_llm_sessions sorted by turns or duration_ms, get_llm_session, get_interaction.

Fix findings without degrading evaluation results

Ask for the issues on a file before you change it, with the fix for each.
Apply the remediation in your code. Your coding agent can do this directly from the guidance. Verify: the finding clears the next time Switch Trust scans your code, and evaluation results hold. Switch Trust scans your code from a GitHub Action or GitLab component in your CI pipeline. See How discovery works. If the file check returns complete: false, it stopped before checking every issue, so treat the result as unknown, not clean. Ask your coding agent to raise max_issues, up to 500, or narrow the search. Tools: find_issues_for_file, list_issues, get_issue, get_finding_detail, get_remediation_guidance.

Next steps

Optimize agents

Walk through the context and token playbook end to end

MCP tools

Every tool the server offers and what it returns