Skip to content

Add isolated Azure Foundry provider for decision models - #11363

Merged
lpcox merged 5 commits into
mainfrom
copilot/awf-api-proxy-support-decision-models
Nov 9, 2026
Merged

lpcox merged 5 commits into
mainfrom
copilot/awf-api-proxy-support-decision-models

Conversation

Copilot AI commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Classification-only workflows currently require manual Foundry authentication and firewall configuration, outside AWF’s credential isolation and usage accounting. This adds an optional provider for native decision and OpenAI-compatible endpoints.

  • Provider: Port 10005; preserves native Decision-1 payloads and paths without startup inference or model discovery.
  • Credential isolation: Injects FOUNDRY_API_KEY or FOUNDRY_ENTRA_TOKEN from the sidecar; rewrites agent routing and allowlists the configured resource hostname.
  • Accounting: Records usage, including zero-output-token calls, and counts decisions toward maxRuns. AI-credit totals use configured catalog or fallback pricing.
  • Scope: Confidence gates and decision frontmatter remain compiler-owned; Entra token acquisition and refresh remain caller-owned.

With Foundry credentials configured on the host, sandboxed callers need no authentication header:

curl "$FOUNDRY_BASE_URL/providers/microsoft/v1/systemone" \
  -H 'Content-Type: application/json' \
  --data-binary @decision-request.json

Copilot AI changed the title [WIP] Add support for decision models in api-proxy Add isolated Azure Foundry provider for decision models Nov 9, 2026
Copilot AI requested a review from lpcox November 9, 2026 14:51
@lpcox
lpcox marked this pull request as ready for review November 9, 2026 14:53
Copilot AI adaptive review requested due to automatic review settings November 9, 2026 14:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Foundry credentials remain accessible through shared mounts and leak into the enclave proxy, while relative decision requests bypass run-limit accounting and CLI-supplied targets miss allowlisting.

4 open issues
What changed in this PR

Adds Azure Foundry support to AWF’s API-proxy architecture so decision-model and OpenAI-compatible calls can use sidecar-held credentials and usage accounting.

Changes:

  • Adds an optional Foundry adapter on port 10005, preserving native request paths and bodies without startup inference probes.
  • Integrates credentials, agent routing, resource allowlisting, and sandbox network policy.
  • Extends decision accounting coverage and documents authentication and pricing configuration.
File Description
src/​types/​ports.ts Exports the Foundry proxy port.
src/​types/​api-proxy-credential-options.ts Documents Foundry endpoints and credentials.
src/​services/​foundry-provider.test.ts Covers host configuration and credential separation.
src/​services/​api-proxy-service-split.test.ts Adds the Foundry endpoint expectation.
src/​services/​api-proxy-env-config.ts Builds Foundry target and credential environment values.
src/​services/​api-proxy-credential-env.ts Sets the agent’s Foundry base URL.
src/​services/​agent-environment/​excluded-vars.ts Excludes Foundry credentials from agent environment passthrough.
src/​microvm/​network.test.ts Adds Foundry to network-policy expectations.
src/​config/​sandbox-network-policy.json Defines the discrete Foundry sidecar port.
src/​config/​network-policy.ts Parses and validates the Foundry port.
src/​config/​network-policy.test.ts Verifies Foundry policy and port mappings.
src/​config/​network-policy-validation.test.ts Updates the validation fixture with Foundry.
src/​commands/​preflight.ts Resolves the Foundry resource for allowlisting.
src/​api-proxy-env-constants.ts Exports shared Foundry environment names.
src/​api-proxy-env-constants-sync.test.ts Verifies shared Foundry constants stay synchronized.
src/​api-proxy-config-domains.ts Adds the configured Foundry resource to allowed domains.
docs/​environment.md Explains Foundry setup, requests, and pricing.
docs/​auth-matrix.md Documents Foundry authentication and credential precedence.
containers/​api-proxy/​upstream-log.test.js Covers native decision invocation recognition.
containers/​api-proxy/​upstream-log.js Adds the native decision path to invocation classification.
containers/​api-proxy/​server.target-ports.test.js Includes Foundry in custom target-port coverage.
containers/​api-proxy/​server.network.test.js Updates endpoint reflection expectations.
containers/​api-proxy/​server.models.test.js Includes Foundry in provider metadata expectations.
containers/​api-proxy/​server.foundry.test.js Covers HTTP forwarding and persisted usage accounting.
containers/​api-proxy/​providers/​index.test.js Verifies Foundry adapter registration.
containers/​api-proxy/​providers/​index.js Registers the Foundry adapter factory.
containers/​api-proxy/​providers/​foundry.test.js Tests activation, authentication, and path handling.
containers/​api-proxy/​providers/​foundry.js Implements the optional Foundry adapter.
containers/​api-proxy/​provider-env-constants.json Defines Foundry environment-variable names.
containers/​api-proxy/​Dockerfile Exposes port 10005.

Review effort: Max (auto)

'/responses',
'/v1/decisions',
'/decisions',
'/providers/microsoft/v1/systemone',

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 81df020: max-runs accounting now checks the resolved upstream path, with regressions for both full-path and prefix-relative decision requests.

Comment thread src/services/api-proxy-env-config.ts Outdated
Comment on lines +162 to +163
const foundryApiKey = getConfigEnvValue(config, FOUNDRY_ENV.KEY) ?? process.env[FOUNDRY_ENV.KEY]?.trim();
const foundryEntraToken = getConfigEnvValue(config, FOUNDRY_ENV.ENTRA_TOKEN) ?? process.env[FOUNDRY_ENV.ENTRA_TOKEN]?.trim();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 81df020: credential-bearing Foundry env files are masked via /dev/null overlays at exposed bind and chroot aliases; a compose-mount regression covers the /tmp aliases.

Comment thread src/services/api-proxy-env-config.ts Outdated
Comment on lines +170 to +171
...(foundryApiKey && { [FOUNDRY_ENV.KEY]: foundryApiKey }),
...(foundryEntraToken && { [FOUNDRY_ENV.ENTRA_TOKEN]: foundryEntraToken }),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 81df020: the enclave API proxy now strips Foundry credentials, target, and base path regardless of its selected provider route; regression coverage verifies all four settings are absent.

Comment thread src/commands/preflight.ts
Comment on lines +218 to +220
FOUNDRY_API_TARGET: additionalEnv?.['FOUNDRY_API_TARGET']
?? envFileValues['FOUNDRY_API_TARGET']
?? process.env.FOUNDRY_API_TARGET,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 81df020: preflight parses options.env and uses the CLI Foundry target for allowlisting; the regression uses the raw env: ['FOUNDRY_API_TARGET=...'] options shape.

@lpcox

lpcox commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

@copilot address all review feedback

@lpcox

lpcox commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

@copilot merge main and resolve conflicts

…-support-decision-models

# Conflicts:
#	src/services/api-proxy-env-config.ts

Copilot AI commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor Author

@copilot address all review feedback

All four review items were addressed in 81df020; the branch is now merged with main in f2c9226.

@copilot merge main and resolve conflicts

Merged main and resolved the upstream-target conflict in f2c9226, preserving the Foundry target and trusted-service routing metadata.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

✅ Copilot review passed with no inline comments.

@copilot Add the ready-for-aw label to this PR to trigger agentic CI smoke tests.

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Documentation Preview

Documentation has been built for this PR.

Download preview artifact

To view locally:

  1. Download the docs-preview-pr-11363 artifact from the workflow run
  2. Unzip and open index.html in your browser

Built from commit 3d00fcf

port: 10005,
alwaysBind: false,
isEnabled: () => configured,
getAuthHeaders: () => entraToken
const entraToken = (env[FOUNDRY_ENV.ENTRA_TOKEN] || '').trim();
const configured = !!rawTarget && !!(entraToken || apiKey);

return buildProviderAdapter({
@lpcox

lpcox commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

@copilot address all review feedback

Copilot AI commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@copilot address all review feedback

Addressed both security findings in ac5790e: Foundry now requires an API key and ignores Entra tokens; only POST inference routes are forwarded, with HTTP/WebSocket enforcement before credential acquisition. Native and prefix-relative decisions remain supported. All 4,044 proxy tests and 59 host/enclave tests passed; build, lint, and secret scan passed. CodeQL was attempted but skipped analysis because the database is too large.

@lpcox
lpcox merged commit e3aa23e into main Nov 9, 2026
49 of 51 checks passed
@lpcox
lpcox deleted the copilot/awf-api-proxy-support-decision-models branch November 9, 2026 17:20
github-actions Bot added a commit that referenced this pull request Nov 14, 2026
…ce in NET-003

Adds provenance for PR #11345 (trusted LLM service sidecar upstream, exact
HTTPS/443 proxy-only) and PR #11363 (Azure Foundry target on the same exact
custom-port sidecar ACL path) to NET-003.

Generated consumers are intentionally not regenerated here; trusted CI or a
reviewer runs diagnostics:render.

Co-authored-by: Copilot <[email protected]>
lpcox added a commit that referenced this pull request Nov 14, 2026
…ry upstream provenance in NET-003 (#11576)

* docs(diagnostics): cite trusted-service and Foundry upstream provenance in NET-003

Adds provenance for PR #11345 (trusted LLM service sidecar upstream, exact
HTTPS/443 proxy-only) and PR #11363 (Azure Foundry target on the same exact
custom-port sidecar ACL path) to NET-003.

Generated consumers are intentionally not regenerated here; trusted CI or a
reviewer runs diagnostics:render.

Co-authored-by: Copilot <[email protected]>

* docs(diagnostics): refresh generated NET-003 consumers

Co-authored-by: copilot-swe-agent[bot] <[email protected]>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: lpcox <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
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.

[awf] api-proxy: support decision/classification models as lightweight non-generative provider

4 participants