Skip to main content
Glama

tune_model

Scores a model with cross-validation and searches its hyperparameters when Optuna is available and budget remains, returning scores and parameters.

Instructions

Score one model by cross-validation, then search its hyperparameters if Optuna is installed and budget remains. Without Optuna, only the baseline is scored. Returns scores and parameters. Use automl_run to search across model families.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "name": "<name>",
      "target_column": "<target_column>",
      "task_type": "<task_type>",
      "model_name": "<model_name>"
    },
    "name": "tune_model"
  }
}

Input Schema

NameRequiredDescriptionDefault
cvNoCross-validation folds (default 3).
nameYesDataset filename.
metricNoSelection metric. auto (default) uses roc_auc for binary classification, f1 for multiclass classification or r2 for regression. Loss metrics rank lowest first.
delimiterNoCSV delimiter character: comma (,), semicolon (;), tab (\t) or pipe (|). Omit to detect it automatically.
task_typeYes'classification' or 'regression'.
max_trialsNoTotal trials including the baseline, 1–50 (default 20).
model_nameYesModel to tune.
random_stateNoRandom seed (default 42).
target_columnYesTarget variable column.
exclude_columnsNoFeature columns to exclude before preprocessing/training.
max_time_secondsNoShared candidate and tuning time budget in seconds (default 600). A trial already in progress may finish after the deadline.
split_manifest_idNoID of a validated split manifest to enforce indices.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changedv0.3.4
    • changedInput schema / properties / delimiter / description
      Previous value: -"CSV delimiter (comma, semicolon, tab, pipe). Auto."New value: +"CSV delimiter character: comma (,), semicolon (;), tab (\\t) or pipe (|). Omit to detect it automatically."
    • changedInput schema / properties / max_time_seconds / description
      Previous value: -"Max wall-clock seconds (default 600)."New value: +"Shared candidate and tuning time budget in seconds (default 600). A trial already in progress may finish after the deadline."
    • changedInput schema / properties / max_trials / description
      Previous value: -"Max tuning trials (default 20)."New value: +"Total trials including the baseline, 1–50 (default 20)."
    • changedInput schema / properties / metric / description
      Previous value: -"Selection metric (default auto)."New value: +"Selection metric. auto (default) uses roc_auc for binary classification, f1 for multiclass classification or r2 for regression. Loss metrics rank lowest first."
  2. Changed3 schema fields changed
    • addedInput schema / properties / delimiter
      Added value: +{
      +  "description": "CSV delimiter (comma, semicolon, tab, pipe). Auto.",
      +  "type": "string"
      +}
    • addedInput schema / properties / exclude_columns
      Added value: +{
      +  "description": "Feature columns to exclude before preprocessing/training.",
      +  "items": {
      +    "type": "string"
      +  },
      +  "type": "array"
      +}
    • addedInput schema / properties / split_manifest_id
      Added value: +{
      +  "description": "ID of a validated split manifest to enforce indices.",
      +  "type": "string"
      +}
  3. Added

TDQS

A3.9/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full behavioral burden. It usefully discloses the Optuna dependency and fallback to baseline-only scoring, plus that it returns scores and parameters, but it does not explain whether a model artifact is persisted, whether the run is interruptible, or what the returned structures contain.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded, uses four tight sentences, and contains no filler. It moves from core behavior to fallback behavior to return summary to alternative tool in a logical order.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 12-parameter tool with no output schema and no annotations, the description is somewhat thin on output shape and side effects. It mentions returns in general terms but does not describe what scores and parameters include or whether the tuned model is saved for later use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the schema already documents all 12 parameters in detail. The description adds context about the baseline-versus-tuning flow and budget condition, but does not add parameter-level meaning beyond what the schema provides.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific two-stage action: cross-validate one model, then optionally search its hyperparameters. It also clearly distinguishes this from automl_run, which searches across model families.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It gives a clear condition for when hyperparameter search occurs and explicitly points to automl_run as the alternative for cross-family search. It does not clarify when to prefer this over train_baseline or compare_models, but the core usage is clear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.