MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / _build_seed_directions

Function _build_seed_directions

agents/coldstart-agent/main.py:265–294  ·  view source on GitHub ↗

Serialize the strongest directions back into role metadata.

(profile: Dict[str, Any], limit: int = 8)

Source from the content-addressed store, hash-verified

263
264
265def _build_seed_directions(profile: Dict[str, Any], limit: int = 8) -> List[Dict[str, Any]]:
266 """Serialize the strongest directions back into role metadata."""
267 try:
268 direction_lexicon = importlib.import_module("config.direction_lexicon")
269 except Exception:
270 direction_lexicon = None
271
272 items = sorted(
273 (profile.get("core_directions") or {}).items(),
274 key=lambda item: (-float(item[1]), str(item[0])),
275 )
276 result: List[Dict[str, Any]] = []
277 for direction_key, weight in items[:limit]:
278 if not direction_key:
279 continue
280 entry = (
281 direction_lexicon.get_direction_entry(direction_key)
282 if direction_lexicon and hasattr(direction_lexicon, "get_direction_entry")
283 else None
284 )
285 result.append(
286 {
287 "canonical_name": direction_key,
288 "name": str((entry or {}).get("name") or _direction_to_seed_phrase(direction_key)).strip(),
289 "name_cn": str((entry or {}).get("name_cn") or (entry or {}).get("name") or _direction_to_seed_phrase(direction_key)).strip(),
290 "bootstrap_phrase": _direction_to_seed_phrase(direction_key),
291 "weight": round(float(weight or 0.0), 4),
292 }
293 )
294 return result
295
296
297def _build_role_bootstrap_summary(

Calls 2

getMethod · 0.80

Tested by

no test coverage detected