6 Commits

Author SHA1 Message Date
Henrik Jess Nielsen
afa1c03d5a fix(deploy): lower CPU reservation back to 500 to fit autobox
autobox has ~580 MHz free; cpu=1000 could not be placed during rolling
replacement. CPU reservation is a scheduling floor (procs still burst on idle
cores), so 500 is enough for the batch scoring work. Memory stays at 1024.
2026-10-29 22:23:19 +01:00
d6806f386f Merge pull request 'fix(score): strip ANTHROPIC_API_KEY from CLI subprocess env' (#3) from fix/cli-oauth-env into main
Some checks failed
Build and Deploy BlaaAi / build-and-deploy (push) Has been cancelled
Reviewed-on: #3
2026-10-29 22:15:21 +01:00
Henrik Jess Nielsen
1171d965e8 fix(score): strip ANTHROPIC_API_KEY from CLI subprocess env
With ANTHROPIC_API_KEY also present in the environment, the claude CLI does
API-key auth and ignores CLAUDE_CODE_OAUTH_TOKEN, failing with 401 Invalid API
key when that key is invalid/out of credit. Strip it from the subprocess env so
the subscription token is used; the api backend still reads it from os.environ.
2026-10-29 22:12:24 +01:00
2925d86447 Merge pull request 'fix(deploy): match Consul key name for Claude auth token' (#2) from fix/claude-auth-consul-key into main
All checks were successful
Build and Deploy BlaaAi / build-and-deploy (push) Successful in 5m21s
Reviewed-on: #2
2026-10-29 22:01:47 +01:00
Henrik Jess Nielsen
ce9c968301 fix(deploy): match Consul key name for Claude auth token
The Nomad template read blaaai/claude_oauth_token but the token was stored
at blaaai/claude_auth_token, so CLAUDE_CODE_OAUTH_TOKEN rendered empty and
CLI auth failed in prod.
2026-10-29 22:00:43 +01:00
db8b4d0406 Merge pull request 'feat(score): add Claude CLI backend via subscription token' (#1) from feat/claude-cli-backend into main
Some checks failed
Build and Deploy BlaaAi / build-and-deploy (push) Has been cancelled
Reviewed-on: #1
2026-10-29 21:59:35 +01:00
2 changed files with 9 additions and 3 deletions

View File

@@ -110,7 +110,7 @@ job "blaaai" {
template {
data = <<EOT
# Subscription auth for the claude CLI (generate with `claude setup-token`)
CLAUDE_CODE_OAUTH_TOKEN={{ key "blaaai/claude_oauth_token" }}
CLAUDE_CODE_OAUTH_TOKEN={{ key "blaaai/claude_auth_token" }}
# Kept for BLAAAI_BACKEND=api fallback
ANTHROPIC_API_KEY={{ key "blaaai/anthropic_api_key" }}
HARBOR_ROBOT_TOKEN={{ key "blaaai/harbor_robot_token" }}
@@ -120,7 +120,7 @@ EOT
}
resources {
cpu = 1000
cpu = 500 # autobox CPU is nearly full; reservation is a floor, procs still burst
memory = 1024 # claude CLI (Node) + chromium need more headroom than the API client
}
}

View File

@@ -88,9 +88,15 @@ def _call_cli(prompt: str) -> tuple[str, int, int, float]:
"--max-turns", str(CLI_MAX_TURNS),
"--disallowed-tools", "Bash,Edit,Write,Read,WebSearch,WebFetch",
]
# ANTHROPIC_API_KEY in the env takes precedence over the OAuth token and makes
# the CLI do API-key auth (401 "Invalid API key"). Strip it so the subscription
# token is used; the api backend still sees it via os.environ.
cli_env = {k: v for k, v in os.environ.items() if k != "ANTHROPIC_API_KEY"}
last_err = ""
for attempt in range(CLI_RETRIES):
proc = subprocess.run(cmd, input=prompt, capture_output=True, text=True, timeout=CLI_TIMEOUT)
proc = subprocess.run(cmd, input=prompt, capture_output=True, text=True,
timeout=CLI_TIMEOUT, env=cli_env)
if proc.returncode != 0 or not proc.stdout.strip():
last_err = f"exit {proc.returncode}: {(proc.stderr or proc.stdout)[:300]}"
continue