From 02c6758a614b9b3a5665ae8e16df9df28da73be4 Mon Sep 17 00:00:00 2001 From: dtzp555 Date: Sat, 11 Apr 2026 16:40:36 +1000 Subject: [PATCH] feat: CLAUDE_NO_CONTEXT mode to suppress context injection (closes #11) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds CLAUDE_NO_CONTEXT=true env var that passes CLAUDE_CODE_DISABLE_CLAUDE_MDS=1 and CLAUDE_CODE_DISABLE_AUTO_MEMORY=1 to Claude CLI child processes. This suppresses CLAUDE.md and auto-memory injection while preserving OAuth auth — needed for third-party agents like Hermes that have their own memory systems. Co-Authored-By: Claude Opus 4.6 --- README.md | 1 + package.json | 2 +- server.mjs | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cfef64a..65399f5 100644 --- a/README.md +++ b/README.md @@ -419,6 +419,7 @@ If you installed OCP before v3.1.0, the auto-start service used names that OpenC | `CLAUDE_SESSION_TTL` | `3600000` | Session expiry (ms, default: 1 hour) | | `CLAUDE_ALLOWED_TOOLS` | `Bash,Read,...,Agent` | Comma-separated tools to pre-approve | | `CLAUDE_SKIP_PERMISSIONS` | `false` | Bypass all permission checks | +| `CLAUDE_NO_CONTEXT` | `false` | Suppress CLAUDE.md and auto-memory injection (pure API mode) | | `PROXY_API_KEY` | *(unset)* | Bearer token for shared-mode authentication | ## Security diff --git a/package.json b/package.json index 032802e..b880e53 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openclaw-claude-proxy", - "version": "3.5.1", + "version": "3.5.2", "description": "OCP (Open Claude Proxy) — use your Claude Pro/Max subscription as an OpenAI-compatible API for any IDE. Works with Cline, OpenCode, Aider, Continue.dev, OpenClaw, and more.", "type": "module", "bin": { diff --git a/server.mjs b/server.mjs index cd7e9f7..1ed3e52 100644 --- a/server.mjs +++ b/server.mjs @@ -94,6 +94,7 @@ const BREAKER_COOLDOWN = parseInt(process.env.CLAUDE_BREAKER_COOLDOWN || "120000 const BREAKER_WINDOW = parseInt(process.env.CLAUDE_BREAKER_WINDOW || "300000", 10); const BREAKER_HALF_OPEN_MAX = parseInt(process.env.CLAUDE_BREAKER_HALF_OPEN_MAX || "2", 10); const BIND_ADDRESS = process.env.CLAUDE_BIND || "127.0.0.1"; +const NO_CONTEXT = process.env.CLAUDE_NO_CONTEXT === "true"; const AUTH_MODE = process.env.CLAUDE_AUTH_MODE || (PROXY_API_KEY ? "shared" : "none"); const ADMIN_KEY = process.env.OCP_ADMIN_KEY || ""; @@ -416,6 +417,12 @@ function spawnClaudeProcess(model, messages, conversationId) { delete env.ANTHROPIC_BASE_URL; delete env.ANTHROPIC_AUTH_TOKEN; + // Pure API mode: suppress Claude Code context injection while preserving OAuth auth + if (NO_CONTEXT) { + env.CLAUDE_CODE_DISABLE_CLAUDE_MDS = "1"; + env.CLAUDE_CODE_DISABLE_AUTO_MEMORY = "1"; + } + const proc = spawn(CLAUDE, cliArgs, { env, stdio: ["pipe", "pipe", "pipe"] }); activeProcesses.add(proc); @@ -1367,6 +1374,7 @@ server.listen(PORT, BIND_ADDRESS, () => { console.log(`Auth: ${PROXY_API_KEY ? "enabled (PROXY_API_KEY set)" : "disabled (no PROXY_API_KEY)"}`); console.log(`Auth mode: ${AUTH_MODE}${AUTH_MODE === "shared" ? " (PROXY_API_KEY)" : AUTH_MODE === "multi" ? " (per-user keys)" : " (open)"}`); console.log(`Bind: ${BIND_ADDRESS}${BIND_ADDRESS === "0.0.0.0" ? " ⚠ LAN-accessible" : ""}`); + if (NO_CONTEXT) console.log(`Context: suppressed (CLAUDE_NO_CONTEXT=true — no CLAUDE.md, no auto-memory)`); console.log(`---`); console.log(`Coexistence: This proxy does NOT conflict with Claude Code interactive mode.`); console.log(` OCP uses: localhost:${PORT} (HTTP) → claude -p (per-request process)`);