[PR #15618] cmd/launch: add OpenClaude integration #77529

Open
opened 2026-05-05 10:12:18 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/15618
Author: @jfxdev01
Created: 4/16/2026
Status: 🔄 Open

Base: mainHead: add-openclaude-launch-integration


📝 Commits (1)

  • 00da618 cmd/launch: add OpenClaude integration

📊 Changes

3 files changed (+272 additions, -1 deletions)

View changed files

cmd/launch/openclaude.go (+88 -0)
cmd/launch/openclaude_test.go (+171 -0)
📝 cmd/launch/registry.go (+13 -1)

📄 Description

Summary

  • Add OpenClaude as a launch integration, enabling ollama launch openclaude --model <model> to start OpenClaude with all API traffic routed through the Ollama proxy.
  • OpenClaude is an open-source fork of Claude Code that reads the same ANTHROPIC_* environment variables, so the integration follows the same pattern as the existing Claude runner (simple Runner interface, no Editor or ManagedSingleModel).

What changed

New files:

  • cmd/launch/openclaude.go — Implements the Runner interface for OpenClaude:

    • String() returns "OpenClaude"
    • findPath() locates the openclaude binary via PATH with fallback to ~/.openclaude/local/openclaude[.exe]
    • Run() configures environment variables to route API traffic through Ollama:
      • ANTHROPIC_BASE_URL → Ollama host
      • ANTHROPIC_API_KEY= (empty, Ollama handles auth)
      • ANTHROPIC_AUTH_TOKEN=ollama
      • CLAUDE_CODE_ATTRIBUTION_HEADER=0
      • OPENCLAUDE_DISABLE_CO_AUTHORED_BY=1
      • All model tiers (ANTHROPIC_DEFAULT_OPUS_MODEL, SONNET, HAIKU, CLAUDE_CODE_SUBAGENT_MODEL) overridden to the user-selected model
      • CLAUDE_CODE_AUTO_COMPACT_WINDOW set for known cloud models
    • args() passes --model <model> plus any extra CLI args to the openclaude binary
  • cmd/launch/openclaude_test.go — Tests covering:

    • Interface compliance (*Openclaude satisfies Runner)
    • Binary discovery via PATH and fallback path
    • Argument construction with and without model
    • Model env var routing including cloud model compact window

Modified files:

  • cmd/launch/registry.go — Register OpenClaude in integrationSpecs and launcherIntegrationOrder (placed after claude since it's a closely related fork)

Design rationale

OpenClaude natively supports --provider ollama --model <model> as CLI flags, which uses the OpenAI-compatible path internally. However, the integration uses the Anthropic first-party env var approach (same as the Claude runner) because:

  1. It's consistent with the existing pattern in this codebase
  2. It leverages the ANTHROPIC_DEFAULT_*_MODEL tier override system and lookupCloudModelLimit() that the launch system already provides
  3. OpenClaude, being a Claude Code fork, reads all the same ANTHROPIC_* env vars, making this the most compatible approach

Testing

  • go build ./cmd/launch/ — compiles without errors
  • go test ./cmd/launch/ -run TestOpenclaude -v — all 10 subtests pass
  • go test ./cmd/launch/ (full suite, excluding CGO-dependent VSCode tests) — no regressions
  • Manual test: set env vars and launched openclaude --model <model> against local Ollama — confirmed API traffic routes through Ollama proxy

Examples

# Launch OpenClaude with a local model
ollama launch openclaude --model llama3.2

# Launch OpenClaude with a cloud model
ollama launch openclaude --model glm-5.1:cloud

# Pass extra args to openclaude
ollama launch openclaude --model llama3.2 -- --allowedTools Read,Write,Bash

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/15618 **Author:** [@jfxdev01](https://github.com/jfxdev01) **Created:** 4/16/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `add-openclaude-launch-integration` --- ### 📝 Commits (1) - [`00da618`](https://github.com/ollama/ollama/commit/00da618f40331b208b8a2ba06d244d84c94947bf) cmd/launch: add OpenClaude integration ### 📊 Changes **3 files changed** (+272 additions, -1 deletions) <details> <summary>View changed files</summary> ➕ `cmd/launch/openclaude.go` (+88 -0) ➕ `cmd/launch/openclaude_test.go` (+171 -0) 📝 `cmd/launch/registry.go` (+13 -1) </details> ### 📄 Description ## Summary - Add OpenClaude as a launch integration, enabling `ollama launch openclaude --model <model>` to start OpenClaude with all API traffic routed through the Ollama proxy. - OpenClaude is an open-source fork of Claude Code that reads the same `ANTHROPIC_*` environment variables, so the integration follows the same pattern as the existing `Claude` runner (simple `Runner` interface, no `Editor` or `ManagedSingleModel`). ## What changed **New files:** - `cmd/launch/openclaude.go` — Implements the `Runner` interface for OpenClaude: - `String()` returns `"OpenClaude"` - `findPath()` locates the `openclaude` binary via PATH with fallback to `~/.openclaude/local/openclaude[.exe]` - `Run()` configures environment variables to route API traffic through Ollama: - `ANTHROPIC_BASE_URL` → Ollama host - `ANTHROPIC_API_KEY=` (empty, Ollama handles auth) - `ANTHROPIC_AUTH_TOKEN=ollama` - `CLAUDE_CODE_ATTRIBUTION_HEADER=0` - `OPENCLAUDE_DISABLE_CO_AUTHORED_BY=1` - All model tiers (`ANTHROPIC_DEFAULT_OPUS_MODEL`, `SONNET`, `HAIKU`, `CLAUDE_CODE_SUBAGENT_MODEL`) overridden to the user-selected model - `CLAUDE_CODE_AUTO_COMPACT_WINDOW` set for known cloud models - `args()` passes `--model <model>` plus any extra CLI args to the `openclaude` binary - `cmd/launch/openclaude_test.go` — Tests covering: - Interface compliance (`*Openclaude` satisfies `Runner`) - Binary discovery via PATH and fallback path - Argument construction with and without model - Model env var routing including cloud model compact window **Modified files:** - `cmd/launch/registry.go` — Register OpenClaude in `integrationSpecs` and `launcherIntegrationOrder` (placed after `claude` since it's a closely related fork) ## Design rationale OpenClaude natively supports `--provider ollama --model <model>` as CLI flags, which uses the OpenAI-compatible path internally. However, the integration uses the **Anthropic first-party env var approach** (same as the `Claude` runner) because: 1. It's consistent with the existing pattern in this codebase 2. It leverages the `ANTHROPIC_DEFAULT_*_MODEL` tier override system and `lookupCloudModelLimit()` that the launch system already provides 3. OpenClaude, being a Claude Code fork, reads all the same `ANTHROPIC_*` env vars, making this the most compatible approach ## Testing - [x] `go build ./cmd/launch/` — compiles without errors - [x] `go test ./cmd/launch/ -run TestOpenclaude -v` — all 10 subtests pass - [x] `go test ./cmd/launch/` (full suite, excluding CGO-dependent VSCode tests) — no regressions - [x] Manual test: set env vars and launched `openclaude --model <model>` against local Ollama — confirmed API traffic routes through Ollama proxy ## Examples ```bash # Launch OpenClaude with a local model ollama launch openclaude --model llama3.2 # Launch OpenClaude with a cloud model ollama launch openclaude --model glm-5.1:cloud # Pass extra args to openclaude ollama launch openclaude --model llama3.2 -- --allowedTools Read,Write,Bash ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-05 10:12:18 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#77529