fix(api): keep prompt input_keys when projecting evaluation inputs#4807
fix(api): keep prompt input_keys when projecting evaluation inputs#4807jayjcoding wants to merge 2 commits into
Conversation
|
@jayjcoding is attempting to deploy a commit to the agenta projects Team on Vercel. A member of the Team first needs to authorize it. |
|
✅ Thanks @jayjcoding! This PR now meets the contribution requirements and has been reopened. A maintainer will review it soon. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Disabled knowledge base sources:
📝 WalkthroughSummary by CodeRabbit
Walkthrough
ChangesInput projection fix: preserve prompt template variables
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Running an evaluation against a testset fails on every row when the target is a
builtin prompt/chat workflow whose template variable is not a declared structural
input. The application step returns HTTP 400:
Invalid inputs:\nExpected '['context']'\nGot ('list') '[]'.(type
v0:schemas:invalid-inputs)Root cause:
_project_inputsinapi/oss/src/core/evaluations/runtime/adapters.pyfilters each testcase row down tothe keys in
data.schemas.inputs.propertiesbefore invoking the workflow (to dropbookkeeping columns like
correct_answer/testcase_id). For builtin promptworkflows that schema declares only the structural inputs (e.g.
messagesforchat:v0), not the prompt template variables (e.g.context) — which live inparameters.prompt.input_keysand are whatcompletion_v0/chat_v0actuallyvalidate against. So the projection strips
context, the workflow is invoked with{}, and validation fails.Fix: widen the projection allow-list to the union of the schema's property keys
and the prompt's declared
input_keys, so a template variable absent from the schemais no longer dropped. Bookkeeping columns are still removed; the no-schema
pass-through path is unchanged (untyped/legacy revisions unaffected).
Testing
Verified locally
Reproduced on a self-hosted OSS stack: a
chatapp whose prompt uses{{context}},evaluated against a testset with a
contextcolumn. Before the change theapplication step fails with
Invalid inputs: Expected ['context'] Got []; after thechange
contextflows through and the app proceeds to the model call.Added or updated tests
Added
api/oss/tests/pytest/unit/evaluations/test_project_inputs.pycovering thechat-app case (schema declares only
messages, prompt needscontext), thebookkeeping-column drop, and the no-schema pass-through. All pass.
QA follow-up
N/A
Demo
Before the change

After the change

Checklist