Repository navigation
ocx claude should set ENABLE_TOOL_SEARCH=true: Claude Code disables MCP tool deferral behind a non-Anthropic base URL, so every tool schema ships in full #4838
Description
Area
Claude Code
What are you trying to accomplish?
Run Claude Code through ocx claude (opencodex 2.57.0, macOS, Claude Code with claude.ai connectors enabled) with the same footprint as a native session. My setup has 292 MCP tools from the claude.ai connectors (Canva, Notion, Zoho Books, Gmail, Drive and so on). Natively those cost almost nothing because Claude Code defers their schemas and loads them on demand through its tool search.
What prevents this today?
Claude Code turns MCP tool deferral off whenever ANTHROPIC_BASE_URL points at a non-first-party host. This is documented on the env-vars page for ANTHROPIC_BASE_URL ("When set to a non-first-party host, MCP tool search is disabled by default") and for ENABLE_TOOL_SEARCH: https://code.claude.com/docs/en/env-vars. It is keyed on the host, not the model id, so it hits every ocx claude session.
The result on my machine is that turn one of a fresh ocx claude session on gpt-6-astra arrives at the proxy at about 213k input tokens with a 1.1 MB request body before I have typed more than one line. /context inside that session shows it directly:
System prompt: 2.8k tokens
System tools: 35.6k tokens
MCP tools: 248.6k tokens (124.3%) 292 tools
Memory files: 18.2k tokens
Context: 215.5k/200k tokens (108%)
So the session is already over the context window before I have done anything, and it compacts on the first tool call. I first suspected a screenshot I had pasted, then the proxy translation, but the request log put the whole 1.1 MB on tool schemas.
What should OpenCodex do?
Have ocx claude inject ENABLE_TOOL_SEARCH=true alongside CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1, since the compatibility table in src/claude/compatibility.ts already declares tool_search, tool_reference and deferred_tools support. If injecting it by default is too aggressive, a claudeCode.toolSearch config key that defaults to on, plus a note in the Claude Code guide's troubleshooting section, would cover it. Right now the string ENABLE_TOOL_SEARCH does not appear anywhere in the package or the docs site, so there is no way to find this from opencodex itself.
Example usage or interface
ocx claude # injects ENABLE_TOOL_SEARCH=true, MCP tools drop from 248k to a few hundred tokens
or
{ "claudeCode": { "toolSearch": true } }Alternatives or workarounds
ENABLE_TOOL_SEARCH=true ocx claude works today. I have it as a shell alias. With it set, the same session starts well under the window and the connectors load on demand as they do natively. The other workaround is a strict MCP config that drops the connectors for GPT sessions only, which is a worse trade since it also loses them for the routed model.
Additional context
A related but separate thing I hit on the way: the auto-context marker only fires when a model's window is at least the auto-compact threshold, and the default threshold is 829,800, so a 272k model like gpt-6-astra never gets the [1m] row until claudeCode.autoCompactWindow is lowered by hand (240000 worked). I can file that as its own issue if you want it tracked.
Checks
- Searched existing issues (Documentation to use "tool_search"? #1872, Bare
gpt-reservegets no catalog row outside codexDesktopAuthless: tool_mode falls back to direct, ~250k tokens of inlined tool schemas at boot #3844, [Bug] Claude Code shows 200k context for native OpenAI models (gpt-5.6/5.5): model-info.ts omits contextWindow; NATIVE_GPT56_CONTEXT_WINDOW stale at 372k #1218 are the closest and are Codex-side or context-window only) - Reproduced on opencodex 2.57.0
Activity
lidge-jun commentedon Sep 16, 2026
리뷰 · 우선순위 74 / 80
이 이슈는
ocx claude로 Claude Code를 띄울 때 생기는 MCP 도구 스키마 폭발을 다룹니다. 지금devHEAD(6ed8986c6, #4835 테스트 재활성 직후)에서도 같은 구조입니다.ocx claude는 프록시를 쓰려고ANTHROPIC_BASE_URL을 로컬/관리 주소로 바꿉니다. Claude Code 쪽 문서는 그 주소가 Anthropic 공식 호스트가 아니면 MCP tool search(도구 스키마 지연 로딩)를 기본으로 끕니다. 그래서 connector가 많으면(이슈 작성자 기준 292개) 첫 턴 요청이 도구 스키마만으로 수십만 토큰·메가바이트급이 되고, 창을 넘긴 채 시작됩니다.중요한 점은 이게 모델 id 문제가 아니라 베이스 URL 호스트 문제라는 것입니다.
gpt-6-astra로 가도, 공식 Claude 모델로 가도,ocx claude가 non-first-partyANTHROPIC_BASE_URL을 심는 한 같은 함정에 빠집니다. 작성자가 이미 확인한 우회는 셸에서ENABLE_TOOL_SEARCH=true ocx claude입니다. 켜면 네이티브처럼 도구를 필요할 때만 불러오고, 첫 턴 컨텍스트가 정상 구간으로 돌아옵니다.현재 코드와 이슈 주장이 정확히 맞습니다.
src/claude/compatibility.ts의 FEATURES 테이블은 이미tool_search/tool_reference/deferred_tools를true로 적어 두었습니다. 즉 프록시가 그 기능을 받을 수 있다고 스스로 선언해 둔 상태입니다. 그런데src/cli/claude.ts의 런처 env 주입부는CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1같은 게이트웨이 플래그는setDefault로 넣고,ENABLE_TOOL_SEARCH문자열은 패키지 어디에도 없습니다. 그래서 문서·코드·트러블슈팅에서 이 스위치를 찾을 길이 없고, 사용자가 Claude 쪽 env-vars 문서를 직접 파야만 합니다.고치는 자리는 좁습니다.
src/cli/claude.ts에서setDefault("CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY", "1");근처(대략 340행대)에setDefault("ENABLE_TOOL_SEARCH", "true");를 같은 패턴으로 넣으면, 사용자가 이미 export한 값은 그대로 이기고 기본만 켜집니다. 기본 on이 부담이면src/types/config.ts의OcxClaudeCodeConfig에toolSearch?: boolean(기본 true)을 추가하고,false일 때만 주입을 건너뛰면 됩니다. 관리 API/agent-settings-routes에 노출할지는 선택입니다. 가이드 트러블슈팅에 한 줄(“MCP 도구가 전부 실리면ENABLE_TOOL_SEARCH”)만 있어도 검색 가능 여부가 달라집니다.추가로,
NATIVE_STRIPPED_LEVERS(src/cli/claude.ts545행대)는 native 라우팅 오프 시 걷어내는 env 목록입니다.ENABLE_TOOL_SEARCH를 기본 주입한다면 native strip 목록에 넣을지도 같이 정해야 합니다. native는 first-party 베이스를 쓰는 경로라 Claude 기본값이 이미 tool search를 켜 둘 가능성이 커서, strip 여부는 동작보다 계약 일관성 문제에 가깝습니다.이슈 본문 하단의
[1m]/autoCompactWindow이야기는 별건으로 보는 게 맞습니다.src/claude/context-windows.ts의AUTO_COMPACT_WINDOW_DEFAULT는 829_800이고, auto-context 마커는 “권위 있는 창 > 200k 그리고 compact window 이상”일 때만 붙습니다. 272k급 모델은 기본 compact(829_800)보다 작아서[1m]행이 안 나오고, 작성자가claudeCode.autoCompactWindow를 240000으로 낮춰 우회한 것과 일치합니다. 그건 tool search 주입과 원인·수정면이 다르니 이 이슈에 묶지 말고 후속 이슈로 빼는 편이 리뷰·랜딩이 깔끔합니다.라인 / 경로
src/cli/claude.ts ~340 - CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY만 setDefault하고 ENABLE_TOOL_SEARCH는 없음. non-first-party ANTHROPIC_BASE_URL과 맞물려 MCP 전체 스키마가 실림
src/cli/claude.ts ~214 - ANTHROPIC_BASE_URL을 managedBaseUrl로 강제. Claude Code가 tool search를 끄는 직접 트리거
src/claude/compatibility.ts 13-15 - tool_search / tool_reference / deferred_tools를 true로 선언했지만 런처 env와 불일치
src/types/config.ts OcxClaudeCodeConfig - toolSearch(또는 동등) 키 없음. 기본 on/opt-out을 설정으로 열고 싶으면 여기가 자리
src/cli/claude.ts NATIVE_STRIPPED_LEVERS ~545 - 새 env를 넣을 때 native 경로 strip 계약 정리 필요
src/claude/context-windows.ts AUTO_COMPACT_WINDOW_DEFAULT 829_800 - 본문 부가 증상([1m] 미표시)의 원인. 이 이슈 범위 밖, 후속 추천
메인테이너의 판단이 필요한 지점
claudeCode.toolSearch같은 설정(기본 on)으로 둘지너의 추천
작은 PR로
src/cli/claude.ts에setDefault("ENABLE_TOOL_SEARCH", "true")를 게이트웨이 discovery 옆에 넣고, Claude Code 가이드 트러블슈팅에 한 줄 추가하세요. 설정 키가 필요하면 기본 true의claudeCode.toolSearch만 최소로. CI 그린이면dev에 바로 머지해도 되는 고립된 CLI 개선입니다(types/config 대분할에 막히지 않음).[1m]/compact 기본값 이야기는 별 이슈로 분리하세요.이 댓글은 grok-bot이 작성했습니다
feat(claude): opt-in ENABLE_TOOL_SEARCH injection for launched Claude…
lidge-jun commentedon Sep 18, 2026
Shipped on
devby #5029, squashed as823f65eb07370eeac5812feb45b68dd08cd8fbe1— but as an opt-in setting rather than the unconditional default you asked for, and the reason is worth more than the feature.The variable is the right lever. Established from the installed Claude Code binary rather than from documentation: the gate is exactly
ENABLE_TOOL_SEARCH, it is keyed on the host, and its own log line says so — "disabled: ANTHROPIC_BASE_URL=... is not a first-party Anthropic host. Set ENABLE_TOOL_SEARCH=true (or auto / auto:N) if your proxy forwards tool_reference blocks." Accepted values aretrue/auto/auto:N/force.But the premise needs correcting, and it changes the answer. Deferral is a server-side context optimisation, not a smaller request. Claude Code's deferred-tool predicate still requires
input_schemanext todefer_loading: true, so all 292 schemas stay on the wire either way.And the compatibility table says the opposite of what the report reads it as saying.
src/claude/compatibility.tsliststool_search,tool_referenceanddeferred_toolsas unsupported, andcompatibleis computed as "no detected feature is flagged" — so atrueentry means "would reject". On a translated routetoolsToResponseskeeps every tool with aninput_schemaas a full function tool, ignoresdefer_loading, and drops thetool_search_tool_*server tool.So setting it unconditionally would have made Claude Code believe its context was nearly empty and stop compacting, while the provider still received every schema — and under
claudeCode.compatibilityset to enforce it would have been a hard 400. That is a worse failure than the one reported, and it would have looked like a proxy bug to you.On native Anthropic passthrough the body is untouched and it works exactly as you described, which is why this ships as
claudeCode.toolSearchrather than not at all. It is injected by the three launch surfaces that already carry the other Claude levers, all user-wins, so your own export still overrides it. Absent or false injects nothing rather thanfalse.Shipping in the next release off
dev.