Skip to content

Honor OPENAI_BASE_URL/ANTHROPIC_BASE_URL in all SDK constructors + route through sluice #33

@JustAGhosT

Description

@JustAGhosT

Summary

Audit on 2026-05-01 found codeflow-engine's main provider abstraction correctly reads OPENAI_BASE_URL and ANTHROPIC_BASE_URL from env, but two action paths bypass that abstraction and construct SDK clients without a base_url argument, so they always go direct to providers regardless of env.

Evidence

Gateway-capable (good)

  • engine/codeflow_engine/ai/core/providers/manager.py:40,60 — reads OPENAI_BASE_URL and ANTHROPIC_BASE_URL from env
  • engine/codeflow_engine/actions/llm/__init__.py:101 — passes OPENAI_API_BASE to provider
  • engine/codeflow_engine/actions/llm/providers/openai.py:19openai.OpenAI(api_key, base_url=self.base_url) (override-aware)
  • desktop/src/schema.json:387,421 — UI schema exposes OPENAI_BASE_URL and ANTHROPIC_BASE_URL settings

Bypass-prone (bad)

  • engine/codeflow_engine/actions/ai_comment_analyzer.py:43openai.OpenAI(api_key=os.getenv("OPENAI_API_KEY")) — no base_url, always direct
  • engine/codeflow_engine/actions/llm/providers/anthropic.py:19anthropic.Anthropic(...) constructed without base URL override
  • engine/codeflow_engine/actions/llm/providers/azure_openai.py:51AzureOpenAI(...) reads AZURE_OPENAI_ENDPOINT directly
  • engine/codeflow_engine/ai/core/providers/manager.py:40,60 — defaults: https://api.openai.com/v1, https://api.anthropic.com
  • tools/quality/production_monitoring.py:18 — hardcoded default https://api.openai.com/v1
  • Zero references to sluice, vkey-, or azurecontainerapps.io anywhere in code

Suggested fix

  1. Code: make ai_comment_analyzer.py:43 and anthropic.py:19 honor OPENAI_BASE_URL / ANTHROPIC_BASE_URL env vars, matching the pattern in openai.py:19.
  2. Config: set OPENAI_BASE_URL=https://pvc-prod-sluice-ca.<region>.azurecontainerapps.io/v1 and ANTHROPIC_BASE_URL=https://pvc-prod-sluice-ca.<region>.azurecontainerapps.io in docker-compose.yml and any K8s manifests.
  3. Docs: document sluice as the recommended endpoint in ENVIRONMENT_VARIABLES.md. Use the vkey-codeflow-engine virtual key already issued in pvc-prod-sluice-kv.

See sluice ADR 09 for the keys table and sluice/AGENTS.md routing section for the env-var pattern.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions