MCPcopy Create free account
hub / github.com/google/adk-samples / compare_decision

Function compare_decision

python/agents/invoice-processing/eval/eval.py:164–206  ·  view source on GitHub ↗

Compare the processing decision (ACCEPT/REJECT/SET_ASIDE). Reads the decision field path and status-to-decision mapping from master data. Falls back to hardcoded "Invoice Processing.Invoice Status" if no master data.

(
    gt: dict, agent: dict, master: MasterData | None = None
)

Source from the content-addressed store, hash-verified

162
163
164def compare_decision(
165 gt: dict, agent: dict, master: MasterData | None = None
166) -> dict:
167 """Compare the processing decision (ACCEPT/REJECT/SET_ASIDE).
168
169 Reads the decision field path and status-to-decision mapping from master data.
170 Falls back to hardcoded "Invoice Processing.Invoice Status" if no master data.
171 """
172 if master:
173 decision_path = master.get_eval_decision_path()
174 status_mapping = master.get_eval_status_to_decision()
175 else:
176 decision_path = "Invoice Processing.Invoice Status"
177 status_mapping = _FALLBACK_STATUS_TO_DECISION
178
179 # Resolve the decision path (e.g., "Invoice Processing.Invoice Status")
180 parts = decision_path.split(".")
181 gt_status = gt
182 agent_status = agent
183 for part in parts:
184 gt_status = (
185 (gt_status or {}).get(part, "")
186 if isinstance(gt_status, dict)
187 else ""
188 )
189 agent_status = (
190 (agent_status or {}).get(part, "")
191 if isinstance(agent_status, dict)
192 else ""
193 )
194
195 gt_decision = status_to_decision(gt_status, status_mapping)
196 agent_decision = status_to_decision(agent_status, status_mapping)
197
198 match = gt_decision == agent_decision
199
200 return {
201 "ground_truth_status": gt_status,
202 "agent_status": agent_status,
203 "ground_truth_decision": gt_decision,
204 "agent_decision": agent_decision,
205 "match": match,
206 }
207
208
209def compare_financials(gt: dict, agent: dict, tolerance: float) -> dict:

Callers 1

evaluate_caseFunction · 0.85

Calls 4

status_to_decisionFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected