Skip to content

feat(providers): add OpenMythos local-model provider#15

Open
baseflux wants to merge 2 commits intoGPT-AGI:mainfrom
baseflux:openmythos-provider-2026-04
Open

feat(providers): add OpenMythos local-model provider#15
baseflux wants to merge 2 commits intoGPT-AGI:mainfrom
baseflux:openmythos-provider-2026-04

Conversation

@baseflux
Copy link
Copy Markdown

Adds OpenMythos (Recurrent-Depth Transformer) as a seventh provider so Clawd-Code can drive a local PyTorch model instead of a remote API.

Scope

  • `src/providers/openmythos_provider.py` — new `OpenMythosProvider` class implementing `BaseProvider.chat()` and `chat_stream()`. Runs one recurrent forward pass per decode token, reuses the KV cache across steps, buffers BPE-partial pieces so gpt-oss-20b tokens render cleanly.
  • `src/providers/init.py` — registers `openmythos` in `PROVIDER_INFO` with the 7 `mythos_*` variants; wires `get_provider_class`.
  • `pyproject.toml` — new `[openmythos]` optional extra pinning `open-mythos>=0.4.0` and `torch>=2.4,<3`. Default install is unchanged.
  • `tests/test_openmythos_provider.py` — 3 smoke tests (registration, class resolution, transcript formatting). Full wire test skipped unless torch+open_mythos are both installed so CI stays light.
  • `docs/openmythos-provider.md` — install, env vars, streaming model, knobs, known limitations.

Why

Three workflows benefit:

  1. Integration dev — smoke-test the Clawd plumbing without API keys or network.
  2. Local eval — point Clawd at a checkpoint you trained via OpenMythos's `training/` scripts.
  3. Research — drive the recurrent-depth model from an interactive shell for depth-extrapolation experiments (inference-time `n_loops` > training `max_loop_iters`).

Caveat (documented)

OpenMythos does not ship pretrained weights. Without `OPENMYTHOS_CHECKPOINT` the model is random-init and produces noise. The provider docs flag this prominently. Useful for wiring checks and post-training use, not out-of-box chat.

Not included

  • Tool calling (architectural — OpenMythos has no tool-output head). Clawd's agent loop falls back to text-only when a provider doesn't honor tool schemas.
  • Chat template — there's no pretrained chat format to honor. Transcript is rendered as `role: content` per line, terminated with `assistant:`.

Env

```
export OPENMYTHOS_VARIANT=mythos_3b # or any mythos_
export OPENMYTHOS_CHECKPOINT=/path/state.pt # optional
export OPENMYTHOS_N_LOOPS=16 # inference-time depth
export OPENMYTHOS_DEVICE=cuda # auto-detected if unset
export OPENMYTHOS_TOKENIZER=openai/gpt-oss-20b
```

Verification

```
pytest tests/test_openmythos_provider.py
3 passed, 1 skipped in 0.01s
```

(Skipped case loads torch + open_mythos end-to-end; runs when the `[openmythos]` extra is installed.)

PAI Review added 2 commits April 21, 2026 23:37
Wires OpenMythos (a local PyTorch Recurrent-Depth Transformer) behind
the Clawd BaseProvider interface so Clawd-Code can drive a local model
instead of a remote API.

- src/providers/openmythos_provider.py: new OpenMythosProvider class.
  Implements chat() and chat_stream() by calling OpenMythos's forward()
  in a decode loop with KV cache reuse. Streams token-by-token, with
  BPE-partial-piece buffering so gpt-oss-20b tokens render cleanly.
  Heavy imports (torch, open_mythos) deferred to __init__ so Clawd
  users without PyTorch are unaffected at package-import time.

- src/providers/__init__.py: register 'openmythos' in PROVIDER_INFO
  with the 7 mythos_* variants; wire get_provider_class.

- pyproject.toml: add [openmythos] extra pinning open-mythos>=0.4.0
  and torch>=2.4,<3. Does not affect base install.

- tests/test_openmythos_provider.py: smoke tests for registration,
  class resolution, transcript formatting. Full wire test skipped if
  torch/open_mythos not installed so CI stays light.

- docs/openmythos-provider.md: install, env vars, streaming model,
  knobs, known limitations (no tool calling, no pretrained weights).

The 'no pretrained weights' caveat is documented prominently — this
provider is for integration-dev, research eval, and post-training use,
not for out-of-box chat.
Adds support for running any local Ollama model (including refusal-
removed Qwen 3.5 abliterated) through Clawd-Code.

Why not OpenAI-compat? Ollama's OpenAI facade does not forward the
`think` parameter, which means reasoning models (Qwen 3.5, DeepSeek-R1)
burn their entire token budget inside <think>...</think> blocks and
return an empty content string. Hitting /api/chat directly with
think=false (or letting the user opt into think=true) fixes this and
gives us access to the model's reasoning trace via
ChatResponse.reasoning_content.

- src/providers/ollama_provider.py: OllamaProvider class. Uses stdlib
  urllib (zero extra deps). Implements chat / chat_stream /
  chat_stream_response and get_available_models (via /api/tags).
- src/providers/__init__.py: register 'ollama' with default model
  llama3.2:3b and abliterated Qwen in the available list.
- tests/test_ollama_provider.py: 4 hermetic tests, 2 live tests that
  skip if Ollama is not running.

Env knobs: OLLAMA_BASE_URL, OLLAMA_THINK.
@baseflux
Copy link
Copy Markdown
Author

Update: pushed a 2nd commit adding an `OllamaProvider` (native `/api/chat`, supports `think=false`).

Rationale: Ollama's OpenAI-compatible facade does not forward the `think` parameter, which means reasoning models like Qwen 3.5, DeepSeek-R1, and `huihui_ai/qwen3.5-abliterated` burn the entire token budget inside `...` before emitting any content, and return an empty string. Hitting `/api/chat` directly with `think=false` fixes this; `think=true` gives access to the model's reasoning trace via `ChatResponse.reasoning_content`.

Zero extra deps (stdlib `urllib`). 4 hermetic tests + 2 live tests that skip if Ollama is not running. Works seamlessly with the existing OpenMythos provider for a "local chat + local training" workflow.

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.

1 participant