CodePanel
get_optimization

get_optimization

The CodePanel MCP tool that combines a repository's spend, verified quality and two alternative panels into one read-only report on what to change.

On this page›

get_optimization answers "what should I change about this repository's reviews?" in one call: this month's spend, verified quality, who wrote the code, provider problems, and two alternative panels with estimated costs. Call it from any repository's agent to inspect CodePanel's setup for a named repository. It changes nothing and makes no model call. It needs the read scope.

When to call it

  • When review cost looks high: it is cheaper than reading get_spend, get_quality and get_panel_recommendation one by one.
  • Before apply_panel: the nextAction names the exact apply call for each alternative.
  • To hand a task to another agent: markdownPrompt is a ready brief for an agent in that repository's checkout.

It does not audit source code, and its estimates are not proven savings.

Inputs

Input Type Required Description
repo string yes Repository as owner/name

It only reads: the server marks it readOnlyHint: true, so clients that ask before a write can run it without asking.

repo is owner/name. The call authenticates and reads spend first. If another part cannot load, you still get the spend, and the failed part is named in diagnosticErrors.

What it returns

  • spend: the get_spend report.
  • quality: the get_quality report, or null if it could not load.
  • authorship: over the latest 100 rounds, how many had an identified author agent family (authors, sameAuthorFamilyRounds, unknownAuthorRounds, stampedRounds). A missing marker means unknown, never human.
  • configurationIssues: each { provider, status, action }. A provider whose key is not valid, rounds where every seat came from the author's own model family (same_author_family), or rounds with an unknown author (unknown_author).
  • alternatives: balanced and economy, each a get_panel_recommendation result for this repository with changes, comparison (current cost a round, estimated change per pull request), estimate and nextAction.
  • analysisSteps and markdownPrompt: what to check before applying anything.
  • diagnosticErrors: parts that could not load, each with the component and a message. Empty when all loaded.
  • nextAction: the apply commands, and a reminder that apply replaces reviewers and the orchestrator, so save the undo.

Examples

These responses come from a test account on a local backend. The panel, prices and spend are seed data. The full result is about 34 KB. Five of its keys are shown, each as returned, with analysisSteps cut to its first two items.

Call
{ "repo": "codepanel-dev/web-app" }
Result (trimmed)
{
  "authorship": {
    "authors": [{ "family": "unknown", "rounds": 5 }],
    "latestAuthor": null,
    "limit": 100,
    "sameAuthorFamilyRounds": 0,
    "sampledRounds": 5,
    "singleProviderRounds": 0,
    "stampedRounds": 0,
    "unknownAuthorRounds": 5
  },
  "diagnosticErrors": [],
  "configurationIssues": [
    {
      "provider": "authorship",
      "status": "unknown_author",
      "action": "5 recent rounds lack agent-family attribution. Add plain-text Authoring agent: and Authoring model: declarations to PR descriptions; missing markers do not establish human authorship."
    }
  ],
  "analysisSteps": [
    "In the target repository, read its agent guidance, architecture, critical paths and tests. Use that source context to choose reviewer roles; this report does not inspect source code.",
    "Compare quality.byModel and quality.byRole when available, including verified sample sizes and uncertainty. Do not infer that an unmeasured model improves this codebase."
  ],
  "nextAction": "Review spend.suggestions and verified quality, then compare alternatives. Apply with codepanel panel apply --repo codepanel-dev/web-app --cost low --quality medium (balanced) or --quality low (economy), or MCP apply_panel with the same arguments. These replace reviewers and the orchestrator; inspect the roles and save undo. No settings changed."
}

The other keys are spend, quality, markdownPrompt and alternatives (balanced and economy). Each alternative lists the per-reviewer changes, a comparison with currentUsdPerRound, and an estimate whose basis is repo_history when the repository has recent rounds.

The same step without MCP

Surface Form
CLI codepanel optimize owner/name --json (prints markdownPrompt too)
HTTP API No single route. It combines GET /spend, GET /quality and GET /authorship?repo=owner/name, which the client calls together

The dashboard's Spend & budget tab shows the same suggestions and lets a person preview, apply and undo a repository panel (Budgets and spending limits).

What the server tells your agent

The description your agent reads when it lists the tools:

Analyze a named repository's full-month spend, cost concentration, failed calls and verified quality alongside balanced and economy panel alternatives. Returns evidence-based suggestions, estimated cost differences and explicit repo-scoped apply/undo paths. Changes nothing, makes no LLM calls, and does not claim a source-code audit or guaranteed quality/savings. Use this from another repository's agent to inspect CodePanel's setup for that repo.

Last updated