Resolve credentialRefs on synchronous evaluate endpoints#160
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR ensures synchronous evaluation endpoints can authenticate LLM-as-judge graders using per-request credentialRefs, by resolving secret references into the same credential ContextVar used by the async worker.
Changes:
- Added a
_resolved_credentials()async context manager to resolve + scope credentials for sync/api/evaluate*routes (including streaming task inheritance). - Plumbed
credentialRefssupport into/api/evaluate,/api/evaluate/stream,/api/evaluate/json, and/api/evaluate/json/stream. - Added API tests that assert credentials are resolved at evaluator invocation time for both multipart and JSON endpoints.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/agentevals/api/routes.py |
Adds credentialRef resolution/scoping and wires it through all sync evaluate endpoints (including streaming task creation). |
src/agentevals/api/models.py |
Extends the JSON request model to accept credentialRefs (via camelCase aliasing). |
tests/test_api.py |
Adds regression tests validating credentialRef resolution behavior across sync endpoints and error cases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The credential
ContextVarthat LLM-as-Judge graders read was populated only by the async run worker, so the synchronous/api/evaluate*paths could authenticate judges only from the process environment.This PR wires credentialRefs into all four sync endpoints (
/evaluate,/evaluate/stream,/evaluate/json,/evaluate/json/stream), mirroring the worker's set/reset pattern, so multi-trace synchronous callers can use judges too.