fix: remove duplicate API key + model selection in spawn_agent() (#1462)

Steps 3-4 (get_or_prompt_api_key and model selection) were executed
twice in spawn_agent() -- once before provisioning and once after.
This caused redundant HTTP validation calls to openrouter.ai/api for
every agent deployment (~130+ scripts use spawn_agent). The duplicate
step numbering in comments (3,4,5 then 4,5,6) confirms this was
accidental.

Agent: code-health

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
A 2026-02-19 03:23:55 -08:00 committed by GitHub
parent be904cbe1c
commit b603e05043
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1720,15 +1720,7 @@ spawn_agent() {
server_name=$(get_server_name)
cloud_provision "${server_name}"
# 4. Get API key while server provisions (overlaps with cloud-init)
get_or_prompt_api_key
# 5. Model selection while server provisions (if agent needs it)
if [[ -n "${AGENT_MODEL_PROMPT:-}" ]]; then
MODEL_ID=$(get_model_id_interactive "${AGENT_MODEL_DEFAULT:-openrouter/auto}" "${agent_name}") || exit 1
fi
# 6. Wait for readiness (may already be done after OAuth)
# 6. Wait for readiness
cloud_wait_ready
# 7. Install agent