crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

[FEATURE] Build an offline Jev routing and guardrail evaluation runner

Open lorenzejay opened this issue 1 month ago • 7 comments

Python PR scope

Write a small Python evaluation runner for labeled routing/guardrail records and recorded or fake decisions. Report accuracy, route coverage/abstention, guardrail false accepts/rejects, and recorded latency/usage when available.

Difficulty: medium. Allocation index: #8118. Project: #8065.

Cohort allocation

This ticket is reserved for maintainer-coordinated allocation to the Stanford semester collaboration. Please wait for @lorenzejay to confirm an assignee before implementing. A comment expresses interest; it does not establish ownership. Public good first issue / help wanted discovery labels will be considered after cohort allocation.

GitHub usernames have not yet been supplied, so no individual assignment is implied.

Acceptance criteria

  • [ ] Use a simple JSON/JSONL dataset and deterministic synthetic decisions for a runnable offline mode.
  • [ ] Treat Jev Choice confidence and Noul probability as separate fields; evaluate thresholds without converting one into the other.
  • [ ] Handle missing decisions explicitly in metrics; do not count failed evaluations as correct answers.
  • [ ] Add tests for metric denominators, threshold boundaries, missing records, and invalid inputs.
  • [ ] Make live SDK calls opt-in with explicit credentials and report measured results rather than vendor speed claims.

Dependencies and coordination

  • Offline implementation can start independently. Coordinate recorded-result shape with #8066 and #8068.

Starting points

Submission

The contributor implements this scope and submits one focused PR linked to this open issue. Include full Python annotations, behavioral tests, and relevant quality checks. No paid API calls are required for the tests. Preserve existing APIs outside the scoped feature. For newly found defects, reproduce them and check active issues/PRs before fixing them. Docs edits, when needed, belong under docs/edge/ and must sync ar, ko, pt-BR per DOCS_TRANSLATIONS.md. Follow .github/CONTRIBUTING.md. Issue prepared with AI assistance.

lorenzejay avatar Oct 13 '26 22:10 lorenzejay

I can do this one. Thank you Lorenze!

bballhaus avatar Oct 15 '26 23:10 bballhaus

Thanks for the assignment, @lorenzejay! I opened a PR alongside this comment, and there are a few choices I want to confirm with you.

What it is: an offline evaluation module at crewai_tools/tools/jev_evaluation/. It loads labeled routing and guardrail records from JSON or JSONL, classifies each one as decided, abstained or failed, and reports accuracy, coverage and abstention, false accepts and false rejects (with their denominators), and recorded usage and latency.

Choices that would mean rework if wrong:

  1. I used a new tools/jev_evaluation/ package, because #8076's jev_decision_tool/ isn't on main yet. Should it move there once #8076 merges, or somewhere else?
  2. Records mirror the SDK: choice, confidence and probabilities for Choice, and noul for Noul, plus optional model, usage and latency_ms. Does that work for you, @ketpatil77 and @PRINCE2-AI?
  3. Missing, malformed or errored decisions count as failed: never correct or accepted, and left out of the false-accept and false-reject denominators. They're reported as their own count, not as rejects. A choice below min_confidence is abstained, and a confident choice of any known route counts as decided. Does that match what you want?

Other defaults:

  • Inclusive >= thresholds.
  • Choice confidence and Noul probability are never converted into each other.
  • Missing token counts stay missing instead of becoming 0.
  • Latency is measured only on successful live calls.
  • Live mode is opt-in: you pass in your own client. There's no typesafe_sdk import and no pyproject.toml or uv.lock change.
  • No top-level export.

How it was built: I wrote this with an AI coding assistant (Claude Code) and reviewed every line myself. Before writing code, I checked the repo's conventions and the open Jev PRs. There are 55 offline tests, passing on Python 3.10–3.13. I also broke the threshold and denominator logic on purpose to confirm the tests catch it.

Size: about 1,100 lines, roughly half of them tests, so it'll be size/XL. I'm happy to split live collection into a follow-up if you'd prefer. The PR is up at #8230, and I'll adjust it to whatever you decide.

bballhaus avatar Oct 16 '26 16:10 bballhaus

Thanks, Brooke! I compared this with my Noul guardrail in #8095. The noul probability field and inclusive >= threshold match its valid-answer behavior, and keeping Noul probability separate from Choice confidence is consistent with my implementation.

One distinction worth documenting: #8095 returns a rejection for missing or malformed Noul answers and propagates SDK exceptions. Your evaluator instead records those cases as failed and excludes them from the false-accept/false-reject denominators. Keeping failures separate makes sense for decision-quality metrics, but those metrics should not be described as reproducing all runtime guardrail outcomes.

My guardrail also checks the answer’s type == "noul", whereas the normalized offline decision validates the noul value without requiring that discriminator. Could we document that normalization boundary and add a wrong-answer-type case for live collection?

On the Cursor finding, I checked the published typesafe-sdk 0.7.3 source: SystemOneResponse.answers is present, and nouls/choices are filtered views of it. A test using a real SDK response object would help settle that warning for the supported version.

I’m happy to coordinate the Noul contract; I’ll leave the final package location to the maintainers. This was a source-level comparison, not a live API validation.

On Fri, Oct 16, 2026 at 10:22 PM Brooke Ballhaus @.***> wrote:

