Spaces:
Paused

File size: 1,201 Bytes
bc9f3e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/**
 * Display-only mirror of backend/model_registry.py::get_max_steps_for_model.
 *
 * The chat tabs' "auto" step-budget controls (Max Steps / Search Steps /
 * Worker Steps) resolve to a MODEL-SCALED default: a ≥10B / ≥20B model pays
 * a much higher per-step cost when a tool-calling loop goes wrong, so its
 * budget is capped to fail fast. The BASE defaults come from /api/meta
 * (autoDefaults.stepBudgets — the Python *_DEFAULT_MAX_STEPS constants, the
 * single source of truth); this helper applies the SAME size-scaling rule
 * the agent builders apply, so the placeholder in an empty field shows the
 * real number the run will use. It must be computed against the LIVE picker
 * label (the backend can't know a model the user switched to mid-session).
 *
 * KEEP IN SYNC with backend/model_registry.py::get_max_steps_for_model
 * (and its estimate_model_param_billions regex).
 */
export function scaledMaxSteps(modelId, base) {
  if (!modelId) return base;
  const m = /(\d+(?:\.\d+)?)\s*[bB](?![a-zA-Z])/.exec(modelId);
  if (!m) return base;
  const size = parseFloat(m[1]);
  if (size >= 20) return Math.min(base, 4);
  if (size >= 10) return Math.min(base, 5);
  return base;
}