Compress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.
Python agentaianthropicclaude-codecompressioncontext-engineeringcontext-windowcursorfastapilangchainllmmcpopenaiprompt-engineeringproxypythonragtoken-optimizationtokenstypescript
fix(openclaw): proxyPort only applies to local URLs, consistency pass
JerrettDavis89f3e5f01f2c
diff --git a/plugins/openclaw/README.md b/plugins/openclaw/README.mdindex 9d24f62da..86dc1cace 100644--- a/plugins/openclaw/README.md+++ b/plugins/openclaw/README.md@@ -78,9 +78,9 @@ Point `proxyUrl` to any reachable Headroom instance:Remote URLs are **connect-only** — the plugin probes the URL at startup and fails fast if the proxy is not reachable. No subprocess is spawned for remote addresses.-## Required Proxy Setup+## Manual Proxy Setup-Optional: run Headroom proxy yourself before launching OpenClaw.+If you prefer to manage the proxy yourself (or are running a remote instance), start it before launching OpenClaw:Python install:@@ -114,7 +114,7 @@ Compression is lossless via CCR (Compress-Cache-Retrieve): originals are stored| `proxyUrl` | auto-detected | Optional URL of a Headroom proxy. Local addresses (`http://127.0.0.1:<port>`, `http://localhost:<port>`) enable auto-start; remote URLs (`https://headroom.example.com`) are connect-only. || `proxyPort` | `8787` | Port used for default auto-detect/auto-start when `proxyUrl` is not set. || `pythonPath` | auto-detected | Optional Python executable override for Python fallback launcher. |-| `autoStart` | `true` | Auto-start `headroom proxy` if not already running |+| `autoStart` | `true` | Auto-start a local `headroom proxy` if not already running (local URLs only; ignored for remote proxies) || `startupTimeoutMs` | `20000` | Time to wait for auto-started proxy to become healthy |## Comparison with lossless-clawdiff --git a/plugins/openclaw/openclaw.plugin.json b/plugins/openclaw/openclaw.plugin.jsonindex dc81baf22..5c54599c7 100644--- a/plugins/openclaw/openclaw.plugin.json+++ b/plugins/openclaw/openclaw.plugin.json@@ -49,8 +49,6 @@"capabilities": {"network": {"allow": [- "http://localhost:*",- "http://127.0.0.1:*","http://*:*","https://*:*"]diff --git a/plugins/openclaw/package.json b/plugins/openclaw/package.jsonindex a1229e2b4..4ffcaf8ec 100644--- a/plugins/openclaw/package.json+++ b/plugins/openclaw/package.json@@ -46,8 +46,8 @@"capabilities": {"network": {"allow": [- "http://localhost:*",- "http://127.0.0.1:*"+ "http://*:*",+ "https://*:*"]}}diff --git a/plugins/openclaw/src/index.ts b/plugins/openclaw/src/index.tsindex 7db0a5fc0..aef51f099 100644--- a/plugins/openclaw/src/index.ts+++ b/plugins/openclaw/src/index.ts@@ -1,5 +1,5 @@export { default } from "./plugin/index.js";export { HeadroomContextEngine } from "./engine.js";-export { ProxyManager, normalizeAndValidateProxyUrl, probeHeadroomProxy } from "./proxy-manager.js";+export { ProxyManager, normalizeAndValidateProxyUrl, isLocalProxyUrl, probeHeadroomProxy } from "./proxy-manager.js";export { agentToOpenAI, openAIToAgent } from "./convert.js";export { createHeadroomRetrieveTool } from "./tools/headroom-retrieve.js";diff --git a/plugins/openclaw/src/proxy-manager.ts b/plugins/openclaw/src/proxy-manager.tsindex b5ea499c6..bfc56eacf 100644--- a/plugins/openclaw/src/proxy-manager.ts+++ b/plugins/openclaw/src/proxy-manager.ts@@ -59,14 +59,18 @@ export class ProxyManager {}/**- * Ensure a proxy is available. Returns the normalized URL origin.+ * Ensure a proxy is available. Returns the normalized URL origin.*/async start(): Promise<string> {const port = this.getProxyPort();- const explicitUrl =+ const rawExplicitUrl =typeof this.config.proxyUrl === "string" && this.config.proxyUrl.trim().length > 0- ? withDefaultPort(normalizeAndValidateProxyUrl(this.config.proxyUrl), port)+ ? normalizeAndValidateProxyUrl(this.config.proxyUrl): null;+ // Only apply proxyPort default to local URLs — remote URLs use their protocol default+ const explicitUrl = rawExplicitUrl+ ? isLocalProxyUrl(rawExplicitUrl) ? withDefaultPort(rawExplicitUrl, port) : rawExplicitUrl+ : null;const defaultCandidates = this.getDefaultProxyCandidates(port);const candidateUrls = explicitUrl ? [explicitUrl] : [...defaultCandidates];const probeByUrl = new Map<string, ProxyProbeResult>();diff --git a/plugins/openclaw/test/proxy-manager.test.ts b/plugins/openclaw/test/proxy-manager.test.tsindex 383c8bb2b..ac723b191 100644--- a/plugins/openclaw/test/proxy-manager.test.ts+++ b/plugins/openclaw/test/proxy-manager.test.ts@@ -156,6 +156,20 @@ describe("ProxyManager.start", () => {expect(startSpy).not.toHaveBeenCalled();});+ it("does not apply proxyPort default to remote URLs", async () => {+ // Remote URL without port should use protocol default, not proxyPort+ const manager = new ProxyManager({ proxyUrl: "https://headroom.remote.example", proxyPort: 9999 });++ const fetchMock = vi+ .fn()+ .mockResolvedValueOnce({ ok: true, status: 200 })+ .mockResolvedValueOnce({ ok: true, status: 200 });+ vi.stubGlobal("fetch", fetchMock);++ const url = await manager.start();+ expect(url).toBe("https://headroom.remote.example");+ });+it("fails fast for unreachable remote proxy without attempting auto-start", async () => {const manager = new ProxyManager({ proxyUrl: "https://headroom.remote.example:8787", autoStart: true });const startSpy = vi.spyOn(manager as any, "startHeadroomProxy").mockResolvedValue(undefined);