MCPcopy Create free account
hub / github.com/crewAIInc/crewAI / _parse_decision

Function _parse_decision

scripts/jev_evaluation_runner.py:473–487  ·  view source on GitHub ↗

Return the validated decision, or ``None`` and the failure reason.

(
    record: RouteRecord | GuardrailRecord,
    model: type[ChoiceDecision] | type[NoulDecision],
)

Source from the content-addressed store, hash-verified

471
472
473def _parse_decision(
474 record: RouteRecord | GuardrailRecord,
475 model: type[ChoiceDecision] | type[NoulDecision],
476) -> tuple[ChoiceDecision | NoulDecision | None, str]:
477 """Return the validated decision, or ``None`` and the failure reason."""
478 if record.error is not None:
479 return None, f"recorded error: {record.error}"
480 if record.decision is None:
481 return None, "missing decision"
482 try:
483 return model.model_validate(record.decision), ""
484 except ValidationError as e:
485 first = e.errors()[0]
486 location = ".".join(str(part) for part in first["loc"]) or "decision"
487 return None, f"invalid {model.__name__}: {location}: {first['msg']}"
488
489
490def _classify_route(

Callers 2

_classify_routeFunction · 0.85
_classify_guardrailFunction · 0.85

Calls 2

joinMethod · 0.80
errorsMethod · 0.45

Tested by

no test coverage detected