Repository navigation
Description
Outcome and dependencies
Optionally expose a runtime-vendor-documented compatible local endpoint through the existing claude -p backend, without claiming official Anthropic support for non-Claude execution.
Parent: #376. Completion dependencies: #378 (LM-2 connection/credential service) and #380 (LM-5 local-run privacy/admission policy). Priority: P3. Delivery group: optional experiment, explicitly outside Local models v1 core completion. This issue never blocks #383 or the Codex local-model release. Reuse #383's test approach/fixtures where available without making that issue a prerequisite or creating a cycle.
Follow the shared execution contract in #376. Experimental support and activation need their own evidence/decision; existing cloud Claude behavior stays unchanged.
Context and source entry points
Refresh current main, scoped AGENTS.md and actual native/runtime documentation before implementation. Publication baseline: ec7be578765f9ce54976882853e57ca190252361.
Existing: apps/desktop/src/main/engine/backends/{claude,health,types}.ts and accepted connection/policy/model-picker contracts. Proposed: apps/desktop/test/local-claude.test.ts. Reuse existing stream-json events, Stop and request broker; no SDK migration, second loop or tool executor.
Consumes: validated local profiles, secrets, qualification state and no-cloud-fallback policy. Produces: either a narrowly qualified opt-in native route with exact limitations, or a documented unsupported/blocked result. A negative feasibility finding is valid evidence, not permission to weaken safety.
Implementation steps
- Recheck Anthropic gateway support boundaries and the exact runtime vendor's compatibility documentation, such as LM Studio's integration guide. Record version/date and any disagreement; vendor compatibility claims do not establish Anthropic-supported non-Claude behavior.
- Before exposing execution, prove a real native stream-json/tool/approval/Stop round trip with a preinstalled model in an authorized disposable fixture. Add per-child, profile-scoped endpoint/auth configuration only against that verified protocol.
- Audit every model destination, including helper, title, follow-up, delegated and compaction paths. One
--modelsetting is insufficient evidence of fully local behavior. Apply [P1][LM-5] Enforce local-run privacy, bounded resource use and truthful recovery #380's no-cloud-fallback/admission policy; disable features whose destination or authority cannot be constrained. - Remove conflicting inherited endpoint switches/provider credentials for the local child while retaining applicable managed safety policy. Never edit global shell or
~/.claudesettings, forward subscription credentials to a local server or bypass platform restrictions. - Reuse current Stop, permission requests, event identity/mapping and recovery. Show experimental status, exact native/runtime limitations and stale qualification. Keep unavailable paths disabled; unresolved protocol/privacy boundaries leave that combination unavailable.
- Keep default cloud Claude sessions unchanged and scope process/session/credential identity to the local connection. The experiment must not introduce a hard dependency into the core Codex release.
Acceptance criteria
- AC1: the route is explicitly experimental and records the exact tested CLI/model/server/configuration and upstream support limitation.
- AC2: native tool/approval/Stop behavior and every auxiliary model destination pass qualification; default cloud Claude sessions remain unchanged.
- AC3: unsupported or unverified configurations cannot appear production-ready; no permission weakening, managed-policy bypass or silent cloud fallback is used to make a test pass.
- AC4: this issue's state does not block [P1][LM-7] Prove local-model integration and publish the supported compatibility matrix #383 or the core release; it retains independent evidence and activation decision.
- AC5: credentials do not enter renderer/logs/exports; cloud account secrets never reach the local server; global settings bytes remain unchanged.
Verification and handoff
Begin with failing scoped-config/credential/destination/lifecycle tests. Use current focused suites, pnpm build && pnpm test, and pnpm test:e2e for UI changes. Keep mock fixtures and real native qualification separate, with exact SHA/version/results and authorization. Update existing local-model docs/status and a dated review receipt. Unavailable native tests remain open. No merge, release, feature activation or model downloads without separate authority.
Long-running goal prompt
Evaluate LM-8 for TypeSafeAI/modex under #376 only as an optional experiment. Consume #378/#380's accepted contracts, read current AGENTS.md, source and vendor/native documentation, and verify main plus owned worktree. First prove the actual claude -p stream-json/tool/approval/Stop path with a preinstalled model in an authorized disposable fixture. Scope credentials and all model destinations, including helpers/compaction; retain managed safety and existing cloud behavior. Show unsupported combinations as unavailable rather than claiming official support or weakening policy. Use failing-first tests, targeted/full checks, signed reviewable commits and status/evidence updates. Checkpoint SHAs, exact versions/results, remaining gates and one next action. Never hold the core Codex release for this issue. No merge, release, global settings rewrite, activation or unapproved downloads.
Follow-up / resume prompt
Resume LM-8 from its live issue/PR and checkpoint. Verify ownership, actual diff, producer contracts and current upstream support statements/native-runtime versions. Repeat the smallest safe qualification and audit helper/compaction destinations plus inherited credentials. Stop on unresolved privacy or permission boundaries; do not bypass managed policy or delay the core release. Fix one bounded regression, rerun smoke/full checks and record exact evidence separately from mocks. Keep unsupported combinations and unrun gates explicit. No merge, publication or scope expansion.
Activity
BunsDev commentedon Oct 23, 2026
Refreshed goal prompts — 2026-10-23 (
mainat203a350)On
mainalready:backends/claude.tsdrivesclaude -pover stream-json with--permission-prompt-tool stdio, and its child environment comes fromcliEnvironment. The Agent SDK migration (ref(claude): Drive turns through the Agent SDK #249, Drive Claude through the Agent SDK instead ofclaude -pstream-json #250) was closed unmerged, so this route stays on the CLI;local-modelscode, nodocs/local-models.mdand no LM entry indocs/status.md.Still open:
SecretStore, with fixture-only evidence. A local review (not on GitHub) found two defects to fix first: a changed token can resolve under the old revision after a failed write, and model metadata can echo the saved token into IPC.048d1e8, local branchlm1-contract, not pushed) namesclaudeas a harness but did not test a Claude route.Local worktrees
lm1-contract,lm2-discovery,lm3-isolationandlm-foundationare claimed by other sessions. Don't adopt or edit them.Long-running goal prompt
Follow-up / resume prompt
misterespresso commentedon Oct 24, 2026
I'd like to take the ungated parts of LM-8. Per the 2026-10-23 refresh, slices 3–4 wait for #378/#380 acceptance, so I'll stay out of the backend until then.
Plan:
~/.claudeor global settings, and no subscription credentials sent to the local server.I'll post the results as a dated receipt here. Any of it can go into a
docs/reviews/PR later if you want. A negative result gets reported as-is. Does that scope work for you?misterespresso commentedon Oct 24, 2026
LM-8 Slice 1: support boundaries for a local
claude -proutemain:a10fcc4Summary
Sources
All pages were retrieved on 2026-10-24. None of them carries a date or version.
ANTHROPIC_BASE_URL.Secondary source: an Ollama blog post says Anthropic compatibility arrived in v0.14.0 (January 2026). I have not confirmed this against Ollama's release notes.
Where the documentation disagrees
ANTHROPIC_AUTH_TOKENoverrides the saved login. A base URL alone keeps the claude.ai login active for requests sent to that host.ANTHROPIC_AUTH_TOKEN=ollama(required but ignored) andANTHROPIC_API_KEY=""ANTHROPIC_AUTH_TOKEN=lmstudio, or the real LM Studio token when auth is on. Does not clearANTHROPIC_API_KEY.CLAUDE_CODE_ATTRIBUTION_HEADER=0count_tokensis optionalcount_tokens,tool_choice, prompt caching, citations, PDF blocks or streaming error events.budget_tokensis not enforced.ANTHROPIC_DEFAULT_*_MODEL--modelonly--modelonlyFindings that constrain the Modex route
F1. Risk of leaking the subscription login (AC5).
ANTHROPIC_BASE_URLbut no gateway credential. Claude Code then uses the saved claude.ai login for requests to that host, which here is the local server.cliEnvironment(apps/desktop/src/main/engine/backends/health.ts:8-17) passes the whole parent environment through. That includes any inheritedANTHROPIC_*,CLAUDE_CODE_OAUTH_TOKENandCLAUDE_CODE_USE_*variables.ANTHROPIC_AUTH_TOKEN;ANTHROPIC_API_KEY;F2. Settings-file
envbeats the process environment.envblock set the same variable, the settings-file value applies."envblock in the user's~/.claude/settings.jsonor a project.claude/settings*.jsonwould override what Modex puts in the child environment. A gateway URL or token set there could send the turn to the cloud, or send a cloud credential to the local server.--settingsenvoverride, for non-secret values only, since argv is visible in the process list;--setting-sourceswithoutuser.~/.claude.F3. Traffic that does not follow
ANTHROPIC_BASE_URL:api.anthropic.com;api.anthropic.com;How to switch these off:
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1covers the first group.fastModethrough--settingsatclaude.ts:94.skipWebFetchPreflight: true.Slice 2 should capture network traffic to show that nothing is left.
F4. Model aliases and auxiliary destinations.
ANTHROPIC_DEFAULT_HAIKU_MODELpins another.haiku,sonnetoropus, andfallbackModeland the content-safety fallback name Claude models. All of these still go to the base URL, so they fail locally rather than reach the cloud.ANTHROPIC_DEFAULT_{OPUS,SONNET,HAIKU,FABLE}_MODELCLAUDE_CODE_SUBAGENT_MODEL--fallback-modelshould be passed.F5. Context windows on this machine (from
/api/show).qwen3:14b:gpt-oss:20b:-16kvariant usesnum_ctx16,384, which is too small.num_ctx≥ 64k variant, made withollama createfrom the local weights (no download), plus a VRAM check on 16 GB.F6. Protocol, verified locally:
POST /v1/messagesexists (GETreturns 405);/v1/messages/count_tokensreturns 404, and Claude Code falls back to a character estimate;/v1/modelsreturns 200.Still unknown:
context_management,defer_loadingandeffort(fallbacks:CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1,ENABLE_TOOL_SEARCH=false);F7. Managed policy.
allowedProviderssetting (v2.1.285+) can refuse a custom endpoint.forceLoginMethodcannot be combined withANTHROPIC_AUTH_TOKEN.Proposed Slice 2: disposable native probe, pending go-ahead
gpt-oss:20bvariant withnum_ctx65536 from the local weights, and record VRAM use.claude -p --input-format stream-json --output-format stream-json --permission-prompt-tool stdiowith:--setting-sourcestested both with and withoutuser.HTTPS_PROXY) and record every non-loopback destination.