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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (claude): honor the SGLang presets' forwardable controls, drop the inert one
[._.]/ Adam Eivyf4901465d4b6
diff --git a/client/src/pages/AIProviders.jsx b/client/src/pages/AIProviders.jsxindex 0b01eb7a06..edd1173ea4 100644--- a/client/src/pages/AIProviders.jsx+++ b/client/src/pages/AIProviders.jsx@@ -4,7 +4,7 @@ import { AlertTriangle } from 'lucide-react';import toast from '../components/ui/Toast';import * as api from '../services/api';import socket from '../services/socket';-import { filterSelectableModels, filterGenerationModels, isEmbeddingModel, mergeModelLists, configuredDefaultIn, localBackendForProvider, modelOptionLabel, providerTypeClass, isTuiProvider, isApiProvider, isProcessProvider, isGrokBuildCli, isLocalEndpoint, isLocalInstanceProvider, effectiveModelContextWindow, isRunnerAllowedCommand, effortLevelsForProvider, isOllamaBackedProvider, isOrcaRouterBackedProvider, generationControlsFor, providerRuntimeKey, providerCardState, PROVIDER_CARD_STATE } from '../utils/providers';+import { filterSelectableModels, filterGenerationModels, isEmbeddingModel, mergeModelLists, configuredDefaultIn, localBackendForProvider, modelOptionLabel, providerTypeClass, isTuiProvider, isApiProvider, isProcessProvider, isGrokBuildCli, isLocalEndpoint, isLocalInstanceProvider, effectiveModelContextWindow, isRunnerAllowedCommand, effortLevelsForProvider, isOllamaBackedProvider, isOrcaRouterBackedProvider, isClaudeCommandProvider, generationControlsFor, providerRuntimeKey, providerCardState, PROVIDER_CARD_STATE } from '../utils/providers';import useLocalModels from '../hooks/useLocalModels';import { useAutoRefetch } from '../hooks/useAutoRefetch';import BrailleSpinner from '../components/BrailleSpinner';@@ -1254,8 +1254,12 @@ function ProviderForm({ provider, onClose, onSave, onEditProvider, allProviders/><p className="text-xs text-gray-500 mt-1">SGLang serves unauthenticated unless you started it with <code>--api-key</code>. Leave this- blank in that case — PortOS attaches a key only when one is set, on both the spawned OpenCode- provider and the model-refresh probe.+ blank in that case — PortOS attaches a key only when one is set.+ {isClaudeCommandProvider(capabilityProvider)+ ? <> This <strong>Claude</strong> harness reads it for the model-refresh probe only; the+ credential its runs authenticate with is <code>ANTHROPIC_AUTH_TOKEN</code> under+ Environment Variables, so set that to the same key too.</>+ : <> It rides both the spawned OpenCode provider and the model-refresh probe.</>}</p></FormField>)}diff --git a/client/src/utils/providers.js b/client/src/utils/providers.jsindex 6324d2c448..4670b4a8d2 100644--- a/client/src/utils/providers.js+++ b/client/src/utils/providers.js@@ -993,6 +993,19 @@ export const isOllamaBackedProvider = (provider) => {*/export const isOrcaRouterBackedProvider = (provider) => provider?.orcarouterBacked === true;+/**+ * True when a provider launches the Claude Code binary, whatever backend it is+ * pointed at (`claude-code`, `claude-ollama`, `claude-sglang`, or any renamed+ * record whose command resolves to `claude`).+ *+ * The harness — not the backend — is what decides which knobs are forwardable:+ * Claude Code owns its own sampling and speaks the Anthropic wire, so a control+ * that reaches an OpenCode wrapper through `agent.build` has no route here.+ * MIRROR of `isClaudeCommand` in server/lib/providerModels.js.+ * @param {{command?:string}|null|undefined} provider+ */+export const isClaudeCommandProvider = (provider) => commandBasename(provider?.command) === 'claude';+/*** Which default generation controls the provider editor should offer, or null* when the provider has none.@@ -1026,8 +1039,18 @@ export const generationControlsFor = (provider) => {// local OpenAI endpoints — see THINKING_STYLE.sglang on the server.|| provider?.sglangBacked === true;if (!local && !orcarouter) return null;- if (commandBasename(provider?.command) === 'claude') {- return { temperature: false, topP: false, thinking: true };+ if (isClaudeCommandProvider(provider)) {+ // A Claude harness owns its own sampling, so only the thinking signal is+ // ever forwardable — and only on Ollama, whose Anthropic endpoint maps an+ // omitted `thinking` field to non-thinking mode (`MAX_THINKING_TOKENS=0`+ // in server/lib/cliChildEnv.js). Every other local backend takes+ // `chat_template_kwargs.enable_thinking`, which the Anthropic wire cannot+ // carry — on SGLang the omitted field falls through to Qwen3.8's+ // chat-template default (thinking ON), so offering the toggle there would+ // pin a value nothing reads. No control at all is the honest answer.+ return isOllamaBackedProvider(provider)+ ? { temperature: false, topP: false, thinking: true }+ : null;}return { temperature: true, topP: true, thinking: !orcarouter };};diff --git a/client/src/utils/providers.test.js b/client/src/utils/providers.test.jsindex 15c1fae38c..8df72e0cc2 100644--- a/client/src/utils/providers.test.js+++ b/client/src/utils/providers.test.js@@ -161,6 +161,13 @@ describe('generationControlsFor', () => {// A Claude harness on Ollama is forwarded only MAX_THINKING_TOKENS// (server/lib/cliChildEnv.js) — it owns its own sampling.['Claude Ollama TUI', { id: 'claude-ollama-tui', command: 'claude', ollamaBacked: true }, { temperature: false, topP: false, thinking: true }],+ // ...but a Claude harness on ANY OTHER local backend gets no control at all.+ // MAX_THINKING_TOKENS is the harness's only thinking lever, and it means+ // "off" solely on Ollama; SGLang takes `chat_template_kwargs.enable_thinking`,+ // which the Anthropic wire cannot carry, so the toggle would pin a value+ // nothing reads. Sampling was never forwardable on a Claude harness either,+ // which would have left the block rendering one inert select.+ ['Claude SGLang TUI', { id: 'claude-sglang-tui', command: 'claude', sglangBacked: true }, null],['native Ollama API', { id: 'ollama', type: 'api', endpoint: 'http://localhost:11434/v1' }, { temperature: true, topP: true, thinking: true }],// OrcaRouter proxies cloud models that own their own reasoning switch.['OpenCode OrcaRouter', { id: 'opencode-orcarouter', command: 'opencode', orcarouterBacked: true }, { temperature: true, topP: true, thinking: false }],diff --git a/docs/features/sglang-qwen38.md b/docs/features/sglang-qwen38.mdindex d4e9bb0a09..7579d0553c 100644--- a/docs/features/sglang-qwen38.md+++ b/docs/features/sglang-qwen38.md@@ -213,7 +213,11 @@ skip, and the GPU-exclusivity probe treat all four presets as the same containerthem breaks the harness while leaving the checklist green.- **`ANTHROPIC_AUTH_TOKEN` must be non-empty.** SGLang accepts any value unlessyou started it with `--api-key`, but the SDK refuses to send a request with a- blank one. It ships as `sglang` and is marked secret.+ blank one. It ships as `sglang` and is marked secret. **If you did start the+ container behind `--api-key`, set this to that key** — the provider card's+ `API Key` field feeds only the model-refresh probe on these two presets, so+ filling that in alone leaves every agent run 401ing while the readiness+ checklist stays green.- **`API_TIMEOUT_MS=3000000`** — reasoning plus a long CoS prompt runs well pastthe SDK default.@@ -228,7 +232,32 @@ window incorrectly in the other direction. Every tier`ANTHROPIC_SMALL_FAST_MODEL`) points at the one served `qwen3.8-27b`, so ahaiku-tier sub-call cannot ask the container for a model it has never heard of.-Thinking still rides Qwen's `enable_thinking`, and CoS coding still wants it off.+### Thinking is not switchable on this path++Qwen3.8-27B thinks by default, and the only per-request off switch is+`chat_template_kwargs.enable_thinking` — which the Anthropic wire cannot carry.+Claude Code has no field that maps to it, so an omitted `thinking` block falls+through to the chat-template default and the model keeps thinking. The provider+card therefore offers **no Thinking toggle** on these two presets; showing one+would pin a value nothing reads.++CoS coding still wants thinking off — that is what keeps the tool-call format+reliable. On this path the levers are the serve line (bake a non-thinking+default into the chat template) or the OpenCode presets above, which reach+`enable_thinking` per request through `OPENCODE_CONFIG_CONTENT`. Pick the+harness accordingly: Claude Code buys you the better file-editing loop, OpenCode+buys you the thinking switch.++### These presets deliberately run non-lean++Claude Ollama runs in **lean mode** (`--bare --strict-mcp-config`) because a 7B+local model drowns in Claude Code's full personal environment — hooks, plugins,+MCP servers, global `CLAUDE.md`. The SGLang pair does not, and that is a choice+rather than an oversight: Qwen3.8-27B has a 262,144-token native window, the+same environment is what lets a CoS agent type `/do:pr` and drive a change+through to merge, and a large prompt prefix costs nothing per turn once+`CLAUDE_CODE_ATTRIBUTION_HEADER=0` keeps it byte-identical between turns. Revisit+this if you point the presets at a smaller served model.## GPU exclusivitydiff --git a/scripts/migrations/291-claude-sglang-providers.js b/scripts/migrations/291-claude-sglang-providers.jsindex cae095bbdd..ba4058d4e4 100644--- a/scripts/migrations/291-claude-sglang-providers.js+++ b/scripts/migrations/291-claude-sglang-providers.js@@ -30,15 +30,32 @@* for the same reason migration 284 put Claude Ollama's there: a blank field* would otherwise be indistinguishable from an ambient override.*- * Tool calls additionally need `--tool-call-parser qwen3_coder` on the serve- * line, which the runtime owns (see docs/features/sglang-qwen38.md). Without it- * the schemas are accepted but calls come back as raw text and Claude Code- * executes nothing.+ * Tool calls additionally need SGLang's tool-call-parser flag on the serve line,+ * which the runtime owns — the one place that spelling lives is+ * `parserFlagsFor('sglang')` in server/lib/qwenAgentParsers.js (see+ * docs/features/sglang-qwen38.md). Without it the schemas are accepted but calls+ * come back as raw text and Claude Code executes nothing.** The model name carries NO `[1m]` suffix: native context is 262,144, and* claiming the 1M beta while the serve line does not raise `--context-length`* would cap the window incorrectly in the other direction.*+ * Two deliberate divergences from the Claude Ollama pair they mirror:+ *+ * - **No thinking control.** Qwen3.8-27B thinks by default and the only+ * per-request off switch is `chat_template_kwargs.enable_thinking`, which the+ * Anthropic wire cannot carry. `MAX_THINKING_TOKENS=0` works on Ollama (its+ * endpoint maps an omitted `thinking` field to non-thinking mode) but not+ * here, so the provider card offers no toggle for these records — see+ * `generationControlsFor` in client/src/utils/providers.js. Use the OpenCode+ * wrappers, or the serve line, when a run needs thinking off.+ * - **Non-lean.** `isOllamaClaudeProvider` puts Claude Ollama in lean mode+ * (`--bare --strict-mcp-config`) because a 7B model drowns in the full+ * personal environment. These presets stay non-lean on purpose: 262,144+ * native context, the environment is what lets a CoS agent type `/do:pr`,+ * and a large prefix is free once the attribution header stops changing it+ * between turns.+ ** Both presets are DISABLED and this migration installs nothing — no image pull,* no weights, no container, no request to the endpoint. `sglangBacked: true`* puts them under the same readiness probe and GPU-exclusivity rules as thediff --git a/scripts/migrations/291-claude-sglang-providers.test.js b/scripts/migrations/291-claude-sglang-providers.test.jsindex 8d48a4e524..fda3e4d316 100644--- a/scripts/migrations/291-claude-sglang-providers.test.js+++ b/scripts/migrations/291-claude-sglang-providers.test.js@@ -180,17 +180,28 @@ describe('migration 291 — Claude SGLang providers', () => {expect(readFileSync(providersPath, 'utf-8')).toBe(first);});- it('ships the same records the install seeds do', async () => {- // The migration is the upgrade path for an existing install; data.reference- // (and the toolkit sample it stays in parity with) is the fresh-install path.- // A divergence gives the two populations different providers.+ it('ships the same records all three seed copies do', async () => {+ // Three populations, three sources: the migration upgrades an existing+ // install, data.reference seeds a fresh one, and providers.sample.json is+ // what loadProviders() falls through to when the install seed is absent. A+ // divergence gives those populations different providers.+ //+ // providersSeedParity.test.js already ties data.reference to the sample, but+ // only on the MODEL fields — and every acceptance criterion for these two+ // records lives in `envVars`, which that test documents as legitimately+ // divergent. So pin the env set here, per-id, rather than widening its scope.writeJson(providersPath, { providers: {} });await migration.up({ rootDir });const migrated = readJson(providersPath).providers;const reference = readJson(resolve(__dirname, '../../data.reference/providers.json')).providers;+ const sample = readJson(resolve(__dirname, '../../server/lib/aiToolkit/defaults/providers.sample.json')).providers;for (const id of IDS) {expect(migrated[id]).toEqual(reference[id]);+ expect(sample[id]?.envVars, `${id}.envVars diverged between data.reference and providers.sample.json`)+ .toEqual(migrated[id].envVars);+ expect(sample[id]?.secretEnvVars).toEqual(migrated[id].secretEnvVars);+ expect(sample[id]?.endpoint).toEqual(migrated[id].endpoint);}});});diff --git a/server/lib/cliChildEnv.js b/server/lib/cliChildEnv.jsindex 84cf9d82b4..3e00d9d043 100644--- a/server/lib/cliChildEnv.js+++ b/server/lib/cliChildEnv.js@@ -42,27 +42,54 @@import { withSpawnCwdEnv } from './spawnCwd.js';import { buildOpencodeEnvVars } from './opencodeConfig.js';+import { getOpencodeLocalProviderNamespace, isClaudeCommand } from './providerModels.js';import { agentGuardEnv } from './agentGuard/index.js';// Claude Code defaults to 32K output tokens. Thinking-capable local models can// legitimately spend more than that before returning their final tool call;// when they do, Claude Code paints a terminal API Error and waits forever at an// empty composer. Cloud Claude models own their own output budgets, so widen the-// ceiling only for a Claude harness explicitly marked as Ollama-backed. A value-// in provider.envVars still wins below.-const CLAUDE_OLLAMA_MAX_OUTPUT_TOKENS = '65536';+// ceiling only for a Claude harness pointed at a LOCAL daemon. A value in+// provider.envVars still wins below.+const CLAUDE_LOCAL_MAX_OUTPUT_TOKENS = '65536';-function claudeOllamaEnvDefaults(provider) {- const command = String(provider?.command || '').split(/[\\/]/).pop()?.replace(/\.(?:cmd|exe)$/i, '').toLowerCase();- return provider?.ollamaBacked === true && command === 'claude'- ? {- CLAUDE_CODE_MAX_OUTPUT_TOKENS: CLAUDE_OLLAMA_MAX_OUTPUT_TOKENS,- // Claude Code omits the Anthropic-compatible `thinking` field when- // this is zero, which Ollama maps to Qwen's non-thinking mode. Do not- // set a value when enabled: Claude retains its normal adaptive budget.- ...(provider.thinking === false ? { MAX_THINKING_TOKENS: '0' } : {}),- }- : {};+/**+ * True for a Claude Code harness talking to a local OpenAI/Anthropic-compatible+ * daemon — `claude-ollama` and `claude-sglang` today, plus any renamed or+ * hand-built provider carrying one of the local-backend markers.+ *+ * Keyed on the marker set rather than `ollamaBacked` alone: SGLang serves an+ * Anthropic-compatible `/v1/messages` endpoint, so a `claude` binary drives it+ * exactly the way it drives Ollama, and the 32K-output wedge above is a+ * property of "local thinking-capable model behind the Claude binary", not of+ * Ollama specifically. `orcarouter` is excluded — it is a hosted gateway whose+ * upstream models own their own budgets, the same carve-out `localRuntimeKind`+ * makes.+ */+function isLocalBackedClaude(provider) {+ const namespace = getOpencodeLocalProviderNamespace(provider);+ return !!namespace && namespace !== 'orcarouter' && isClaudeCommand(provider?.command);+}++function claudeLocalEnvDefaults(provider) {+ if (!isLocalBackedClaude(provider)) return {};+ return {+ CLAUDE_CODE_MAX_OUTPUT_TOKENS: CLAUDE_LOCAL_MAX_OUTPUT_TOKENS,+ // Claude Code omits the Anthropic-compatible `thinking` field when this is+ // zero, which Ollama maps to Qwen's non-thinking mode. Do not set a value+ // when enabled: Claude retains its normal adaptive budget.+ //+ // Ollama-only on purpose. Every other local backend takes its thinking+ // switch as `chat_template_kwargs.enable_thinking`, which the Anthropic+ // wire cannot carry — on SGLang an omitted `thinking` field falls through+ // to Qwen3.8's chat-template default, which is thinking ON. Emitting the+ // var there would look like an off switch while changing nothing, so the+ // provider card does not offer the toggle for those records either (see+ // `generationControlsFor` in client/src/utils/providers.js).+ ...(provider.ollamaBacked === true && provider.thinking === false+ ? { MAX_THINKING_TOKENS: '0' }+ : {}),+ };}/**@@ -86,7 +113,7 @@ function claudeOllamaEnvDefaults(provider) {export function composeProviderEnv({ before = null, provider = null, model = null, extra = null } = {}) {return {...(before || {}),- ...claudeOllamaEnvDefaults(provider),+ ...claudeLocalEnvDefaults(provider),...(provider?.envVars || {}),// Rebuilds OPENCODE_CONFIG_CONTENT with a declared models map for OpenCode// local providers (an empty object for everyone else) so the injecteddiff --git a/server/lib/cliChildEnv.test.js b/server/lib/cliChildEnv.test.jsindex 302c301086..3fde93b967 100644--- a/server/lib/cliChildEnv.test.js+++ b/server/lib/cliChildEnv.test.js@@ -219,6 +219,37 @@ describe('composeProviderEnv — delta for sites that do not spawn directly', ()// `sglangBacked` also marks the OpenCode wrappers, but the OpenCode config// is gated on the COMMAND — a `claude` harness must not receive one.expect(env.OPENCODE_CONFIG_CONTENT).toBeUndefined();++ // The 32K-output wedge is a property of "local thinking model behind the+ // claude binary", not of Ollama — a run that reasons past the default ceiling+ // hangs forever at an empty composer, and thinking cannot be turned off here.+ expect(env.CLAUDE_CODE_MAX_OUTPUT_TOKENS).toBe('65536');+ });++ it('widens the Claude output ceiling for any LOCAL backend, never a hosted one', () => {+ const forClaude = (extra) => composeProviderEnv({ provider: { command: 'claude', envVars: {}, ...extra } });++ for (const marker of ['ollamaBacked', 'sglangBacked', 'llamaBacked', 'mtplxBacked', 'vllmBacked']) {+ expect(forClaude({ [marker]: true }).CLAUDE_CODE_MAX_OUTPUT_TOKENS, marker).toBe('65536');+ }+ // OrcaRouter is a hosted gateway whose upstream models own their own output+ // budgets — the same carve-out localRuntimeKind makes.+ expect(forClaude({ orcarouterBacked: true }).CLAUDE_CODE_MAX_OUTPUT_TOKENS).toBeUndefined();+ // And a cloud Claude provider is untouched.+ expect(forClaude({}).CLAUDE_CODE_MAX_OUTPUT_TOKENS).toBeUndefined();+ // The marker alone isn't enough: an OpenCode wrapper is not a Claude harness.+ expect(composeProviderEnv({ provider: { command: 'opencode', sglangBacked: true, envVars: {} } })+ .CLAUDE_CODE_MAX_OUTPUT_TOKENS).toBeUndefined();+ });++ it('emits MAX_THINKING_TOKENS only where an omitted thinking field means OFF', () => {+ // Ollama's Anthropic endpoint maps an omitted `thinking` field to its+ // non-thinking mode, so the var is a real off switch there. SGLang falls+ // through to Qwen3.8's chat-template default (thinking ON), so emitting it+ // would look like an off switch while changing nothing.+ const off = (extra) => composeProviderEnv({ provider: { command: 'claude', thinking: false, envVars: {}, ...extra } });+ expect(off({ ollamaBacked: true }).MAX_THINKING_TOKENS).toBe('0');+ expect(off({ sglangBacked: true }).MAX_THINKING_TOKENS).toBeUndefined();});it('is what buildCliChildEnv layers over its base env', () => {