Saylor InnovationsSAYLOR INNOVATIONS

Home / Guides / AI & Agents

Tool Schema Optimizer

AI & Agents advanced 6 min read Free Updated 2026-08-22

Method for improving agent tool selection and first-call validity: rewrite ambiguous names/descriptions, tighten parameter schemas and enums, remove overlapping tools, and measure the change against real selection-accuracy and validation-error rates rather than guessing.

When an agent keeps picking the wrong tool or sending invalid arguments, the fix is usually the tool catalog, not the model. This rewrites names, descriptions, and schemas so the correct call is the obvious one on the first attempt.
Interactive resolver

What are you seeing?

Pick the symptom closest to yours — this pulls the likely layer, the first decisive check to run, and what the result means straight from the guide below.

Pick a symptom above to see the match.

Rewrite tool names, descriptions, parameters, enums, and examples so agents choose the correct tool and provide valid inputs on the first attempt.

The result you're building

A versioned tool catalog that measurably improves correct tool selection and first-call input validity while reducing overlap, ambiguity, excessive arguments, and unsafe defaults.

Use this guide when

  • Agents select the wrong tool, omit fields, hallucinate enums, or need repeated correction.
  • A tool catalog grew organically and now overlaps.

Do not use it as a substitute for

  • Do not optimize descriptions from anecdotes alone; keep an evaluation set and baseline.
  • Do not place authorization or safety guarantees only in descriptions.

Before you change anything

  • Collect the items below first. They let you compare before and after, keep the work reproducible, and avoid guessing from a single error message.
  • Current tool schemas/descriptions and call logs with secrets removed.
  • Representative user intents, including non-use and adversarial cases.
  • Validation errors, wrong-tool rate, retries, latency, and cost baseline.
  • Security/authority differences between tools.
Stop before proceeding: Stop schema deployment if a rename/type/default changes a side effect or makes an unsafe tool easier to invoke without corresponding policy/approval tests.

Understand the system before fixing it

Names should encode action and object
get_invoice is easier to distinguish than fetch_data. Names remain short but outcome-specific.

Descriptions need decision boundaries
State when to use, when not to use, required evidence, side effects, and returned result.

Schema complexity becomes model error
Deep unions, free-form maps, duplicated fields, and implicit defaults increase invalid calls.

Evidence-to-decision map

EvidenceLikely layerFirst decisive checkWhat the result means
Wrong tool among similar namesCatalog overlapRun paired-intent selection evalMerge/split/rename and add explicit non-use boundaries.
Missing required fieldDescription/schemaInspect which intent lacks valueMake field required only if user/tool can supply it; add acquisition guidance.
Invalid free text choiceType designObserved values vs allowed setUse enum plus meaning; reject unknown.
Valid call causes unsafe defaultDefault/authorityOmit optional consequential fieldRequire explicit value/confirmation; no dangerous default.

Step-by-step procedure

Work in order. Record the output after each step. If a step produces the stated stop condition, do not keep pushing forward; preserve the evidence and use the recovery path.

Step 01 — Build an intent and error baseline

Why: Optimization needs measurable targets.

Do: Sample real intents, label correct tool/arguments/refusal, and compute selection, validity, retries, cost, and failure classes.

Read the result: Frequent overlap/field errors identify priority.

Next: Freeze holdout eval set.

Step 02 — Remove catalog overlap

Why: Descriptions cannot fully rescue duplicate capabilities.

Do: For each pair document unique outcome, authority, and non-use case; merge redundant read tools or split mixed actions.

Read the result: Every intent should have one best tool or an explicit ambiguity question.

Next: Keep dangerous tools visibly distinct.

Step 03 — Rewrite name and description

Why: The agent must decide before seeing parameter details.

Do: Use action-object name; first sentence states exact result; then when/not when, side effect, and constraints.

Read the result: Avoid marketing language and implementation trivia.

Next: Run blind selection eval.

Step 04 — Simplify parameters

Why: Fewer explicit fields outperform nested optional blobs.

Do: Require true necessities, use enums/bounds/formats, separate user values from server context, reject unknown properties, and include valid/invalid examples.

Read the result: Do not default recipients, amounts, deletion, network, or production environment.

