agentcompass 0.1.3: :minimal and :ultra are efforts; ultra reads as the model's Max, minimal sits below its Low (#750)

agentcompass 0.1.3. `:minimal` and `:ultra` are read as efforts. `ultra` maps to the model's Max, or to the policy table's max when the model has no curve. `minimal` sits below the model's Low, and is clamped by a step floor and the burn scale. `none`/`off` stay in the policy. Quota is scaled through `burnScale` rather than the raw tables. A model with no curve (glm-5.3) uses the policy table's Low. A request that nothing routes now falls back through `fallbackToBestExcluded`, in both the middleware and the hooks. The fallback's tiers are: below the floor only, then seeing models, then the rest. The README (en/zh) notes that the fallback can override the visual, unhealthy, context and quota constraints.

Reviewed head: ff614f0316ab5b1a07bcc68afd11b69bb6e892d3 (merge-base 42331f64 = origin/main).

Run on mote (mote-run, HOME=$(mktemp -d)):
- packages/agentcompass `node --test`: 44 pass. `bun test`: 44 pass.
- repo `bun test`: 6188 pass, 20 skip, 0 fail. `bun scripts/check.mjs`: exit 0.
- PR CI (test, on-npm): green on ff614f0.

Broken by hand. All 16 went red:
- A-H turned 9.13 red: ability-only fallback, no floor-only tier, no seeing tier, onlyBelowFloor from the floor alone, tier order flipped, no fallback in middleware, no fallback in hooks, old middleware retry condition.
- I (quota from the raw tables) and J (below-Low scaling from the model's own Low) turned 9.12 red.
- K (no ultra to own max) turned 9.10 and 9.12 red.
- L (no ultra to policy max) turned 9.11 and 9.12 red.
- M (no step floor) and N (no burn clamp) turned 9.11 red.
- O (old EFFORT_ORDER) turned 9.10, 9.11 and 9.13 red.
- P (none/off out of the policy) turned 8.12, 9.11 and 9.13 red.

Version 0.1.2 to 0.1.3 sits on main's 0.1.2 and on dist's latest (tgz 0.1.2). The package is not on npm, so it ships through the dist branch.
Not tried: a real magpie gateway routing through 0.1.3.
This commit is contained in:
Akiiwa
2026-11-06 07:19:21 +08:00
committed by GitHub
parent 42331f64d8
commit 10a61c2efa
8 changed files with 291 additions and 32 deletions
+29 -20
View File
@@ -25,7 +25,10 @@ import {
resolveModelSpec,
} from "./catalog.js";
import { inferTaskProfile, validateProfile } from "./profiler-core.js";
import { evaluateModelQuota, normalizeQuotaSnapshot } from "./quota.js";
// effortValue and burnScale live in quota.js so its opportunity cost reads the same burn scale as the allocator.
import { burnScale, effortValue, evaluateModelQuota, normalizeQuotaSnapshot } from "./quota.js";
export { burnScale, effortValue };
export const EFFORT_SCALED_CAPABILITIES = [
"reasoning",
@@ -74,13 +77,6 @@ export function profileKind(profile, policy = DEFAULT_SCORING_POLICY) {
return policy?.profile?.kind_by_style?.[profile.interaction_style] || "other_or_mixed";
}
export function effortValue(policy, curves, name, effort, fallback) {
const own = curves?.[name] || {};
if (effort in own) return own[effort];
const policyTable = policy?.[`effort_${name}`] || {};
return effort in policyTable ? policyTable[effort] : fallback;
}
/**
* The model's effective tier at one effort level (`allocator.py:effort_ability`).
*/
@@ -93,16 +89,6 @@ export function effortAbility(policy, curves, info, effort = "high") {
return tier + effortValue(policy, curves, "ability", effort, 0);
}
/**
* Relative burn scale of `effort` compared to `high` (`allocator.py:burn_scale`).
*/
export function burnScale(policy, curves, effort = "high") {
const mult = curves?.burn_mult || {};
if (effort in mult) return Number(mult[effort]);
const ref = effortValue(policy, curves, "burn", "high", 0.7);
return effortValue(policy, curves, "burn", effort, ref) / (ref || 1.0);
}
export function capabilityVector(info) {
const raw = info?.capabilities || {};
const legacyVisual = typeof info?.visual === "number" ? info.visual : 0.0;
@@ -402,7 +388,8 @@ export function evaluateCandidate(candidate, taskCtx, catalog = {}) {
const curves = curvesTable[canonical] || {};
const excluded = [];
if (taskCtx.needs_visual && !info.visual) {
const cannotSeeInput = Boolean(taskCtx.needs_visual && !info.visual);
if (cannotSeeInput) {
excluded.push("task needs visual input");
}
if (taskCtx.unhealthy_models && taskCtx.unhealthy_models.has(canonical)) {
@@ -627,6 +614,8 @@ export function evaluateCandidate(candidate, taskCtx, catalog = {}) {
fast: Boolean(quotaEval?.fast),
excluded,
eligible: excluded.length === 0,
cannotSeeInput,
onlyBelowFloor: excluded.length === 1 && ability < gate,
score: excluded.length === 0 ? totalScore : null,
quota: quotaEval
? {
@@ -830,14 +819,34 @@ export function rankCandidates(profileInput, options = {}) {
};
}
function fallbackTier(candidate) {
if (candidate.onlyBelowFloor) return 0;
return candidate.cannotSeeInput ? 2 : 1;
}
/**
* Convenience entry point: takes a raw request or task object + options and returns the winning route decision.
*
* `fallbackToBestExcluded` is for gateways. AgentCompass may leave a task unrouted when no candidate clears its
* floor, but a gateway that does so forwards the virtual model name upstream and the request fails. With the
* option, an excluded candidate is chosen instead and the decision carries `fallback`: one that only misses the
* floor, else one that can see the request's images, with ability breaking ties. Falling short of a floor still
* answers the request; a model that can't see its images can't.
*/
export function selectBestRoute(taskOrProfile, options = {}) {
const result = rankCandidates(taskOrProfile, options);
const top = result.selected;
let top = result.selected;
let fallback = null;
if (!top && options.fallbackToBestExcluded && result.allCandidates.length > 0) {
top = result.allCandidates.reduce((best, c) => {
const tier = fallbackTier(c) - fallbackTier(best);
return tier < 0 || (tier === 0 && c.components.ability_value > best.components.ability_value) ? c : best;
});
fallback = { excluded: top.excluded };
}
return {
ok: Boolean(top),
fallback,
targetModel: top ? top.model : null,
canonicalModel: top ? top.canonicalModel : null,
targetEffort: top ? top.effort : "high",