agentcompass 0.1.2: sync AgentCompass v0.3.8 scoring (floors, origin, frontier headroom, curves, work-kind inference) (#749)
Syncs Mode A's scoring with AgentCompass v0.3.8 (akiiwa-games/AgentCompass, accounts.json and scripts/allocator.py): ability floors routine 2.3 / hard 3.1, `ability_score_origin` (graded from max(floor, origin)), `critical_headroom_by_difficulty` {frontier: 0.1}, the tool_execution route floor {hard: 2.7}, the 13 effort curves and `effort_ability`/`effort_burn`, and 54bb51e's work-kind inference (COMPUTER_USE_PHRASES, CODE_FILE_RE guard, "translation of", the code-file/debug skip). `extractRequestFacts().hasComputerUse` uses the same phrases and guard, so continuity's GUI `capability_outgrown` no longer fires on bare "gui", "desktop app", "keyboard", "桌面", "键盘". Version 0.1.2.
Reviewed at head 4ff38ce1d (previous review at 4de283991; the 4ff38ce diff drops the four screenshot phrases and adds tests 8.9 to 8.12).
Checked against upstream v0.3.8 (e30836e7) by script: all 13 curves in 8.12's table and `effort_ability`/`effort_burn` equal accounts.json; COMPUTER_USE_PHRASES equals allocator.py:1088 exactly.
Run at 4ff38ce1d on mote (macOS, Bun 1.4.2, Node 22.22.0): `bun test` 40 pass 0 fail; `node --test test/router.test.mjs` 40 pass; `bun scripts/check.mjs agentcompass` exit 0. PR CI (test, on-npm) green.
Broken by hand at 4ff38ce1d, one at a time, each red:
- origin = floor -> 8.9
- CODE_FILE_RE guard off in inferKindFromObjective -> 8.10
- bare "keyboard"/"mouse" in COMPUTER_USE_PHRASES -> 8.10, 8.11
- "translation of" -> "translation" -> 8.10
- namesCode out of the translation skip -> 8.10
- hasComputerUse without the guard, or on GUI_WORDS -> 8.10, 8.11
- "take a screenshot" or "截屏操作" put back -> 8.10
- opus xhigh ability, carbon medium burn, effort_ability.xhigh, effort_burn.max changed -> 8.12
- criticalHeadroom ignoring the table -> 8.7; abilityFloor ignoring the route -> 8.8
Not tried: real routing traffic through a live magpie gateway.
This commit is contained in:
@@ -184,13 +184,40 @@ export function fitScore(kind, model, catalog = {}, options = {}) {
|
||||
return Math.max(band.floor, round4(band.start - band.step * (place - 1)));
|
||||
}
|
||||
|
||||
/**
|
||||
* The minimum ability a route's work needs at a difficulty (`allocator.py:ability_floor`).
|
||||
*/
|
||||
export function abilityFloor(policy = DEFAULT_SCORING_POLICY, route = null, difficulty = "hard") {
|
||||
const own = route?.ability_floor || {};
|
||||
return difficulty in own ? Number(own[difficulty]) : Number(policy.ability_floor?.[difficulty] ?? 3.0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extra ability critical work needs above the difficulty's floor (`allocator.py:critical_headroom`).
|
||||
*/
|
||||
export function criticalHeadroom(policy = DEFAULT_SCORING_POLICY, difficulty = "hard") {
|
||||
const own = policy?.critical_headroom_by_difficulty || {};
|
||||
return difficulty in own ? Number(own[difficulty]) : Number(policy?.critical_headroom ?? 0.3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Continuous task ability demand (`allocator.py:task_demand`).
|
||||
*/
|
||||
export function taskDemand(profile, difficulty, critical, divergence, policy = DEFAULT_SCORING_POLICY, highPrecision = false) {
|
||||
export function taskDemand(
|
||||
profile,
|
||||
difficulty,
|
||||
critical,
|
||||
divergence,
|
||||
policy = DEFAULT_SCORING_POLICY,
|
||||
highPrecision = false,
|
||||
floorOverride = null,
|
||||
) {
|
||||
const cfg = policy.demand || DEFAULT_SCORING_POLICY.demand;
|
||||
const floor = Number(policy.ability_floor?.[difficulty] ?? 3.3);
|
||||
const headroom = critical ? Number(policy.critical_headroom ?? 0.3) : 0.0;
|
||||
const floor =
|
||||
floorOverride === null || floorOverride === undefined
|
||||
? Number(policy.ability_floor?.[difficulty] ?? 3.3)
|
||||
: Number(floorOverride);
|
||||
const headroom = critical ? criticalHeadroom(policy, difficulty) : 0.0;
|
||||
const precision = highPrecision && !critical ? Number(cfg.precision_headroom ?? 0.15) : 0.0;
|
||||
const span = Number(policy.profile?.saturation_span ?? 0.3);
|
||||
|
||||
@@ -389,15 +416,15 @@ export function evaluateCandidate(candidate, taskCtx, catalog = {}) {
|
||||
`context window ${info.context_window || 128000} outgrown by ${taskCtx.min_context_tokens} tokens`
|
||||
);
|
||||
}
|
||||
const routes = catalog.routes || CANONICAL_ROUTES;
|
||||
const route = routes[taskCtx.kind] || {};
|
||||
const ability = effortAbility(policy, curves, info, effort);
|
||||
const highAbility = effortAbility(policy, curves, info, "high");
|
||||
const demand = taskCtx.demand;
|
||||
const target = demand.required_ability;
|
||||
const floor = policy.ability_floor[taskCtx.difficulty] ?? 3.0;
|
||||
const gate = floor + (taskCtx.critical ? policy.critical_headroom : 0.0);
|
||||
|
||||
const routes = catalog.routes || CANONICAL_ROUTES;
|
||||
const route = routes[taskCtx.kind] || {};
|
||||
const floor = demand.floor ?? abilityFloor(policy, route, taskCtx.difficulty);
|
||||
const headroom = taskCtx.critical ? criticalHeadroom(policy, taskCtx.difficulty) : 0.0;
|
||||
const gate = floor + headroom;
|
||||
if (
|
||||
route.restrict_models &&
|
||||
taskCtx.specialist_available &&
|
||||
@@ -508,7 +535,8 @@ export function evaluateCandidate(candidate, taskCtx, catalog = {}) {
|
||||
span = Number(policy.profile?.saturation_span ?? 0.3);
|
||||
}
|
||||
|
||||
let abilityScore = clamp((credited - (taskCtx.high_precision ? gate : floor)) / span, 0, 1);
|
||||
const origin = Math.max(floor, Number(policy.ability_score_origin?.[taskCtx.difficulty] ?? floor));
|
||||
let abilityScore = clamp((credited - origin - (taskCtx.high_precision ? gate - floor : 0.0)) / span, 0, 1);
|
||||
const qualityBonus = taskCtx.high_precision
|
||||
? round4(Number(policy.high_precision_effort_weight ?? 0.14) * effortGain)
|
||||
: 0.0;
|
||||
@@ -683,7 +711,9 @@ export function rankCandidates(profileInput, options = {}) {
|
||||
(!critical || mechanicalRunbook)
|
||||
);
|
||||
|
||||
const demand = taskDemand(profile, difficulty, critical, div, policy, highPrecision);
|
||||
const routeObj = routes[kind] || {};
|
||||
const floor = abilityFloor(policy, routeObj, difficulty);
|
||||
const demand = taskDemand(profile, difficulty, critical, div, policy, highPrecision, floor);
|
||||
const requirements = profileRequirements(profile, policy);
|
||||
const sWeights = subjectiveWeights(profile, kind);
|
||||
|
||||
@@ -720,7 +750,6 @@ export function rankCandidates(profileInput, options = {}) {
|
||||
if (rawM) candidateCanonicals.add(canonicalModel(rawM, aliases));
|
||||
}
|
||||
const dotAvailable = candidateCanonicals.has("dot");
|
||||
const routeObj = routes[kind] || {};
|
||||
const specialistAvailable = Boolean(
|
||||
routeObj.restrict_models &&
|
||||
(routeObj.preferred || []).some((m) => candidateCanonicals.has(canonicalModel(m, aliases)))
|
||||
|
||||
Reference in New Issue
Block a user