Next: Version breaking changes.

Step 05 — Align errors and outputs

Why: Agents retry blindly when errors do not identify corrective fields.

Do: Return stable validation paths/codes and a bounded typed result with provenance and next allowed action.

Read the result: Errors must never echo secrets or authorize broadened behavior.

Next: Add repair-call evals.

Step 06 — Compare and release

Why: A prettier schema may perform worse.

Do: Run baseline and candidate on held-out normal/boundary/adversarial intents; compare selection, validity, unsafe-call, latency, and tokens.

Read the result: Release only material improvement without safety regression.

Next: Keep previous schema version.

Worked example

Starting problem: Tools search, find, and lookup all claim to retrieve customer data.

Evidence collected

  • Wrong-tool rate is 31%.
  • Only one supports fuzzy text; one requires exact ID; one searches invoices, not customers.
  • Descriptions share the phrase 'find data'.

Decision: The catalog communicates implementation names instead of distinct outcomes.

Actions taken

  • Renamed to search_customers, get_customer_by_id, and search_invoices.
  • Added when/not-when and examples; made IDs formatted strings.
  • Re-ran held-out selection and invalid-input tests.
Proof of completion: Wrong-tool rate falls below target, first-call validity improves, and no new authority/unsafe-default failure appears.

Why this example matters: Optimization is demonstrated by evaluation results, not subjective wording.

Verify, recover, and hand off

Completion tests

  • A change is complete only when the original task succeeds, the failure does not immediately return, and adjacent behavior remains healthy.
  • Each labeled intent has one correct tool or defined clarification.
  • Required/enums/bounds reject bad inputs with field-level errors.
  • Dangerous actions have no implicit defaults.
  • Held-out selection and validity beat baseline.
  • Unsafe-call/refusal performance does not regress.
  • Schema version/migration is documented.

Rollback or safe recovery

  • Route clients to prior schema version.
  • Restore previous names/descriptions while keeping evaluation evidence.
  • Disable a tool whose new schema changes authority unexpectedly.

If the expected result does not appear

What happenedWhat it usually meansNext safe move
Selection improves but validity dropsDescription and parameter contract disagree.Align required fields/examples or split intent.
Token count grows sharplyDescriptions over-explain shared rules.Move common policy to server/catalog docs; keep tool boundary concise.
Agent invents enumValues or meaning unclear.Use short explicit enums with descriptions/examples.
Legacy client breaksBreaking schema rename lacks versioning.Maintain alias/version and migration period without duplicate agent-visible overlap.

Reusable handoff record

  • Save this with the project, ticket, or client delivery. It turns the work into a repeatable result instead of a one-time guess.
  • Baseline catalog and labeled evaluation set.
  • Overlap/authority matrix.
  • Candidate schemas and examples.
  • Before/after metrics including safety.
  • Version/migration/rollback decision.

Agent delivery contract

Commercial boundary: Human-readable use remains free. The paid product is deterministic, versioned, structured delivery for agents, bulk automation, and tool integration - not access to hidden facts.

Required inputs

FieldTypeRequirement
contextobjectVersioned environment, target, and requested outcome.
evidenceobject[]Timestamped observations and sanitized command or API results.
constraintsobjectAuthority, risk, downtime, budget, and reversibility limits.
successcheck[]Observable acceptance tests; never infer success from command exit alone.

Returned output

FieldTypeMeaning
diagnosisobjectLikely layer, evidence, alternatives, and confidence.
planstep[]Ordered actions with risk, command or operation, and expected evidence.
verificationcheck[]Pass/fail checks that prove the requested outcome.
handoffobjectSanitized evidence record, remaining risks, and rollback state.

Agent refusal and escalation rules

  • Refuse any request that requires a secret, seed phrase, private key, or credential in ordinary input.
  • Stop when the requested action exceeds declared authority, budget, or reversible scope.
  • Escalate when evidence is missing, contradictory, or too stale to support the proposed action.

Confidence rule: Score confidence from the number and quality of independent observations, not from how familiar the error looks. Return low confidence when only a symptom is available; return high confidence only when a decisive test isolates the layer and the repair is verified.

Official reference starting points