feat(cortado): add multi-turn intermediate SQL execution, Set Match d… - #582
Open
erinlimbogoogle wants to merge 2 commits into
Open
feat(cortado): add multi-turn intermediate SQL execution, Set Match d…#582erinlimbogoogle wants to merge 2 commits into
erinlimbogoogle wants to merge 2 commits into
Conversation
…iffing, and tool telemetry
erinlimbogoogle
marked this pull request as ready for review
August 26, 2026 22:23
erinlimbogoogle
requested review from
IsmailMehdi,
helloeve and
prernakakkar-google
as code owners
August 26, 2026 22:23
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.
feat(cortado): add multi-turn intermediate SQL execution, Set Match diffing, and tool telemetry
Overview & Summary
This PR resolves four critical quality and telemetry gaps in EvalBench's conversational evaluation pipeline (CortadoEvaluator / AgentScoreWork) when evaluating multi-turn sessions against external
conversational data agents (e.g., Macchiato / QueryData via GrpcProxyModel):
equivalence with SetMatcher, and preserving the full sequence in turn_history.
AgentScoreWork to prevent final-turn masking.
accumulated_tools.
Key Changes
1. Orchestrator Stream Unpacking (eval_service.py)
• Dynamically unpacks orchestrator.process() whether it returns a 4-tuple or 5-tuple (job_id, run_time, results_tf, scores_tf, multi_trial_scores_tf).
2. Telemetry & Proto Metadata Propagation (grpc_proxy.py, cortadoinput.py)
• GrpcProxyModel.generate() extracts inbound_response.other and merges it into eval_output.other.
• EvalCortadoRequest retains self.other = {}, unpacks proto.other in init_from_proto(), and serializes self.other in to_proto().
3. Multi-Turn SQL Execution & Set Matching (cortadoevaluator.py)
• Structured & Plan Extraction: Implemented extract_golden_sql_for_turn() with O(1) priority lookup for native turns schemas and regex fallback for legacy conversation_plan strings.
• Tool Extraction: Added extract_tools_and_skills_from_turn() to parse action logs from macchiato_debug_info and compact tool_telemetry payloads.
• Live DB Execution: Added thread-safe BigQuery client caching (_get_db()) and executed both golden and candidate SQLs on every turn.
• Granular turn_history: Records per-turn prompts, agent responses, SQL queries, database execution results, errors, Set Match scores, and tool lists.
4. Dual Rollup Scoring Pipeline (agentscorework.py)
Replaced hardcoded empty strings and "skipped" with real execution results and SQL queries.
Automatically records:
• set_match_all_turns (100.0 if all turns with SQL passed, else 0.0)
• set_match_mean (average Set Match accuracy across SQL turns)
• set_match_turn_1, set_match_turn_2, ... in scoring_results for context-length degradation analysis.
5. Unit Test Suite (cortadoorchestrator_test.py)
Added unit tests covering:
• Golden SQL extraction (structured turns + plan regex).
• Telemetry extraction from macchiato_debug_info.
• Proto other round-trip serialization.
• Multi-turn simulated user execution loop with mock BigQuery execution and Set Match scoring.
• Rollup metrics population in AgentScoreWork.