Skip to content

Agent: LM Studio as a local model; remove the Claude Code mode - #38

Merged
drthyang merged 1 commit into
mainfrom
claude/agent-lmstudio
Oct 10, 2026
Merged

drthyang merged 1 commit into
mainfrom
claude/agent-lmstudio

Conversation

@drthyang

Copy link
Copy Markdown
Owner

Summary

LM Studio as a fourth way to reach a model. LM Studio 0.4.1+ answers the Anthropic Messages API at /v1/messages, so the Agent drives it with the same chat loop, tools, approval cards and undo as Ollama. It sends only plain headers and only the request fields a local server reads.

  • The drawer lists the server's language models from /api/v1/models, those trained for tool use first, each with the context its loaded copy was given.
  • It auto-picks a tool-trained model with room for the Agent's ~15k-token instructions, and warns when a model is loaded with less than 32k (lms load <model> --context-length 32768).
  • Errors name the CORS switch (LM Studio admits no other origin until Enable CORS is on), the version requirement, a context overflow, and a server that requires a token.

The Claude Code mode is removed, together with the materia-live MCP bridge (src/agent/bridge/, bridgeClient.ts), scripts/live-bridge-demo.mjs, the mcp:live / build:mcp-live scripts and its .mcp.json entry.

  • The materia MCP server is unchanged.
  • The Agent now starts on the user's own API key; a saved Claude Code choice falls back to it, and stored settings keep only known keys.
  • With one sender left, tool calls no longer carry a source.

Shared local-server helpers (plainFetch, the 32k context floor) move to src/agent/localServer.ts.

Docs: docs/AGENT_TOOLS.md (modes table, LM Studio, a plain explanation of the local proxy), docs/ROADMAP.md, CHANGELOG.md (Unreleased).

Testing

  • npm run typecheck, npm run lint, npm run build, and node scripts/build-mcp.mjs all pass.
  • Full suite: 1674 passed, 113 skipped.
  • New tests:
    • lmstudio.test.ts: model listing against a stand-in server in LM Studio's documented shape, plus the too-old and not-LM-Studio cases.
    • chat.test.ts: LM Studio request headers and fields, the Ollama → LM Studio history switch, and error messages.
    • useAgent.test.ts: migrating stored settings from Claude Code.
  • Ran the dev app in Chromium against a stand-in LM Studio (CORS on):
    • a stored claude-code setting migrated to API key;
    • the models listed and the auto-pick skipped the 4k-context one;
    • a chat turn called get_state and answered, sending no x-api-key, anthropic-* or authorization headers;
    • a wrong address showed the CORS hint.
  • Not tested against a real LM Studio install (not downloadable from this environment).

🤖 Generated with Claude Code

https://claude.ai/code/session_01MReUfYLPkA6mqDmVQK5NpM


Generated by Claude Code

LM Studio (0.4.1+) answers the Anthropic Messages API at /v1/messages, so the
Agent drives it with the same loop, tools and approvals as Ollama: plain
headers only, the fields a local server reads. The drawer lists the server's
language models from /api/v1/models, those trained for tool use first, with
each loaded copy's context, picks one with room for the Agent's ~15k-token
instructions, and says how to reload with 32k. Errors name the CORS switch,
the version, a context overflow and a server that wants a token.

The Claude Code mode is gone with its materia-live MCP bridge, scripts and
.mcp.json entry; the materia MCP server is unchanged. The Agent now starts on
the user's own API key, and a saved Claude Code choice falls back to it. With
one sender left, tool calls no longer carry a source.

Shared local-server helpers (plainFetch, the context floor) move to
localServer.ts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MReUfYLPkA6mqDmVQK5NpM
@drthyang
drthyang merged commit 849c65f into main Oct 10, 2026
2 checks passed
@drthyang
drthyang deleted the claude/agent-lmstudio branch October 10, 2026 03:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants