From 65ae295e0a835b60ee4771ee3306369fc0d195c7 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Fri, 30 Oct 2026 09:08:41 -0500 Subject: [PATCH] fix(muse-proxy): resolve contributor model ids in direct mode (#2753) --- bin/muse-proxy.mjs | 20 ++++++++++++++++++-- bin/muse-proxy.test.mjs | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/bin/muse-proxy.mjs b/bin/muse-proxy.mjs index 4f6cc1bd1..dc8b56b7e 100644 --- a/bin/muse-proxy.mjs +++ b/bin/muse-proxy.mjs @@ -88,6 +88,21 @@ const resolveModelAndEffort = (requestedModel, requestedEffort) => { } } + // Contributor variants (#2753 amendment): the Meta pool's contributor + // models are distinct upstream ids (muse-spark-1.3-contributor, + // muse-wonder-1.0-contributor), optionally carrying an effort suffix + // AFTER the contributor part (muse-wonder-1.0-contributor-high — the + // effort suffix was already stripped above). Peel the contributor part + // off for the base-model lookup and re-attach it to the resolved ids, + // so the direct path sends the contributor id upstream verbatim. A + // plain base-model request keeps the plain id — contributor is the + // caller's choice, never a proxy rewrite. + let contributor = false; + if (modelStr.endsWith('-contributor')) { + contributor = true; + modelStr = modelStr.slice(0, -'-contributor'.length); + } + // Bare aliases if (modelStr === 'spark' || modelStr === 'muse-spark') modelStr = 'muse-spark-1.3'; if (modelStr === 'wonder' || modelStr === 'muse-wonder') modelStr = 'muse-wonder-1.0'; @@ -101,10 +116,11 @@ const resolveModelAndEffort = (requestedModel, requestedEffort) => { effort = modelConfig.defaultEffort; } + const baseModel = contributor ? `${modelConfig.id}-contributor` : modelConfig.id; return { - baseModel: modelConfig.id, + baseModel, effort, - fullName: `${modelConfig.id}-${effort}` + fullName: `${baseModel}-${effort}` }; }; diff --git a/bin/muse-proxy.test.mjs b/bin/muse-proxy.test.mjs index f4e240499..583cb13d4 100644 --- a/bin/muse-proxy.test.mjs +++ b/bin/muse-proxy.test.mjs @@ -756,3 +756,37 @@ test('direct mode: missing auth.json leaves the exec path in charge (#2753)', as assert.equal(health.direct.credentialFound, false); assert.equal(health.direct.mintedKeyCached, false); }); + +test('direct mode: contributor ids reach upstream verbatim, effort suffix parses after contributor (#2753)', async (t) => { + const meta = await startMetaStub('chat'); + t.after(() => meta.close()); + const { port, stop, home } = await startProxy({ MUSE_PROXY_META_API_BASE: meta.url }); + t.after(stop); + writeStubAuth(home); + + const wonder = JSON.parse(await chat(port, { + model: 'muse-wonder-1.0-contributor-high', + messages: [{ role: 'user', content: 'hi' }] + })); + assert.equal(wonder.model, 'muse-wonder-1.0-contributor-high'); + + const spark = JSON.parse(await chat(port, { + model: 'muse-spark-1.3-contributor', + messages: [{ role: 'user', content: 'hi' }] + })); + assert.equal(spark.model, 'muse-spark-1.3-contributor-high', 'no explicit effort means the default effort, contributor intact'); + + const plainBase = JSON.parse(await chat(port, { + model: 'muse-spark-1.3', + messages: [{ role: 'user', content: 'hi' }] + })); + assert.equal(plainBase.model, 'muse-spark-1.3-high', 'a plain request is NOT rewritten to contributor'); + + const sent = meta.requests.filter(r => r.url === '/v1/responses').map(r => JSON.parse(r.body)); + assert.equal(sent.length, 3); + assert.equal(sent[0].model, 'muse-wonder-1.0-contributor', 'contributor id goes upstream verbatim'); + assert.deepEqual(sent[0].reasoning, { effort: 'high' }, 'the effort suffix after -contributor is the effort'); + assert.equal(sent[1].model, 'muse-spark-1.3-contributor'); + assert.deepEqual(sent[1].reasoning, { effort: 'high' }); + assert.equal(sent[2].model, 'muse-spark-1.3', 'plain base model stays plain upstream'); +});