You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Attach: set ENABLE_TOOL_SEARCH=true so the gateway base URL doesn't force eager tool loading
Claude Code disables deferred tool loading whenever ANTHROPIC_BASE_URL is a
non-first-party host, sending every tool schema up front (~50k tokens of
per-session context bloat). The gateway is a pure pass-through that forwards
tool_reference blocks, so attach now sets ENABLE_TOOL_SEARCH=true to keep
deferred loading on.
Only manage the key when it is ours: a value the user set themselves is left
untouched and unrecorded, so detach never clobbers it. The core detach scopes
the prev_base_url restore to ANTHROPIC_BASE_URL only and removes any other
managed key, so it can't stamp the base URL onto ENABLE_TOOL_SEARCH.
Documents the rationale in LLP 0045.
// Keep deferred tool loading on through the gateway. Claude Code turns it off
100
+
// whenever ANTHROPIC_BASE_URL is a non-first-party host - it assumes the proxy
101
+
// cannot forward `tool_reference` blocks and so sends every tool schema up
102
+
// front, tens of thousands of tokens of per-session context bloat. Our gateway
103
+
// is a pure pass-through that does forward them, so re-enable deferred loading
104
+
// with ENABLE_TOOL_SEARCH=true. Only manage the key when it is ours to manage:
105
+
// a value the user set themselves (and that a prior marker did not record as
106
+
// ours) is left untouched so detach never clobbers it, mirroring the
107
+
// back-up/restore rule for the base URL.
108
+
// @ref LLP 0045#enable_tool_search-keep-deferred-tool-loading-on-through-the-gateway [implements]: attach sets ENABLE_TOOL_SEARCH=true so the non-first-party base URL doesn't force eager tool-schema loading
0 commit comments