Skip to content

Wire Azure AI Foundry into research-run routing (main-process)#155

Merged
blisspixel merged 1 commit into
mainfrom
feature/foundry-routing
Jul 22, 2026
Merged

Wire Azure AI Foundry into research-run routing (main-process)#155
blisspixel merged 1 commit into
mainfrom
feature/foundry-routing

Conversation

@blisspixel

Copy link
Copy Markdown
Owner

Completes the multi-cloud provider goal — Azure AI Foundry deployments now run research stages, alongside the Bedrock routing already on main. Together they deliver "meet people where they are" for AWS and Azure.

The Foundry wrinkle, solved honestly

A Foundry model id is the user's deployment name (arbitrary), so primr can't ship a fixed priced registry entry. The operator declares the deployment and its pricing via env, and nothing is guessed into the cost gate:

AZURE_OPENAI_DEPLOYMENT=<your-deployment-name>
AZURE_FOUNDRY_PRICE_AS=gpt-5.4          # price/spec as a registered model
# ...or explicit rates instead:
# AZURE_FOUNDRY_INPUT_PRICE=2.50
# AZURE_FOUNDRY_OUTPUT_PRICE=15.00
AI_REASONING_MODEL=<your-deployment-name>   # select it for a stage

PrimrModels._resolve_config centralizes model lookup so get_model_config, get_price, and the cost-breakdown paths all resolve the declared deployment. If pricing isn't declared, the lookup returns None → the cost gate fails closed (unknown model) rather than mispricing a run.

Security boundary (same as Bedrock)

Main-process only. Foundry routing is refused inside a supervised MCP worker (Azure creds are never inherited); the guard and allowlist regression pin already cover foundry from the Bedrock change.

Verified — $0

  • tests/test_ai/test_foundry_routing.py (6): price-as + explicit pricing resolve; fail-closed without pricing; only the declared deployment name resolves; routing returns AzureFoundryProvider in-process; refused in a worker.
  • Affected suites (config, cost estimator, routing, llm dispatch, stage routing, provider foundation, cost properties, architecture): 378 passed; ruff + mypy clean; doc-link test green.
  • Docs updated: .env.example, the Foundry deploy README (corrected the "not yet wired" note), CHANGELOG.

After this merges, I'll cut 1.38.0 with both Bedrock + Foundry.

A Foundry model id is a per-user deployment name, so a fixed priced registry
entry cannot be shipped. Instead the operator declares the deployment and its
pricing via env, and primr resolves it at lookup time:

- AZURE_OPENAI_DEPLOYMENT names the deployment (also the id selected on a stage).
- Pricing is declared, never guessed: AZURE_FOUNDRY_PRICE_AS copies a registered
  model's price/spec, or AZURE_FOUNDRY_INPUT_PRICE/OUTPUT_PRICE set explicit
  rates. Without a declaration the lookup returns None, so the cost gate fails
  closed rather than mispricing a run.

Centralized model lookup through PrimrModels._resolve_config so get_model_config,
get_price, and the cost-breakdown paths all resolve the declared deployment.
Routing (get_provider_for_model) and the supervised-worker guard already handle
provider=foundry from the Bedrock change. Verified with mocked tests (no spend).
@blisspixel
blisspixel merged commit c0d4943 into main Jul 22, 2026
10 checks passed
@blisspixel
blisspixel deleted the feature/foundry-routing branch July 22, 2026 16:03
@blisspixel blisspixel mentioned this pull request Jul 22, 2026
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