ren worker folder adding orig, mv new one into root

This commit is contained in:
2026-09-25 10:34:29 -04:00
parent 10f0668e32
commit 5b010039d7
1308 changed files with 44597 additions and 1511 deletions

View File

@@ -43,6 +43,10 @@ _DISABLED_SUFFIX = ".snapshot-seeded-disabled"
# this beta header (the proxy's server-side alias for the suffixed id was
# dropped; the literal id now 400s and the claude CLI hangs retrying).
_CONTEXT_1M_BETA_HEADER = "anthropic-beta: context-1m-2025-08-07"
# Spelled out rather than imported from llm_proxy_env: this module ships to the
# worker toolkit, where a cross-import would fail at import time.
_CLIENT_METADATA_HEADER = "X-Surge-Client-Metadata"
_TRIAL_CALL_METADATA = '{"origin":"harbor-trial"}'
def _strip_1m_suffix(model: str) -> tuple[str, bool]:
@@ -68,6 +72,20 @@ def _with_1m_beta_header(existing: str | None) -> str:
"""Merge the 1M-context beta header into an ANTHROPIC_CUSTOM_HEADERS value."""
return _merge_custom_headers(existing, _CONTEXT_1M_BETA_HEADER)
def _with_trial_origin(existing: str | None) -> str:
"""Restate the call origin as this trial, replacing the launching surface's.
Replaces rather than appends: two values of one header name is not a
merge the proxy can read.
"""
kept = [
line
for line in (existing or "").split("\n")
if line.strip() and not line.startswith(f"{_CLIENT_METADATA_HEADER}:")
]
return "\n".join([*kept, f"{_CLIENT_METADATA_HEADER}: {_TRIAL_CALL_METADATA}"])
# Fast mode (claude's /fast), opted in per-trial via `--ak fast_mode=true`
# (harbor-run --fast). The --settings flag is the only headless opt-in, and it
# doubles as the availability override for a proxy base URL: claude probes
@@ -581,6 +599,8 @@ class SnapshotClaudeCode(PreinstalledClaudeCode):
os.environ.get("ANTHROPIC_CUSTOM_HEADERS") if on_proxy else None,
self._extra_env.get("ANTHROPIC_CUSTOM_HEADERS"),
)
if on_proxy:
header = _with_trial_origin(header)
if self.model_name:
# "[1m]" normalization happened once in PreinstalledClaudeCode.__init__
# (shared by all Claude agent classes); by here model_name is the plain