Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix([issue-8149]): advise only pinnable tiers, from one learning snapshot

[._.]/ Adam Eivy090dcc7f5276
diff --git a/server/services/taskLearning.test.js b/server/services/taskLearning.test.js
index fcfa6be51b..08d989e418 100644
--- a/server/services/taskLearning.test.js
+++ b/server/services/taskLearning.test.js
@@ -835,6 +835,26 @@ describe('TaskLearning - getRoutingAccuracy', () => {
expect(byType['self-improve:ui'].suggestion.avoidTiers).toContain('light');
expect(byType['user-task'].suggestion).toBeUndefined();
});
+
+ it('advises only pinnable tiers: retired thinking-level names map to their tier, user-specified never appears', async () => {
+ const outcome = { completed: 15, succeeded: 12, failed: 3, totalDurationMs: 1500000, avgDurationMs: 100000, successRate: 80 };
+ const data = makeLearningData({
+ byTaskType: { 'legacy-high': outcome, 'pinned-only': outcome },
+ routingAccuracy: {
+ 'legacy-high': { high: { succeeded: 9, failed: 1, lastAttempt: '2026-01-26T00:00:00.000Z' } },
+ 'pinned-only': { 'user-specified': { succeeded: 9, failed: 1, lastAttempt: '2026-01-26T00:00:00.000Z' } }
+ }
+ });
+ readFile.mockResolvedValue(JSON.stringify(data));
+
+ const result = await getRoutingAccuracy();
+ const byType = Object.fromEntries(result.matrix.map((entry) => [entry.taskType, entry]));
+
+ expect(byType['legacy-high'].suggestion.tier).toBe('heavy');
+ expect(byType['pinned-only'].suggestion).toBeUndefined();
+ // History is kept verbatim — only the advice is normalized.
+ expect(byType['legacy-high'].tiers[0].tier).toBe('high');
+ });
});
describe('TaskLearning - suggestModelTier with routing signals', () => {
diff --git a/server/services/taskLearning/routing.js b/server/services/taskLearning/routing.js
index c73a3c5ffb..ca89dcfa9d 100644
--- a/server/services/taskLearning/routing.js
+++ b/server/services/taskLearning/routing.js
@@ -67,6 +67,20 @@ const NON_ROUTABLE_LEARNED_TIERS = new Set(['minimal', 'low', 'ultra']);
*/
export const isNonRoutableLearnedTier = (tier) => NON_ROUTABLE_LEARNED_TIERS.has(tier);
+/**
+ * A recorded tier name → the tier a user can actually pin today, or null.
+ * Learning data from before #8149 carries the retired thinking-level names;
+ * pinning one (`high`) would be read as a literal model id, so advice maps them
+ * onto the tier they resolved to (`off` → the provider default, `high`/`xhigh`
+ * → heavy). `user-specified` and the local-only levels name no pinnable tier,
+ * so they never appear as advice — their history stays in the matrix.
+ */
+const ADVISORY_TIERS = Object.freeze({
+ light: 'light', medium: 'medium', heavy: 'heavy', ultra: 'ultra', default: 'default',
+ off: 'default', high: 'heavy', xhigh: 'heavy',
+});
+const advisoryTier = (tier) => (Object.hasOwn(ADVISORY_TIERS, tier) ? ADVISORY_TIERS[tier] : null);
+
/** Minimum success rate (%) for a tier to count as "proven" for a task type. */
const HIGH_SUCCESS_THRESHOLD = 80;
@@ -264,10 +278,15 @@ export async function getTaskTypePriorityMultiplier(taskType) {
export async function suggestModelTier(taskType) {
// Sandboxed fallback (issue #2333): the `external/untyped` bucket aggregates
// heterogeneous work, so its tier success rates are meaningless — never let it
- // drive a model-tier suggestion. Let the selector fall through to its default.
+ // drive a model-tier suggestion.
if (isSandboxedTaskType(taskType)) return null;
+ return suggestModelTierFrom(await loadLearningData(), taskType);
+}
- const data = await loadLearningData();
+// `suggestModelTier` over an already-loaded snapshot, so a caller walking every
+// task type (getRoutingAccuracy) loads — and clones — the store once, not per row.
+function suggestModelTierFrom(data, taskType) {
+ if (isSandboxedTaskType(taskType)) return null;
// Auto-adjustment aggressiveness gate (issue #2344): the enriched failure
// signal steers routing more aggressively only once the correlation-quality
@@ -484,13 +503,14 @@ export async function getRoutingAccuracy() {
// Advice, not routing: the tier each task type's history recommends, for the
// user to pin on the task or schedule if they agree.
- await Promise.all(matrix.map(async (entry) => {
- const suggestion = await suggestModelTier(entry.taskType).catch(() => null);
- const avoidTiers = suggestion?.avoidTiers || [];
- if (suggestion?.suggested || avoidTiers.length > 0) {
- entry.suggestion = { tier: suggestion.suggested || null, avoidTiers, reason: suggestion.reason || null };
+ for (const entry of matrix) {
+ const suggestion = suggestModelTierFrom(data, entry.taskType);
+ const tier = advisoryTier(suggestion?.suggested);
+ const avoidTiers = [...new Set((suggestion?.avoidTiers || []).map(advisoryTier).filter(Boolean))];
+ if (tier || avoidTiers.length > 0) {
+ entry.suggestion = { tier, avoidTiers, reason: suggestion.reason || null };
}
- }));
+ }
return { matrix, tierOverview, misroutes, totalMisroutes: misroutes.length };
}