bballhaus left a comment (crewAIInc/crewAI#8124) https://github.com/crewAIInc/crewAI/issues/8124#issuecomment-6220399905

Thanks for the assignment, @lorenzejay https://github.com/lorenzejay! I opened a PR alongside this comment, and there are a few choices I want to confirm with you.

What it is: an offline evaluation module at crewai_tools/tools/jev_evaluation/. It loads labeled routing and guardrail records from JSON or JSONL, classifies each one as decided, abstained or failed, and reports accuracy, coverage and abstention, false accepts and false rejects (with their denominators), and recorded usage and latency.

Choices that would mean rework if wrong:

  1. I used a new tools/jev_evaluation/ package, because #8076 https://github.com/crewAIInc/crewAI/pull/8076's jev_decision_tool/ isn't on main yet. Should it move there once #8076 https://github.com/crewAIInc/crewAI/pull/8076 merges, or somewhere else?
  2. Records mirror the SDK: choice, confidence and probabilities for Choice, and noul for Noul, plus optional model, usage and latency_ms. Does that work for you, @ketpatil77 https://github.com/ketpatil77 and @PRINCE2-AI https://github.com/PRINCE2-AI?
  3. Missing, malformed or errored decisions count as failed: never correct or accepted, and left out of the false-accept and false-reject denominators. They're reported as their own count, not as rejects. A choice below min_confidence is abstained, and a confident choice of any known route counts as decided. Does that match what you want?

Other defaults:

  • Inclusive >= thresholds.
  • Choice confidence and Noul probability are never converted into each other.
  • Missing token counts stay missing instead of becoming 0.
  • Latency is measured only on successful live calls.
  • Live mode is opt-in: you pass in your own client. There's no typesafe_sdk import and no pyproject.toml or uv.lock change.
  • No top-level export.

How it was built: I wrote this with an AI coding assistant (Claude Code) and reviewed every line myself. Before writing code, I checked the repo's conventions and the open Jev PRs. There are 55 offline tests, passing on Python 3.10–3.13. I also broke the threshold and denominator logic on purpose to confirm the tests catch it.

Size: about 1,100 lines, roughly half of them tests, so it'll be size/XL. I'm happy to split live collection into a follow-up if you'd prefer. The PR is up at #8230 https://github.com/crewAIInc/crewAI/pull/8230, and I'll adjust it to whatever you decide.

— Reply to this email directly, view it on GitHub https://github.com/crewAIInc/crewAI/issues/8124?email_source=notifications&email_token=BSYXNLDNOGSIJCJ52E7QPF35UJG3HA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMMRSGAZTSOJZGA22M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-6220399905, or unsubscribe https://github.com/notifications/unsubscribe-auth/BSYXNLG6EZ5QJQWYO7UX7L35UJG3HAVCNFSNUABFKJSXA33TNF2G64TZHM3TCMBWGAYTAOBYHNEXG43VMU5TKOBTHA3TMMZRGE4KC5QC . Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS https://github.com/notifications/mobile/ios/BSYXNLEIBKWC37PLBYUCFZL5UJG3HA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMMRSGAZTSOJZGA22M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJKTGN5XXIZLSL5UW64Y and Android https://github.com/notifications/mobile/android/BSYXNLE2W7THPYMCX66W7MT5UJG3HA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMMRSGAZTSOJZGA22M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLTGN5XXIZLSL5QW4ZDSN5UWI. Download it today! You are receiving this because you were mentioned.Message ID: @.***>

PRINCE2-AI avatar Oct 16 '26 17:10 PRINCE2-AI

@bballhaus Thanks again for coordinating this! Would you be open to me contributing alongside you to the evaluation runner in #8230? Since I worked on the Noul guardrail in #8095, I’d be happy to help with Noul compatibility tests, edge cases, or documentation—whichever would be most useful. I understand this issue is assigned to you and maintainer-coordinated, so I’d coordinate a small piece with you and @lorenzejay before starting to avoid duplicating work.

PRINCE2-AI avatar Oct 16 '26 17:10 PRINCE2-AI

Thanks @PRINCE2-AI.

Pushed 7b8aa2e to #8230:

  • The README now says these are decision-quality metrics, not a replay of runtime guardrail outcomes: a guardrail that rejects on a missing answer or SDK error would count those as rejections, while the evaluator marks them failed and leaves them out of the false-accept/false-reject rates. It also states that decisions are checked by their fields only and the answer type is not stored.
  • Added a live-collection test where the guardrail question gets a Choice answer and the route question gets a Noul answer; both evaluate as failed.

On a real SDK response test: typesafe-sdk isn't a dependency of crewai-tools and the module takes an injected client, so a test importing it would be skipped in CI. I ran collect_live_decisions on a real SystemOneResponse from typesafe-sdk 0.7.5 (one choice and one noul answer) and both decisions and the usage came through; I replied with the details on the Cursor thread in #8230. If maintainers want the SDK as a test dependency, I'm happy to add it.

Thanks for offering! Since this is scoped tightly to #8124 and the PR is already up for review, I'll keep it as is for now, but I'd appreciate your review on #8230, especially on the Noul side.

bballhaus avatar Oct 16 '26 18:10 bballhaus

@bballhaus Thanks for the update and for incorporating those changes, Brooke! That makes sense regarding the scope. I’ll take a look at #8230 and focus my review on the Noul behavior and tests, as you suggested.

PRINCE2-AI avatar Oct 16 '26 18:10 PRINCE2-AI

Thanks @PRINCE2-AI, both reproduced.

  • type="choice" with noul=0.99: fixed in d6344cb, which landed after 7b8aa2e. Collection now fails an answer whose type doesn't match the question, and the wrong-type test includes that mixed case.
  • probabilities=42: fixed in cb1bd57. A non-mapping probabilities value is now stored as returned, like choice and confidence, and the record fails at evaluation ("invalid ChoiceDecision: probabilities: Input should be a valid dictionary") instead of aborting collection. The regression test sends a malformed answer followed by a valid one and checks that the first fails and the second is still collected as correct.

bballhaus avatar Oct 16 '26 19:10 bballhaus