Skip to content

[Migrate local backend from LM Studio to Ollama]#522

Merged
cgfixit merged 1 commit into
mainfrom
feature/ollama-migration-verified
Jul 13, 2026
Merged

[Migrate local backend from LM Studio to Ollama]#522
cgfixit merged 1 commit into
mainfrom
feature/ollama-migration-verified

Conversation

@cgfixit

@cgfixit cgfixit commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Summary

Migrates CyClaw's local LLM backend from LM Studio to Ollama. Zero adapter code — LocalLLMClient keeps speaking raw OpenAI-compatible HTTP; only endpoints, model tags, service labels, and docs change. Includes full independent verification (test suite + live gateway smoke tests + swarm-sandbox emulation) and closes three review findings.

Changes

Ollama migration

  • config.yaml: provider: ollama, base_url: http://127.0.0.1:11434/v1, model: qwen2.5:7b; stall-math comments updated to num_ctx semantics
  • llm/client.py, utils/health.py, graph.py, gate.py, schemas/api.py, utils/personality.py: lm_studioollama service labels, error strings, health probe (GET /v1/models)
  • agentic/config.py: deepagent default provider ollama @ 11434 (lmstudio still valid for back-compat)
  • agentic/harness_optimizer/model_adapter.py: proposer provider label → ollama
  • guardrails/config.py: fallback defaults migrated to 11434 / qwen2.5:7b (was inconsistently left at 1234)

Tests (10 stale failures → 0)

  • conftest.py, test_health.py, test_client.py, test_due_diligence_invariants.py, test_agentic_config.py updated to Ollama expectations

Docs

  • New OLLAMA_SETUP.md — install, model pull, and OLLAMA_CONTEXT_LENGTH guidance (Ollama's 4096 default is below the 8,500-token no-stall floor; correct /set parameter num_ctx form, no fake --num_ctx flag)
  • New SECURITY.md — security model + accepted dependency risks with review dates (chromadb PYSEC-2026-311, embedded PersistentClient only; nltk PYSEC-2026-597). Closes the dangling reference in requirements.txt
  • docs/screenshots/ — 5 live terminal.html captures from verification (vault hit answered via Ollama API, triple-gate confirm dialog with Send-to-Grok/Claude buttons, deny → offline-best-effort, soul console, agentic console 4-gate checklist)

Verification

Check Result
Full pytest suite (py3.12, pinned env, torch 2.12.1+cpu) 1,271 tests: 1,258 passed / 0 failed / 13 skipped (live-Postgres)
Live gateway vs mock Ollama (/v1/models, /v1/chat/completions) /health ok (service ollama), /query full RAG round trip, model_used: local
Triple gate (forced vault miss) pause → confirm dialog → Grok (Bearer, /chat/completions) / Claude (x-api-key + anthropic-version, /messages) / deny → offline-best-effort / unavailable → offline-best-effort
Fail-closed surface 401 no-key, 422 unknown ops action (Literal schema), 429 rate limit, security headers, TrustedHost
Due-diligence invariants 12/12
pip-audit No new advisories (both known findings documented in SECURITY.md)
bandit No new findings vs main (9 pre-existing medium B608, all behind read-only guards)

Notes for review

  • agentic/harness_optimizer/mcp/tools.py is untouched vs main — the holdout_hidden symlink guard and its 3 tests are intact (an earlier working zip had dropped them; restored before this PR)
  • Cosmetic "LM Studio down" mock strings in test_graph.py / test_runtime_errors.py are test-authored fixtures, pass fine, and were deliberately left alone
  • Operators MUST set OLLAMA_CONTEXT_LENGTH>=10000 (or per-model num_ctx) — see OLLAMA_SETUP.md

…tests green)

- Swap local LLM provider to Ollama: base_url 127.0.0.1:11434/v1, model
  qwen2.5:7b, service label lm_studio -> ollama across client, health,
  graph, gate, schemas, personality, agentic deepagent + harness proposer
- guardrails/config.py fallback defaults migrated (11434 / qwen2.5:7b)
- Tests updated to Ollama expectations (conftest, health, client,
  due-diligence invariants, agentic config) - suite: 1258 pass / 0 fail
- New OLLAMA_SETUP.md: install, model pull, OLLAMA_CONTEXT_LENGTH stall
  guidance (4096 default < 8500 no-stall floor), troubleshooting
- New SECURITY.md: security model + accepted dep risks with review dates
  (chromadb PYSEC-2026-311 embedded-only, nltk PYSEC-2026-597) - closes
  dangling requirements.txt reference
- docs/screenshots/: 5 live terminal.html verification captures (vault
  hit via Ollama API, triple-gate confirm dialog, offline best-effort
  deny path, soul console, agentic console 4-gate checklist)

Verification: full pinned env (py3.12, torch 2.12.1+cpu, chromadb 1.5.9,
langgraph 1.2.6) - 1271 tests: 1258 passed, 0 failed, 13 skipped
(live-Postgres). Live gateway smoke-tested against mock Ollama
(/v1/models health probe, /v1/chat/completions RAG round trip, triple
gate Grok/Claude request shapes, 401/422/429 fail-closed, security
headers). pip-audit: no new advisories. bandit: no new findings vs main.
Comment thread agentic/config.py Dismissed
Comment thread config.yaml Dismissed
Comment thread tests/conftest.py Dismissed
Comment thread tests/test_agentic_config.py Dismissed
@cgfixit cgfixit changed the title feat(llm): migrate local backend from LM Studio to Ollama (verified) [Migrate local backend from LM Studio to Ollama] Jul 13, 2026
@cgfixit cgfixit marked this pull request as ready for review July 13, 2026 14:38
@cgfixit cgfixit merged commit f56a127 into main Jul 13, 2026
29 checks passed
@cgfixit cgfixit deleted the feature/ollama-migration-verified branch July 13, 2026 14:38
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