Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

Merge remote-tracking branch 'pr/390'

Duarte Santos7ce0ce370fc8
diff --cc api/coach/core/adapters/http.js
index 511a6a6c2,ad96fbd2a..3517d3514
--- a/api/coach/core/adapters/http.js
+++ b/api/coach/core/adapters/http.js
@@@ -135,9 -125,9 +135,9 @@@ export function httpAdapter(spec)
const key = keyOf(env);
if (!key && !meta.keyOptional) return { code: -1, text: '', stderr: `no API key configured for ${id}`, spawnError: true };
const chosen = model || meta.defaultModel;
- if (!chosen) return { code: 1, text: '', stderr: `no model chosen for ${id} — pick one from the list the endpoint serves` };
+ if (!chosen) return { code: 1, text: '', stderr: `no model chosen for ${id} (pick one from the list the endpoint serves)` };
- let body = spec.body({ model: chosen, prompt, system: system || null, schema: schema || null, maxTokens: MAX_OUTPUT_TOKENS });
+ let body = spec.body({ model: chosen, prompt, system: system || null, schema: schema || null, maxTokens });
let retriedWithoutJsonMode = false;
let transientRetries = 0;
for (;;) {
diff --cc api/test/routes.test.js
index 831512dfe,308c40394..6b28b45fc
--- a/api/test/routes.test.js
+++ b/api/test/routes.test.js
@@@ -235,22 -235,22 +235,42 @@@ test('an admin can raise the Coach mess
assert.equal(status.body.maxMessageLen, 1800);
});
+// The guard in front of every user route answers 503 while the Coach is switched off or has no
+// provider connected. It sent the words with no class, so the app could not pick its own,
+// translated line for it and a German lifter read "the Coach is not set up on this instance". It
+// names the class now: 'off', the class enqueue's own refusal carries for the same state.
+test('the Coach-off guard names its class beside the words, on every guarded user route', async () => {
+ const guarded = ['GET /api/coach/status', 'POST /api/coach/plan', 'POST /api/coach/review', 'POST /api/coach/debrief',
+ 'GET /api/coach/cohort', 'POST /api/coach/cohort/share', 'POST /api/coach/pending/resolve'];
+ const refusal = { error: 'the Coach is not set up on this instance', code: 'off' };
+ const { call } = harness();
+ for (const [state, patch] of [['switched off', { enabled: false }], ['no provider connected', { provider: 'anthropic' }]]) {
+ fresh(patch);
+ assert.equal(cfg.isConnected(), false, state);
+ for (const key of guarded) {
+ const r = await call(key, {});
+ assert.equal(r.status, 503, `${state}: ${key}`);
+ assert.deepEqual(r.body, refusal, `${state}: ${key}`);
+ }
+ }
+});
++
+ /* ---------- configurable max output tokens (reasoning models) ---------- */
+ test('an admin can raise the Coach output cap for a reasoning model, clamped to a sane range', async () => {
+ fresh();
+ const { call } = harness();
+
+ // The old hard-coded constant, for an instance that has never touched the setting.
+ assert.equal((await call('GET /api/admin/coach')).body.maxOutputTokens, 16000);
+
+ const set = await call('POST /api/admin/coach/config', { maxOutputTokens: 48000 });
+ assert.equal(set.status, 200);
+ assert.equal((await call('GET /api/admin/coach')).body.maxOutputTokens, 48000);
+ assert.equal(cfg.load().maxOutputTokens, 48000, 'persists with the rest of the Coach config');
+
+ // Clamped, not trusted outright — a reasoning model needs more than 16000, but not a million.
+ await call('POST /api/admin/coach/config', { maxOutputTokens: 999999 });
+ assert.equal((await call('GET /api/admin/coach')).body.maxOutputTokens, 65536, 'ceiling');
+ await call('POST /api/admin/coach/config', { maxOutputTokens: 1 });
+ assert.equal((await call('GET /api/admin/coach')).body.maxOutputTokens, 1024, 'floor');
+ });