feat: SOCKS5 outbound + Claude instructions cache stabilize - #1
Open
Warexpor wants to merge 5 commits into
Open
Conversation
|
✅ Deterministic PR hygiene checks passed. |
✅ READY
Hygiene✅ Deterministic PR hygiene checks passed. |
Warexpor
marked this pull request as ready for review
September 8, 2026 16:22
OpenCode Go rejects requests without a stable session header; derive one from thread identity when present and attach it on Anthropic/Chat/Responses adapters.
Port Warexpor's SOCKS5 work from feat/outbound-socks5 onto upstream-synced main. Clash mixed-port HTTP_PROXY cannot CONNECT a SOCKS listener, so `ocx start --socks5` persists socks5:// into config.proxy and ALL_PROXY and routes HTTP(S) through a dependency-free SOCKS5 tunnel. Preserves current HTTP(S) proxy, NO_PROXY, and Mihomo fake-IP pinning behavior; Codex WS falls back to SSE when SOCKS5 is configured. Co-authored-by: Warexpor <warexpor@gmail.com>
Claude Code appends growing <total_tokens> footers (and occasional TaskCreate nudges) into system text that becomes Responses instructions. That churn collapses Muse/Go prefix cache even when tools stay stable. Strip those dynamics from instructions and append the latest notice as a trailing Responses input user message so the model still sees current budget without poisoning the cached prefix. prompt_cache_key and tools are unchanged. Co-authored-by: Warexpor <warexpor@gmail.com>
The x-opencode-session commit left tests/opencode-go-session.test.ts at the tests/ root, which the layout guard treats as a migrated-domain straggler. Move it next to the existing header coverage. Co-authored-by: Warexpor <warexpor@gmail.com>
cursor
Bot
force-pushed
the
cursor/feat-claude-instructions-cache-stabilize-0d69
branch
from
September 8, 2026 16:25
b1f43b2 to
6325b4b
Compare
Upstream dev already attaches x-opencode-session via resolveOpenCodeGoTransport (opaque ocx_ ids, HTTPS canonical destination, omit when Claude has no usable identity). The fork main helper matched http://opencode.ai/zen/go/v1 and always filled a header from session-id / first-user text, which broke routed-agent-messages and OpenCode Go session affinity tests. Co-authored-by: Warexpor <warexpor@gmail.com>
Warexpor
added a commit
that referenced
this pull request
Sep 8, 2026
Local-test land on fork main (same tip as PR #1).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This branch is for Warexpor/opencodex only. It is not the upstream PR to
lidge-jun/opencodex; that discussion is next.Upstream sync. Fork
devwas ~1560 commits behindlidge-jun/opencodexdev. It has been fast-forwarded to current upstreamdev. This PR is rebased onto that tip.SOCKS5 outbound.
feat/outbound-socks5was far behind current integration, so the work is re-applied onto today'sdevrather than a raw rebase. Semantics preserved:ocx start --socks5 [host:port](defaultsocks5://127.0.0.1:10808) writesconfig.proxyand mirrors it toALL_PROXY.--socks5-offclears only a saved SOCKS5config.proxy.config.proxystill fillsHTTP_PROXY/HTTPS_PROXYwhen unset.src/lib/socks5-fetch.ts) withNO_PROXY, auth, streaming, and abort support. Codex WS falls back to SSE while SOCKS5 is configured (Clash mixed-portHTTP_PROXYcannot CONNECT a SOCKS listener).Claude prompt-cache stabilize. Claude Code Anthropic→Responses translation puts system text into top-level
instructions. Claude Code appends growing<total_tokens>…</total_tokens>footers (and occasional TaskCreate nudges) into that system text each turn, soinstructionschurns and Muse/Go prefix cache collapses even when tools stay stable. This change strips those dynamics frominstructionsand appends the latest notice as a trailing Responsesinputuser message so the model still sees current budget without poisoning the cached prefix.toolsandprompt_cache_keylogic are unchanged.Measured in a controlled suite on Muse Spark via Go: Claude hit-rate ~0.17 → ~0.86 after this stabilize. No extra tables.
Go session header. Fork
maincarried a secondx-opencode-sessionhelper. Currentdevalready does this viaresolveOpenCodeGoTransport(opaqueocx_ids, canonical HTTPS Go destination, omit when Claude has no usable identity). The duplicate path matchedhttp://opencode.ai/zen/go/v1and always filled a header, which failed Cross-platform CI. It is dropped; the existingdevaffinity path is unchanged.Verification
After dropping the duplicate Go session helper (all pass):
bun test tests/adapters/routed-agent-messages.test.ts— pass (includeshttp://opencode.ai/zen/go/v1Go-like destination)bun test tests/providers/opencode-go-session-header.test.ts— pass (Claude omit-affinity cases included)bun test tests/ci-workflows/repo-hygiene.test.ts tests/test-layout.test.ts tests/test-layout-tooling.test.ts— pass (no duplicate basenames; layout membership agrees)bun test tests/cli/start-args.test.ts tests/server/socks5-fetch.test.ts tests/server/proxy-env.test.ts— passbun test tests/claude-integration/claude-inbound-cache-stabilize.test.ts tests/claude-integration/claude-inbound.test.ts— passbun test tests/responses/responses-fetch-helpers-boundary.test.ts— passbun test tests/responses/ws-upstream.test.ts -t "uses HTTP SSE when SOCKS5 outbound transport is configured"— passbun run typecheck— passbun run privacy:scan— passChecklist