Skip to content

fix(runtime): auto-derive AZURE_OPENAI_ENDPOINT from project endpoint#222

Merged
placerda merged 1 commit into
developfrom
fix/derive-azure-openai-endpoint
Jun 1, 2026
Merged

fix(runtime): auto-derive AZURE_OPENAI_ENDPOINT from project endpoint#222
placerda merged 1 commit into
developfrom
fix/derive-azure-openai-endpoint

Conversation

@placerda
Copy link
Copy Markdown
Contributor

@placerda placerda commented Jun 1, 2026

Why

While recording the prompt-agent tutorial, agentops eval run in local
execution mode failed on step 17 with::

Error: evaluation failed: AI-assisted evaluators require an evaluator
model. Missing environment variables: AZURE_OPENAI_ENDPOINT

The workspace had been created with agentops init and had a valid
AZURE_AI_FOUNDRY_PROJECT_ENDPOINT in .azure/sandbox/.env — exactly
the case CONTRIBUTING.md and the env-var docs claim is supported via
"auto-derived from the project endpoint when absent". The runtime never
honored that promise: pipeline/runtime.py::_model_config only read the
explicit env var with no fallback.

What changed

  • Added derive_openai_endpoint_from_project() in
    utils/azure_endpoints.py. The helper trims the trailing
    /api/projects/<name> segment from a Foundry project URL — covering
    both services.ai.azure.com and the legacy
    cognitiveservices.azure.com hosts — to recover the AI Services
    account base URL.
  • _model_config now uses the derived value as a fallback whenever
    AZURE_OPENAI_ENDPOINT is unset, finally matching the documented
    behavior.
  • When AZURE_OPENAI_DEPLOYMENT is the only thing missing, the error
    message now points users at the deployment list in the Foundry portal
    and mentions the execution: cloud escape hatch in
    agentops.yaml so the next step is obvious without leaving the
    terminal.

Tests

  • New helper covered in tests/unit/test_azure_endpoints.py (Foundry
    host, legacy host, project name with hyphens, case-insensitive match,
    pass-through cases, base URL that already carries the OpenAI suffix).

  • New tests/unit/test_runtime_model_config.py covers explicit
    endpoint wins, project-endpoint auto-derive, missing-deployment error
    with hint, missing-both error, default and overridden API version.

  • Full suite::

    python -m pytest tests/ -x -q
    833 passed, 1 skipped in 96.06s

Follow-up (not in this PR)

The original tutorial failure escalated into a second issue: even after
unblocking the run via execution: cloud, the Foundry grader returned
PermissionDenied because creating a Foundry project does not grant
the caller the OpenAI data-plane RBAC on the AI Services account. Doctor
should detect that pre-run; tracking separately so this PR stays
focused on the documented-but-not-implemented auto-derive.

CONTRIBUTING.md and the env-var docs both state that AZURE_OPENAI_ENDPOINT
is auto-derived from the Foundry project endpoint when absent, but
pipeline/runtime.py::_model_config only read AZURE_OPENAI_ENDPOINT with no
fallback. A fresh workspace created by `agentops init` (which writes
AZURE_AI_FOUNDRY_PROJECT_ENDPOINT but not AZURE_OPENAI_ENDPOINT) therefore
always tripped 'Missing environment variables: AZURE_OPENAI_ENDPOINT' the
first time AI-assisted evaluators tried to run locally.

Adds derive_openai_endpoint_from_project() in utils/azure_endpoints.py that
trims the trailing /api/projects/<name> segment to recover the AI Services
account base URL. _model_config uses it as a fallback, restoring the
documented behavior. The missing-deployment error also now nudges users
toward the Foundry deployments list and the execution: cloud escape hatch
so the next step is obvious without leaving the terminal.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@placerda placerda merged commit eaca229 into develop Jun 1, 2026
12 checks passed
@placerda placerda deleted the fix/derive-azure-openai-endpoint branch June 1, 2026 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant