Skip to content

Add built-in Foundry adapter - #6

Open
eedorenko wants to merge 17 commits into
mainfrom
eedorenko/update-foundry-adapter
Open

Add built-in Foundry adapter#6
eedorenko wants to merge 17 commits into
mainfrom
eedorenko/update-foundry-adapter

Conversation

@eedorenko

@eedorenko eedorenko commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add protocol: foundry as a built-in adapter in beval for evaluating Microsoft Foundry agents, replacing the standalone custom adapter approach.

Changes

  • python/src/beval/adapters/foundry.py — new adapter using azure-ai-projects SDK with lazy imports
  • python/src/beval/adapters/__init__.py — register "foundry" in protocol dispatch and known protocols
  • python/pyproject.toml — add foundry optional dependency group (azure-ai-projects, azure-identity); include in all extra
  • samples/foundry-agent/ — update sample to use protocol: foundry instead of protocol: custom; remove standalone adapter file

Test plan

  • uv run pytest tests/test_adapters.py -v — all 42 tests pass
  • Validated against live Foundry agent (100 cases, 98 passed)

🤖 Generated with Claude Code

eedorenko and others added 2 commits July 14, 2026 16:45
Move the Foundry agent adapter from a standalone custom adapter file
into beval as a built-in protocol (protocol: foundry). Add cortyx
eCommerce analytics cases (100 cases across 11 files) for evaluating
Foundry agents with deterministic graders.

- Add python/src/beval/adapters/foundry.py with lazy azure SDK imports
- Register "foundry" protocol in adapters/__init__.py
- Add "foundry" optional dependency group in pyproject.toml
- Update samples/foundry-agent to use protocol: foundry
- Remove standalone beval_foundry_adapter.py
- Add run.sh convenience script

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- run.sh accepts optional cases path argument (defaults to cases/cortyx)
- Update README install URL to point to current branch

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@eedorenko
eedorenko requested a review from bjcmit July 15, 2026 21:20
eedorenko and others added 2 commits July 15, 2026 14:22
Cases live in the cortyx repo (microsoft/cortyx/cases/).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Revert uv.lock changes
- Restore eval.config.yaml to standard sample config
- Clean up README to be generic (no branch-specific URLs)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@eedorenko eedorenko changed the title Add built-in Foundry adapter and cortyx eval cases Add built-in Foundry adapter Jul 15, 2026
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

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.

Pull request overview

This PR adds a first-party protocol: foundry adapter to beval so Microsoft Foundry agents can be evaluated without the standalone custom-adapter module, and updates the Foundry sample to use the built-in protocol.

Changes:

  • Added FoundryAdapter (lazy-importing azure-ai-projects/azure-identity) and registered the foundry protocol in adapter dispatch.
  • Introduced a foundry optional dependency group in pyproject.toml and included it in the all extra.
  • Updated samples/foundry-agent/ to use protocol: foundry and simplified the sample run instructions.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
samples/foundry-agent/README.md Updates sample documentation to use the built-in foundry protocol and revised setup/run instructions.
samples/foundry-agent/eval.config.yaml Switches agent definition to protocol: foundry and uses built-in connection keys.
samples/foundry-agent/agent.yaml Switches agent definition to protocol: foundry and simplifies connection config.
python/src/beval/adapters/foundry.py Adds the built-in Foundry adapter implementation using azure-ai-projects.
python/src/beval/adapters/init.py Registers foundry as a known protocol and wires it into create_adapter().
python/pyproject.toml Adds foundry extras and updates all and mypy overrides accordingly.
Comments suppressed due to low confidence (3)

python/src/beval/adapters/foundry.py:57

  • self._timeout is read from the agent definition but never applied to the Foundry/OpenAI request. As a result, timeout: in agent.yaml / eval.config.yaml has no effect and requests may hang indefinitely depending on underlying SDK defaults.
    python/src/beval/adapters/foundry.py:28
  • New built-in protocol adapter FoundryAdapter is introduced without unit tests (unlike ACP/A2A adapters). Adding tests for lazy-import failure messaging, required endpoint validation, and the basic request path (mocking the SDK client) would help prevent regressions.
    python/src/beval/adapters/foundry.py:68
  • When adapter_input.query is a message list, this code flattens it into a single string (and overwrites query). Other adapters extract the last user message instead, which avoids accidentally including assistant/system content and preserves the original query value for Subject.input. Consider using a separate query_text and extracting the last user turn.

Comment thread samples/foundry-agent/README.md
Comment thread samples/foundry-agent/README.md Outdated
eedorenko and others added 12 commits July 15, 2026 14:42
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Azure AI Foundry project endpoints use the OpenAI v1 API path
(/openai/v1/chat/completions) rather than the Azure-native path
that requires api-version query params. Without this, the judge
fails with "Missing required query parameter: api-version" or
"API version not supported".

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add effective_latency (geometric mean of time+1, capped at 100s),
p95_latency, fail_rate, keyword_recall, and accuracy_rate with
binomial standard errors to RunSummary. These metrics appear in
results.json summary when computed, and are omitted when not
applicable (backward compatible).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Bug fix for redacted keyword_recall metrics
Regex fix for keyword_recall being redacted
Strip comma thousands separators (e.g. 1,000 → 1000) from both the
keyword and the agent response before matching. This fixes false
negatives where a case expects "9786" but the agent responds with
"9,786.07".

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Strip trailing decimal zeros from both keyword and output before
matching (e.g. 104.90 → 104.9, 1.00 → 1). Combined with the existing
comma normalization, this handles all common number formatting
variations without losing meaningful precision.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When a numeric keyword isn't found literally, check if rounding the
more-precise value to the less-precise one's scale produces a match.
Works both ways: keyword 1.577 matches output 1.58, and keyword 9786
matches output 9786.07. Limited to at most 2 decimal places difference
to avoid overly aggressive matching.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The Foundry entra_id path was using plain OpenAI client with a static
bearer token baked into headers. After 60 minutes the token expired,
causing 401 errors for all remaining cases. Switch to AzureOpenAI
client with azure_ad_token_provider so tokens refresh automatically
on every request.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

2 participants