@@ -18,6 +18,7 @@ class AgentMatch:
1818 missing_evidence : tuple [str , ...]
1919 requested_bond_units : int
2020 max_bond_units : int
21+ warrantability_score : int
2122 reasons : tuple [str , ...]
2223
2324
@@ -37,7 +38,7 @@ def list_agents(self) -> list[dict[str, Any]]:
3738
3839 def match (self , request : WorkRequest ) -> list [AgentMatch ]:
3940 matches = [_match_manifest (manifest , request ) for manifest in self ._manifests .values ()]
40- return sorted (matches , key = lambda item : (not item .eligible , item .display_name ))
41+ return sorted (matches , key = lambda item : (not item .eligible , - item . warrantability_score , item .display_name ))
4142
4243
4344def run_registry_demo () -> dict [str , Any ]:
@@ -85,6 +86,7 @@ def match_to_public(match: AgentMatch) -> dict[str, Any]:
8586 "missingEvidence" : list (match .missing_evidence ),
8687 "requestedBondUnits" : match .requested_bond_units ,
8788 "maxBondUnits" : match .max_bond_units ,
89+ "warrantabilityScore" : match .warrantability_score ,
8890 "reasons" : list (match .reasons ),
8991 }
9092
@@ -104,6 +106,12 @@ def _match_manifest(manifest: AgentManifest, request: WorkRequest) -> AgentMatch
104106 reasons .append ("unsupported_promise_type" )
105107 if not reasons :
106108 reasons .append ("eligible_for_warranted_quote" )
109+ score = _warrantability_score (
110+ required_count = len (required ),
111+ matched_count = len (matched ),
112+ requested_bond_units = request .requested_bond_units ,
113+ max_bond_units = manifest .max_bond_units ,
114+ )
107115 return AgentMatch (
108116 agent_id = manifest .agent_id ,
109117 display_name = manifest .display_name ,
@@ -113,5 +121,24 @@ def _match_manifest(manifest: AgentManifest, request: WorkRequest) -> AgentMatch
113121 missing_evidence = missing ,
114122 requested_bond_units = request .requested_bond_units ,
115123 max_bond_units = manifest .max_bond_units ,
124+ warrantability_score = score ,
116125 reasons = tuple (reasons ),
117126 )
127+
128+
129+ def _warrantability_score (
130+ * ,
131+ required_count : int ,
132+ matched_count : int ,
133+ requested_bond_units : int ,
134+ max_bond_units : int ,
135+ ) -> int :
136+ if required_count == 0 :
137+ evidence_score = 70
138+ else :
139+ evidence_score = int (70 * (matched_count / required_count ))
140+ if requested_bond_units <= 0 :
141+ bond_score = 30
142+ else :
143+ bond_score = int (30 * min (max_bond_units / requested_bond_units , 1 ))
144+ return min (100 , evidence_score + bond_score )
0 commit comments