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

Function sync_role_metadata_from_cold_start

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

Write structured cold-start seed data back into roles.json for the matching role.

(
    user_id: str,
    profile: Dict[str, Any],
    *,
    explicit_text: Optional[str] = None,
    scholar_url: Optional[str] = None,
    homepage_url: Optional[str] = None,
    scholar_result: Optional[Dict[str, Any]] = None,
    homepage_result: Optional[Dict[str, Any]] = None,
)

Source from the content-addressed store, hash-verified

318
319
320def sync_role_metadata_from_cold_start(
321 user_id: str,
322 profile: Dict[str, Any],
323 *,
324 explicit_text: Optional[str] = None,
325 scholar_url: Optional[str] = None,
326 homepage_url: Optional[str] = None,
327 scholar_result: Optional[Dict[str, Any]] = None,
328 homepage_result: Optional[Dict[str, Any]] = None,
329) -> bool:
330 """Write structured cold-start seed data back into roles.json for the matching role."""
331 roles_meta = _load_roles_meta()
332 role_match = _find_role_entry_by_user_id(roles_meta, user_id)
333 if not role_match:
334 return False
335
336 role_name, role_info = role_match
337 changed = False
338 seed_directions = _build_seed_directions(profile)
339 bootstrap_summary = _build_role_bootstrap_summary(
340 profile,
341 explicit_text=explicit_text,
342 seed_directions=seed_directions,
343 )
344
345 if bootstrap_summary and role_info.get("bootstrap_summary") != bootstrap_summary:
346 role_info["bootstrap_summary"] = bootstrap_summary
347 changed = True
348
349 if not str(role_info.get("description") or "").strip() and bootstrap_summary:
350 role_info["description"] = bootstrap_summary
351 changed = True
352
353 if seed_directions and role_info.get("seed_directions") != seed_directions:
354 role_info["seed_directions"] = seed_directions
355 changed = True
356
357 for obsolete_key in ("scholar_url", "homepage_url", "scholar_seed", "homepage_seed"):
358 if obsolete_key in role_info:
359 del role_info[obsolete_key]
360 changed = True
361
362 if not changed:
363 return False
364
365 role_info["cold_start_updated_at"] = datetime.now().isoformat()
366 roles_meta.setdefault("roles", {})[role_name] = role_info
367 _save_roles_meta(roles_meta)
368 return True
369
370
371def resolve_baseline_pdf_path(user_id: str) -> Optional[str]:

Callers 1

cold_startFunction · 0.85

Calls 7

_load_roles_metaFunction · 0.85
_build_seed_directionsFunction · 0.85
_save_roles_metaFunction · 0.85
getMethod · 0.80
nowMethod · 0.80

Tested by

no test coverage detected