a2a-source-edit: write agent.py
This commit is contained in:
13
agent.py
13
agent.py
@@ -760,9 +760,16 @@ def _analyze_snapshots(tenant_id: str, snapshots: SnapshotBundle, policy: Policy
|
||||
|
||||
if duplicate_invoices:
|
||||
unknowns.append(f"Duplicate invoices suppressed from amount totals: {len(duplicate_invoices)}")
|
||||
findings = [item for item in findings if item.recoverable_amount >= 0]
|
||||
findings.sort(key=lambda item: (-item.recoverable_amount, item.customer_token, item.leakage_type.value))
|
||||
return findings, sorted(set(unknowns))
|
||||
nonnegative_findings: list[LeakageFinding] = []
|
||||
for finding in findings:
|
||||
if finding.recoverable_amount >= 0:
|
||||
nonnegative_findings.append(finding)
|
||||
nonnegative_findings.sort(key=_finding_sort_key)
|
||||
return nonnegative_findings, sorted(set(unknowns))
|
||||
|
||||
|
||||
def _finding_sort_key(finding: LeakageFinding) -> tuple[float, str, str]:
|
||||
return (-finding.recoverable_amount, finding.customer_token, finding.leakage_type.value)
|
||||
|
||||
|
||||
def _finding(tenant_id: str, customer_id: str, leakage_type: LeakageType, amount: float, currency: str, confidence: float, confidence_level: float, evidence: list[str], blockers: list[str], action: RecoveryAction) -> LeakageFinding:
|
||||
|
||||
Reference in New Issue
Block a user