Skip to content

feat: add rubric_with_history multi-turn evaluator - #12

Open
sowndappan5 wants to merge 2 commits into
agentevals-dev:mainfrom
sowndappan5:feat/rubric-with-history
Open

sowndappan5 wants to merge 2 commits into
agentevals-dev:mainfrom
sowndappan5:feat/rubric-with-history

Conversation

@sowndappan5

Copy link
Copy Markdown

What it does: Grades a selected turn (turn_index or invocation_id) or every turn against rubrics using preceding turns (0..i-1) as context while excluding future turns.
Key behavior: Uses ADK's dialogue format, treats earlier user turns and sound tool outputs as proof, and treats earlier assistant text replies as context only (not factual proof).
Files included: evaluator.yaml, rubric_with_history.py, and requirements.txt (litellm>=1.0.0).

@sowndappan5

Copy link
Copy Markdown
Author

added only conversation_history and earlier turns evidence rule. matched adk's format. added pre-sample exception handling, removed .pyc. fixed typo pre-sample to per-sample. set defaults to turn index, num_samples. @krisztianfekete

@krisztianfekete krisztianfekete left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some comments, also please update the description.

<available_tools>
{{
'name': 'load_hr_data_from_file',
'description': 'Reads a data file from the company\\'s HR database into a Pandas DataFrame.'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: \\' here and \\n on L159/L232 put a literal \' and \n into the prompt, where ADK has a plain ' and a real newline. Please drop the extra backslashes to match ADK exactly.


answered_ids = {v.rubric_id for v in parsed if v.score is not None}
if any(r.rubric_id not in answered_ids for r in rubrics):
return []

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropping the whole sample when the judge skips one rubric is fine, but please mention it in the docstring so a NOT_EVALUATED with several rubrics isn't a surprise for the users.

def select_target_indices(invocations: list[InvocationData], config: dict[str, Any]) -> list[int]:
"""Resolve which invocation indices to grade (defaults to the final turn ``-1``)."""
n = len(invocations)
all_turns = bool(config.get("all_turns", False))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bool("false") is True, so all_turns: "false" grades every turn. Please require an actual bool, as turn_index already does for ints.

judge_model = str(input.config.get("judge_model") or DEFAULT_JUDGE_MODEL)
judge_base_url = input.config.get("judge_base_url") or input.config.get("base_url")
raw_samples = input.config.get("num_samples")
num_samples = DEFAULT_NUM_SAMPLES if raw_samples is None else int(raw_samples)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

num_samples: "five" raises an uncaught ValueError (same for float() on L616), so the run crashes instead of returning NOT_EVALUATED. Validate these the same way as turn_index.


samples: list[list[RubricVerdict]] = []
sample_errors: list[str] = []
for _ in range(num_samples):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The samples run one after another, so all_turns will quickly go over the 120s timeout. Consider running them concurrently with a small ThreadPoolExecutor.

sample_errors.append(f"{type(exc).__name__}: {exc}")
continue
parsed = parse_judge_response(raw_reply, rubrics)
if parsed:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replies that fail to parse are dropped without a trace. Add them to sample_errors (e.g. "unparseable judge reply") so you can see when a verdict rests on 1 of 5 samples.

status=EvalStatus.NOT_EVALUATED,
per_invocation_scores=per_invocation_scores,
details={
"error": "Judge returned no parseable rubric verdicts for the evaluated turn(s).",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If every sample raised (e.g. a 401), this message hides the cause. Include the first sample_errors entry in error.

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